Skip to content

Commit a68a1f7

Browse files
mystordomenic
authored andcommitted
Make noopener stop the copying of session storage
This was discussed in whatwg#2681. Tests: https://bugzilla.mozilla.org/show_bug.cgi?id=1372662 Also fixes whatwg#2681's original issue by relocating the copying logic to the place where new browsing contexts are actually created, instead of it being located in the session storage portions of the spec.
1 parent ea14be5 commit a68a1f7

File tree

1 file changed

+44
-32
lines changed

1 file changed

+44
-32
lines changed

source

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22955,16 +22955,18 @@ interface <dfn>HTMLHyperlinkElementUtils</dfn> {
2295522955
<code>base</code> element.</p></li>
2295622956
<!-- c.f. concept-fs-target -->
2295722957

22958+
<li><p>Let <var>noopener</var> be true if <var>subject</var>'s <a href="#linkTypes">link
22959+
types</a> include the <code data-x="rel-noreferrer">noreferrer</code>
22960+
or <code data-x="rel-noopener">noopener</code> keyword</p></li>
22961+
2295822962
<li><p>Let <var>target</var> and <var>replace</var> be the result of applying <span>the rules for
22959-
choosing a browsing context</span> given <var>targetAttributeValue</var> and
22960-
<var>source</var>.</p></li>
22963+
choosing a browsing context</span> given <var>targetAttributeValue</var>, <var>source</var>, and
22964+
<var>noopener</var>.</p></li>
2296122965

2296222966
<li><p>If <var>target</var> is null, then return.</p></li>
2296322967

22964-
<li><p>If <var>subject</var>'s <a href="#linkTypes">link types</a> include the <code
22965-
data-x="rel-noreferrer">noreferrer</code> or <code data-x="rel-noopener">noopener</code> keyword,
22966-
and <var>replace</var> is true, then <span data-x="disowned its opener">disown
22967-
<var>target</var>'s opener</span>.</p></li>
22968+
<li><p>If <var>noopener</var> and <var>replace</var> are true, then
22969+
<span data-x="disowned its opener">disown <var>target</var>'s opener</span>.</p></li>
2296822970

2296922971
<li><p><span data-x="parse a url">Parse</span> the <span>URL</span> given by <var>subject</var>'s
2297022972
<code data-x="attr-hyperlink-href">href</code> attribute, relative to <var>subject</var>'s
@@ -76946,9 +76948,12 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {
7694676948

7694776949
<div w-nodev>
7694876950

76949-
<p>To <dfn data-x="creating a new browsing context">create a new browsing context</dfn>:</p>
76951+
<p>To <dfn data-x="creating a new browsing context">create a new browsing context</dfn>,
76952+
optionally given <var>noopener</var>:</p>
7695076953

7695176954
<ol>
76955+
<li><p>If <var>noopener</var> was not given, let it be false.</p></li>
76956+
7695276957
<li><p>Let <var>browsingContext</var> be a new <span>browsing context</span>.</p></li>
7695376958

7695476959
<li>
@@ -77010,6 +77015,19 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {
7701077015
<li><p>Add <var>document</var> to <var>browsingContext</var>'s <span>session
7701177016
history</span>.</p></li>
7701277017

77018+
<!--
77019+
NOTE: Clean up this logic in the future. SessionStorage ownership is unclear.
77020+
https://github.com/whatwg/html/pull/2832#issuecomment-315239343
77021+
-->
77022+
77023+
<li id="copy-session-storage"><p>If <var>noopener</var> is false, <var>browsingContext</var> is a
77024+
<span>top-level browsing context</span>, and <span>creator origin</span> is <span>same
77025+
origin</span> with <var>document</var>'s <span>origin</span>, then copy the <code
77026+
data-x="dom-sessionStorage">sessionStorage</code> storage area of the <span>creator origin</span>
77027+
from the <span>creator browsing context</span> into <var>browsingContext</var>'s set of session
77028+
storage areas. These areas must be considered separate, not affecting each other in any
77029+
way.</p></li>
77030+
7701377031
<li><p>Return <var>browsingContext</var>.</p></li>
7701477032
</ol>
7701577033

@@ -77625,7 +77643,8 @@ console.assert(iframeWindow.frameElement === null);
7762577643

7762677644
<p><dfn id="the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name">The rules for
7762777645
choosing a browsing context</dfn>, given null or a <span>browsing context name</span>
77628-
<var>name</var> and a <span>browsing context</span> <var>current</var>, are as follows:</p>
77646+
<var>name</var>, a <span>browsing context</span> <var>current</var>, and a
77647+
boolean <var>noopener</var> are as follows:</p>
7762977648

7763077649
<ol>
7763177650
<li><p>Let <var>chosen</var> be null.</p></li>
@@ -77678,7 +77697,8 @@ console.assert(iframeWindow.frameElement === null);
7767877697

7767977698
<ol>
7768077699
<li><p>Set <var>chosen</var> to a <span data-x="creating a new browsing context">new</span>
77681-
<span>top-level browsing context</span> and <var>new</var> to true.</p></li>
77700+
<span>top-level browsing context</span> given <var>noopener</var>, and set <var>new</var> to
77701+
true.</p></li>
7768277702

7768377703
<li><p>Set <var>chosen</var> to an existing <span>top-level browsing context</span>.</p>
7768477704
</ol>
@@ -77695,11 +77715,11 @@ console.assert(iframeWindow.frameElement === null);
7769577715

7769677716
<dd>
7769777717
<p>Set <var>chosen</var> to a <span data-x="creating a new browsing context">new</span>
77698-
<span>auxiliary browsing context</span>, with the <span>opener browsing context</span> being
77699-
<var>current</var>, and set <var>new</var> to true. If <var>name</var> is not an <span>ASCII
77700-
case-insensitive</span> match for "<code data-x="">_blank</code>", then <var>chosen</var>'s
77701-
<span data-x="browsing context name">name</span> must be set to <var>name</var> (otherwise, it
77702-
has no name).</p>
77718+
<span>auxiliary browsing context</span> given <var>noopener</var> with the <span>opener
77719+
browsing context</span> being <var>current</var>, and set <var>new</var> to true. If
77720+
<var>name</var> is not an <span>ASCII case-insensitive</span> match for "<code
77721+
data-x="">_blank</code>", then <var>chosen</var>'s <span data-x="browsing context
77722+
name">name</span> must be set to <var>name</var> (otherwise, it has no name).</p>
7770377723

7770477724
<p class="note">If the newly created <span>browsing context</span> is immediately <span
7770577725
data-x="navigate">navigated</span>, then the navigation will be done with <span>replacement
@@ -78239,10 +78259,13 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span
7823978259
<li><p>If <var>target</var> is the empty string, then set <var>target</var> to "<code
7824078260
data-x="">_blank</code>".</p></li>
7824178261

78262+
<li><p>Let <var>noopener</var> be true if <var>tokenizedFeatures</var> <span data-x="map
78263+
exists">contains</span> an entry with the key "<code data-x="">noopener</code>"</p></li>
78264+
7824278265
<li>
78243-
<p>Let <var>target browsing context</var> and <var>new</var> be the result of applying
78244-
<span>the rules for choosing a browsing context</span> given <var>target</var> and
78245-
<var>source browsing context</var>.
78266+
<p>Let <var>target browsing context</var> and <var>new</var> be the result of applying <span>the
78267+
rules for choosing a browsing context</span> given <var>target</var>, <var>source browsing
78268+
context</var>, and <var>noopener</var>.
7824678269

7824778270
<p class="example">If there is a user agent that supports control-clicking a link to open it in
7824878271
a new tab, and the user control-clicks on an element whose <code
@@ -78281,9 +78304,8 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span
7828178304
</ol>
7828278305
</li>
7828378306

78284-
<li><p>If <var>tokenizedFeatures</var> <span data-x="map exists">contains</span> an entry with
78285-
the key "<code data-x="">noopener</code>", then <span data-x="disowned its opener">disown
78286-
<var>target browsing context</var>'s opener</span> and return null.</p></li>
78307+
<li><p>If <var>noopener</var> is true, then <span data-x="disowned its opener">disown <var>target
78308+
browsing context</var>'s opener</span> and return null.</p></li>
7828778309

7828878310
<li><p>Return <var>target browsing context</var>'s <code>WindowProxy</code> object.</p></li>
7828978311
</ol>
@@ -98311,18 +98333,8 @@ interface <dfn>WindowSessionStorage</dfn> {
9831198333
object for its <code>Window</code>'s <code data-x="dom-sessionStorage">sessionStorage</code>
9831298334
attribute.</p>
9831398335

98314-
<p>When a new <span>top-level browsing context</span> is created by cloning an existing
98315-
<span>browsing context</span>, the new browsing context must start with the same session storage
98316-
areas as the original, but the two sets must from that point on be considered separate, not
98317-
affecting each other in any way.</p>
98318-
98319-
<p>When a new <span>top-level browsing context</span> is created by a <span
98320-
data-x="concept-script">script</span> in an existing <span>browsing context</span>, or by the user
98321-
following a link in an existing browsing context, or in some other way related to a specific
98322-
<code>Document</code>, and the creation is not a new start for session storage, then the session
98323-
storage area of the <span>origin</span> of that <code>Document</code> must be copied into the new
98324-
browsing context when it is created. From that point on, however, the two session storage areas
98325-
must be considered separate, not affecting each other in any way.</p>
98336+
<p>While <span>creating a new browsing context</span>, the session storage area <a
98337+
href="#copy-session-storage">is sometimes copied</a> over.</p>
9832698338

9832798339
<p id="sessionStorageEvent">When the <code data-x="dom-Storage-setItem">setItem()</code>, <code
9832898340
data-x="dom-Storage-removeItem">removeItem()</code>, and <code

0 commit comments

Comments
 (0)