Skip to content

Commit 7f61e66

Browse files
jgrahamAutomatedTester
authored andcommitted
Store the top-level and parent browsing contexts explicitly.
Previously the parent and top-level browsing contexts were computed properties based on the current browsing context. This fails in the case where the frame containing the current browsing context is removed from the DOM tree since the browsing context is then discarded meaning that trying to compute its parents will fail. In practice we expect operations working with the top-level browsing context to continue working in that case (and indeed implementations are mostly/entirely not following the current spec), so this makes the top-level and parent browsing contexts explictly stored properties of the session that are updated at the point where we change browsing contexts.
1 parent f0c7bdf commit 7f61e66

File tree

1 file changed

+49
-28
lines changed

1 file changed

+49
-28
lines changed

index.html

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,14 +2160,14 @@ <h2>Sessions</h2>
21602160
representation of a <a>UUID</a>) used to uniquely identify this
21612161
session. Unless stated otherwise it is <a><code>null</code></a>.
21622162

2163-
<p>A <a>session</a> has an associated <dfn>current browsing context</dfn>,
2164-
which is the <a>browsing context</a> against which <a>commands</a> will run.
2165-
2166-
<p>A <a>session</a> has an associated
2167-
<dfn>current top-level browsing context</dfn>, which is the <a>current browsing
2168-
context</a> if it itself is a <a>top-level browsing context</a>, and otherwise
2169-
is the <a>top-level browsing context</a> of the <a>current browsing
2170-
context</a>.
2163+
<p>A <a>session</a> has an associated <dfn>current browsing
2164+
context</dfn>, which is the <a>browsing context</a> against
2165+
which <a>commands</a> will run, an associated <dfn>current parent
2166+
browsing context</dfn>, which is set to the parent of the <a>current
2167+
browsing context</a> when changing browsing contexts, and an
2168+
associated <dfn>current top-level browsing context</dfn>, which is
2169+
set to the top-browsing context ancestor of the <a>current browsing
2170+
context</a>, when changing browsing contexts.</p>
21712171

21722172
<p>
21732173
A <a>session</a> has an associated <dfn data-lt="session script timeout|session page load timeout|session implicit wait timeout">session timeouts</dfn>
@@ -2432,10 +2432,9 @@ <h3 id=new-session><dfn data-lt="new sessions|creating a new session">New Sessio
24322432

24332433
<li><p>Set the <a>webdriver-active flag</a> to true.</p>
24342434

2435-
<li><p>Set the <a>current top-level browsing context</a>
2436-
for <var>session</var> in an implementation-specific way. This
2437-
should be the <a>top-level browsing context</a> of the UA’s
2438-
<a>current browsing context</a>.
2435+
<li><p><a>Set the current top-level browsing context</a>
2436+
for <var>session</var> with the <a>top-level browsing context</a>
2437+
of the UA’s <a>current browsing context</a>.
24392438

24402439
<p class="note">WebDriver implementations typically start a
24412440
completely new browser instance, but there is no requirement in
@@ -2932,8 +2931,8 @@ <h3><dfn>Navigate To</dfn></h3>
29322931
<li><p><a>Try</a> to run the <a>post-navigation checks</a>.
29332932
</ol>
29342933

2935-
<li><p>Set the <a>current browsing context</a>
2936-
to the <a>current top-level browsing context</a>.
2934+
<li><p><a>Set the current browsing context</a> with the <a>current
2935+
top-level browsing context</a>.
29372936

29382937
<li><p>If the <a>current top-level browsing context</a> contains
29392938
a <a>refresh state pragma directive</a> of <var>time</var> 1 second
@@ -3101,8 +3100,8 @@ <h3><dfn>Refresh</dfn></h3>
31013100
<li><p><a>Try</a> to run the <a>post-navigation checks</a>.
31023101
</ol>
31033102

3104-
<li><p>Set the <a>current browsing context</a>
3105-
to the <a>current top-level browsing context</a>.
3103+
<li><p><a>Set the current browsing context</a> with <a>current
3104+
top-level browsing context</a>.
31063105

31073106
<li><p>Return <a>success</a> with data <a><code>null</code></a>.
31083107
</ol>
@@ -3195,6 +3194,28 @@ <h2>Contexts</h2>
31953194
</dl>
31963195
</ol>
31973196

3197+
<p>When required to <dfn>set the current browsing context</dfn> given
3198+
a <var>context</var>, an implementation must follow the following
3199+
steps:
3200+
<ol>
3201+
<li>Set the <a>current session</a>’s <a>current browsing
3202+
context</a> to <var>context</var>.
3203+
<li>Set the <a>current session</a>’s <a>current parent browsing
3204+
context</a> to the <a>parent browsing context</a>
3205+
of <var>context</var>, if that context exists, or <a>null</a>
3206+
otherwise.
3207+
</ol>
3208+
3209+
<p>When required to <dfn>set the current top-level browsing
3210+
context</dfn> given a <var>context</var>, an implementation must
3211+
follow the following steps:
3212+
<ol>
3213+
<li>Assert: <var>context</var> is a <a>top-level browsing context</a>.
3214+
<li>Set the <a>current session</a>’s <a>current top-level browsing
3215+
context</a> to <var>context</var>.
3216+
<li><a>Set the current browsing context</a> to <var>context</var>.
3217+
</ol>
3218+
31983219
<p class=note>
31993220
In accordance with
32003221
the <a href=https://html.spec.whatwg.org/multipage/interaction.html#focus>focus</a>
@@ -3292,10 +3313,11 @@ <h3><dfn>Switch To Window</dfn></h3>
32923313
focussing of another <a>top-level browsing context</a>,
32933314
return <a>error</a> with <a>error code</a> <a>unexpected alert open</a>.
32943315

3295-
<li><p>If <var>handle</var> is equal to the associated <a>window handle</a>
3296-
for some <a>top-level browsing context</a> in the <a>current session</a>,
3297-
set the <a>session</a>’s <a>current browsing context</a>
3298-
to that browsing context.
3316+
<li><p>If <var>handle</var> is equal to the associated <a>window
3317+
handle</a> for some <a>top-level browsing context</a> in
3318+
the <a>current session</a>, let <var>context</var> be the that
3319+
browsing context, and
3320+
<a>set the current top-level browsing context</a> with <var>context</var>.
32993321

33003322
<p>Otherwise, return <a>error</a> with <a>error code</a> <a>no such window</a>.
33013323

@@ -3455,7 +3477,7 @@ <h3><dfn>Switch To Frame</dfn></h3>
34553477
<dt><var>id</var> is <a><code>null</code></a>
34563478
<dd>
34573479
<ol>
3458-
<li><p>Set the <a>current browsing context</a> to
3480+
<li><p><a>Set the current browsing context</a> with
34593481
the <a>current top-level browsing context</a>.
34603482
</ol>
34613483

@@ -3478,7 +3500,7 @@ <h3><dfn>Switch To Frame</dfn></h3>
34783500
<var>window</var>.<a data-lt='window.[[\getOwnProperty]]'><code>[[\GetOwnProperty]]</code></a>
34793501
(<var>id</var>).
34803502

3481-
<li><p>Set the <a>current browsing context</a> to
3503+
<li><p><a>Set the current browsing context</a> with
34823504
<var>child window</var>’s <a>browsing context</a>.
34833505
</ol>
34843506

@@ -3496,8 +3518,8 @@ <h3><dfn>Switch To Frame</dfn></h3>
34963518
or <a><code>iframe</code></a> element,
34973519
return <a>error</a> with <a>error code</a> <a>no such frame</a>.
34983520

3499-
<li><p>Set the <a>current browsing context</a> to <var>element</var>’s
3500-
<a>nested browsing context</a>.
3521+
<li><p><a>Set the current browsing context</a>
3522+
with <var>element</var>’s <a>nested browsing context</a>.
35013523
</ol>
35023524
</dl>
35033525

@@ -3539,10 +3561,9 @@ <h3><dfn>Switch To Parent Frame</dfn></h3>
35393561

35403562
<li><p><a>Handle any user prompts</a> and return its value if it is an <a>error</a>.
35413563

3542-
<li><p>If the <a>current browsing context</a> is not equal to
3543-
the <a>current top-level browsing context</a>,
3544-
set the <a>current browsing context</a> to
3545-
the <a>parent browsing context</a> of the <a>current browsing context</a>.
3564+
<li><p>If the <a>current session</a>'s <a>current parent browsing
3565+
context</a> is not <a>null</a>, <a>set the current browsing
3566+
context</a> with the <a>current parent browsing context</a>.
35463567

35473568
<li><p>Update any implementation-specific state that would result
35483569
from the user selecting the <a>current browsing context</a> for

0 commit comments

Comments
 (0)