-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Calculate ancestorOrigins on document creation and store on document #12071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11480,6 +11480,78 @@ partial interface <dfn id="document" data-lt="">Document</dfn> { | |
| readonly attribute <span>Element</span>? <span data-x="dom-documentorshadowroot-activeElement">activeElement</span>; | ||
| };</code></pre> | ||
|
|
||
| <h4>Ancestor origins</h4> | ||
|
|
||
| <div algorithm> | ||
| <p>A <code>Document</code> object has an associated <dfn export for="Document" | ||
| data-x="concept-document-internal-ancestor-origin-objects-list">internal ancestor origin objects | ||
| list</dfn>, initially « ».</p> | ||
|
|
||
| <p>The <dfn>internal ancestor origin objects list creation steps</dfn> given a | ||
| <code>Document</code> object <var>innerDoc</var> are:</p> | ||
|
|
||
| <ol> | ||
| <li><p>Let <var>output</var> be « ».</p></li> | ||
|
|
||
| <li><p>Let <var>parentDoc</var> be <var>innerDoc</var>'s <span | ||
| data-x="doc-container-document">container document</span>.</p></li> | ||
|
|
||
| <li><p>If <var>parentDoc</var> is null, then return <var>output</var>.</p></li> | ||
|
|
||
| <li><p><span>Assert</span>: <var>parentDoc</var> is <span>fully active</span>.</p></li> | ||
|
|
||
| <li><p>Let <var>ancestorOrigins</var> be <var>parentDoc</var>'s <span | ||
| data-x="concept-document-internal-ancestor-origin-objects-list">internal ancestor origin objects | ||
| list</span>.</p></li> | ||
|
|
||
| <li><p><span data-x="list append">Append</span> <var>parentDoc</var>'s <span | ||
| data-x="concept-document-origin">origin</span> to <var>output</var>.</p></li> | ||
|
|
||
| <li> | ||
| <p><span data-x="list iterate">For each</span> <var>ancestorOrigin</var> of | ||
| <var>ancestorOrigins</var>:</p> | ||
|
|
||
| <ol> | ||
| <li><p><span data-x="list append">Append</span> <var>ancestorOrigin</var> to | ||
| <var>output</var>.</p></li> | ||
| </ol> | ||
| </li> | ||
|
|
||
| <li><p>Return <var>output</var>.</p></li> | ||
| </ol> | ||
| </div> | ||
|
|
||
| <div algorithm> | ||
| <p>A <code>Document</code> object has an associated <dfn export for="Document" | ||
| data-x="concept-document-ancestor-origins-list">ancestor origins list</dfn>, initially a | ||
| <code>DOMStringList</code> object whose associated list is an empty <span>list</span>.</p> | ||
|
|
||
| <p>The <dfn>ancestor origins list creation steps</dfn> given a <code>Document</code> object | ||
| <var>document</var> are:</p> | ||
|
|
||
| <ol> | ||
| <li><p>Let <var>ancestorOrigins</var> be <var>document</var>'s <span | ||
| data-x="concept-document-internal-ancestor-origin-objects-list">internal ancestor origin objects | ||
| list</span>.</p></li> | ||
|
|
||
| <li><p>Let <var>output</var> be « ».</p></li> | ||
|
|
||
| <li> | ||
| <p><span data-x="list iterate">For each</span> <var>origin</var> of | ||
| <var>ancestorOrigins</var>:</p> | ||
|
|
||
| <ol> | ||
| <li><p><span data-x="list append">Append</span> the <span data-x="serialization of an | ||
| origin">serialization</span> of <var>origin</Var> to <var>output</var>.</p></li> | ||
| </ol> | ||
| </li> | ||
|
|
||
| <li><p>Return a new <code>DOMStringList</code> object whose associated list is | ||
| <var>output</var>.</p></li> | ||
| </ol> | ||
| </div> | ||
|
|
||
|
|
||
| <h4><dfn>Resource metadata management</dfn></h4> | ||
|
|
||
| <dl class="domintro"> | ||
|
|
@@ -96799,7 +96871,7 @@ interface <dfn interface>Location</dfn> { // but see also <a href="#the-location | |
| [<span>LegacyUnforgeable</span>] undefined <span data-x="dom-location-replace">replace</span>(USVString url); | ||
| [<span>LegacyUnforgeable</span>] undefined <span data-x="dom-location-reload">reload</span>(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not returning the same object each time from a getter seems very surprising. Why would we want that? You don't want
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Step 1 says to return a an empty Since the relevant Document can change over time, I think we can't return the same object always. So options are:
The current spec is wrong since it says
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't have to return the same object always to not violate Can you observe the object changing in WebKit? Maybe with initial
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, for example removing an https://software.hixie.ch/utilities/js/live-dom-viewer/saved/14480 Maybe option 4 is to create an empty
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think if you navigate an
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR computes a new list when a About the chaching or throwing issue, should we go with option 4? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't quite follow here. If iframe can be removed, the location have it's relevant document null, then let a = location.ancestorOrigins;
...
/* relevant document for location becomes null */
...
let b = location.ancestorOrigins;
a !== b; // trueAlso let loc = i.location;
let list = loc.ancestorOrigins;
i.contentWindow.navigation.navigate("www.some.where.else-same-origin.com");
let whatIsThis = list !== loc.ancestorOrigins;What value does Is there a reason why we can't make this attribute NewObject?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @theIDinside it's ok to have a new object when there's a semantic change, but just accessing
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK I've attempted to fix this in e3091d3
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. web-platform-tests/wpt#56635 updated also. |
||
|
|
||
| [<span>LegacyUnforgeable</span>, SameObject] readonly attribute <span>DOMStringList</span> <span data-x="dom-location-ancestorOrigins">ancestorOrigins</span>; | ||
| [<span>LegacyUnforgeable</span>] readonly attribute <span>DOMStringList</span> <span data-x="dom-location-ancestorOrigins">ancestorOrigins</span>; | ||
| };</code></pre> | ||
|
|
||
| <dl class="domintro"> | ||
|
|
@@ -96902,38 +96974,6 @@ interface <dfn interface>Location</dfn> { // but see also <a href="#the-location | |
| <code>Document</code></span> is non-null, and <code>about:blank</code> otherwise.</p> | ||
| </div> | ||
|
|
||
| <div algorithm> | ||
| <p>A <code>Location</code> object has an associated <dfn | ||
| data-x="concept-location-ancestor-origins-list">ancestor origins list</dfn>. When a | ||
| <code>Location</code> object is created, its <span | ||
| data-x="concept-location-ancestor-origins-list">ancestor origins list</span> must be set to a | ||
| <code>DOMStringList</code> object whose associated list is the <span>list</span> of strings that | ||
| the following steps would produce:</p> | ||
|
|
||
| <ol> | ||
| <li><p>Let <var>output</var> be a new <span>list</span> of strings.</p></li> | ||
|
|
||
| <li><p>Let <var>current</var> be the <code>Location</code> object's <span>relevant | ||
| <code>Document</code></span>.</p></li> | ||
|
|
||
| <li> | ||
| <p>While <var>current</var>'s <span data-x="doc-container-document">container document</span> | ||
| is non-null:</p> | ||
|
|
||
| <ol> | ||
| <li><p>Set <var>current</var> to <var>current</var>'s <span | ||
| data-x="doc-container-document">container document</span>.</p></li> | ||
|
|
||
| <li><p><span data-x="list append">Append</span> the <span data-x="serialization of an | ||
| origin">serialization</span> of <var>current</var>'s <span | ||
| data-x="concept-document-origin">origin</span> to <var>output</var>.</p></li> | ||
| </ol> | ||
| </li> | ||
|
|
||
| <li><p>Return <var>output</var>.</p></li> | ||
| </ol> | ||
| </div> | ||
|
|
||
| <div algorithm> | ||
| <p>To <dfn><code>Location</code>-object navigate</dfn> a <code>Location</code> object | ||
| <var>location</var> to a <span>URL</span> <var>url</var>, optionally given a <code | ||
|
|
@@ -97478,22 +97518,27 @@ interface <dfn interface>Location</dfn> { // but see also <a href="#the-location | |
|
|
||
| <hr> | ||
|
|
||
| <p>A <code>Location</code> object has an associated <dfn export for="Location" | ||
| data-x="concept-location-empty-domstringlist">empty <code>DOMStringList</code></dfn> which is a | ||
| <code>DOMStringList</code> object whose associated list is an empty <span>list</span>.</p> | ||
|
|
||
| <div algorithm> | ||
| <p>The <dfn attribute for="Location"><code | ||
| data-x="dom-location-ancestorOrigins">ancestorOrigins</code></dfn> getter steps are:</p> | ||
|
|
||
| <ol> | ||
| <li><p>If <span>this</span>'s <span>relevant <code>Document</code></span> is null, then return | ||
| an empty <span>list</span>.</p></li> | ||
| <span>this</span>'s <span data-x="concept-location-empty-domstringlist">empty | ||
| <code>DOMStringList</code></span>.</p></li> | ||
|
|
||
| <li><p>If <span>this</span>'s <span>relevant <code>Document</code></span>'s <span | ||
| data-x="concept-document-origin">origin</span> is not <span>same origin-domain</span> with the | ||
| <span>entry settings object</span>'s <span | ||
| data-x="concept-settings-object-origin">origin</span>, then throw a | ||
| <span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li> | ||
|
|
||
| <li><p>Otherwise, return <span>this</span>'s <span | ||
| data-x="concept-location-ancestor-origins-list">ancestor origins list</span>.</p></li> | ||
| <li><p>Otherwise, return <span>this</span>'s <span>relevant <code>Document</code></span>'s <span | ||
| data-x="concept-document-ancestor-origins-list">ancestor origins list</span>.</p></li> | ||
| </ol> | ||
| </div> | ||
|
|
||
|
|
@@ -104488,6 +104533,21 @@ interface <dfn interface>NotRestoredReasons</dfn> { | |
| </dl> | ||
| </li> | ||
|
|
||
| <li> | ||
| <p>If <var>embedder</var> is non-null, then:</p> | ||
|
|
||
| <ol> | ||
| <li><p>Set <var>document</var>'s <span | ||
| data-x="concept-document-internal-ancestor-origin-objects-list">internal ancestor origin | ||
| objects list</span> to the result of running the <span>internal ancestor origin objects list | ||
| creation steps</span> given <var>document</var>.</p></li> | ||
|
|
||
| <li><p>Set <var>document</var>'s <span data-x="concept-document-ancestor-origins-list">ancestor | ||
| origins list</span> to the result of running the <span>ancestor origins list creation | ||
| steps</span> given <var>document</var>.</p></li> | ||
| </ol> | ||
| </li> | ||
|
|
||
| <li> | ||
| <p>If <var>creator</var> is non-null, then:</p> | ||
|
|
||
|
|
@@ -111176,7 +111236,7 @@ location.href = '#foo';</code></pre> | |
| <p class="note">This means that both the <span data-x="is initial about:blank">initial | ||
| <code>about:blank</code></span> <code>Document</code>, and the new <code>Document</code> that | ||
| is about to be created, will share the same <code>Window</code> object.</p> | ||
| </li> | ||
| </li> | ||
|
|
||
| <li id="create-new-agent-and-window"> | ||
| <p>Otherwise:</p> | ||
|
|
@@ -111316,6 +111376,15 @@ location.href = '#foo';</code></pre> | |
| <li><p>Set <var>window</var>'s <span data-x="concept-document-window">associated | ||
| <code>Document</code></span> to <var>document</var>.</p></li> | ||
|
|
||
| <li><p>Set <var>document</var>'s <span | ||
| data-x="concept-document-internal-ancestor-origin-objects-list">internal ancestor origin objects | ||
| list</span> to the result of running the <span>internal ancestor origin objects list creation | ||
| steps</span> given <var>document</var>.</p></li> | ||
|
|
||
| <li><p>Set <var>document</var>'s <span data-x="concept-document-ancestor-origins-list">ancestor | ||
| origins list</span> to the result of running the <span>ancestor origins list creation | ||
| steps</span> given <var>document</var>.</p></li> | ||
|
|
||
| <li><p><span>Run CSP initialization for a <code data-x="">Document</code></span> given | ||
| <var>document</var>. <ref>CSP</ref></p> | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could use https://infra.spec.whatwg.org/#list-extend, instead of iterating manually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#11560 would need to change back to iterating the list though.