-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Tidy up the window.postMessage algorithm further #1586
Merged
+107
−140
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94357,9 +94357,23 @@ function receiver(e) { | |
|
||
<ol> <!-- a lot of this is similar or identical to port.postMessage --> | ||
|
||
<li><p>Let <var>targetWindow</var> be this <code>Window</code> object.</p> | ||
|
||
<li><p>Let <var>targetRealm</var> be <var>targetWindow</var>'s <span | ||
data-x="concept-global-object-realm">Realm</span>.</p></li> | ||
|
||
<li><p>Let <var>incumbentSettings</var> be the <span>incumbent settings object</span>.</p></li> | ||
<!-- This is one of the few cases where incumbent is probably the right choice. Current or | ||
relevant would mean that the MessageEvent's source property always points to the "calling" | ||
window, in same-origin cases. See discussion at | ||
https://github.com/whatwg/html/issues/1542#issuecomment-233502636 --> | ||
|
||
<li><p>If <var>targetOrigin</var> is a single U+002F SOLIDUS character (/), set | ||
<var>targetOrigin</var> to <var>incumbentSettings</var>'s <span>origin</span>.</p> | ||
|
||
<li> | ||
<p>If the value of the <var>targetOrigin</var> argument is neither a single U+002A ASTERISK | ||
character (*) nor a single U+002F SOLIDUS character (/), then:</p> | ||
<p>Otherwise, if <var>targetOrigin</var> is not a single U+002A ASTERISK character (*), | ||
then:</p> | ||
|
||
<ol> | ||
<li><p>Let <var>parsedURL</var> be the result of running the <span>URL parser</span> on | ||
|
@@ -94373,59 +94387,40 @@ function receiver(e) { | |
</ol> | ||
</li> | ||
|
||
<li><p>Let <var>targetRealm</var> be this <code>Window</code> object's <span | ||
data-x="concept-global-object-realm">Realm</span>.</p></li> | ||
|
||
<li><p>Let <var>incumbentSettings</var> be the <span>incumbent settings object</span>.</p></li> | ||
<!-- This is one of the few cases where incumbent is probably the right choice. Current or | ||
relevant would mean that the MessageEvent's source property always points to the "calling" | ||
window, in same-origin cases. See discussion at | ||
https://github.com/whatwg/html/issues/1542#issuecomment-233502636 --> | ||
|
||
<li><p>Let <var>cloneRecord</var> be <span>StructuredCloneWithTransfer</span>(<var>message</var>, | ||
<var>transfer</var>, <var>targetRealm</var>). Rethrow any exceptions.</p></li> | ||
|
||
<li><p>Let <var>message clone</var> be <var>cloneRecord</var>.[[Clone]].</p></li> | ||
<li><p>Let <var>messageClone</var> be <var>cloneRecord</var>.[[Clone]].</p></li> | ||
|
||
<li><p>Let <var>new ports</var> be a new <span>frozen array</span> consisting of all | ||
<li><p>Let <var>newPorts</var> be a new <span>frozen array</span> consisting of all | ||
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. If you're changing these steps we should maybe also update the corresponding steps in dom-MessagePort-postMessage |
||
<code>MessagePort</code> objects in <var>cloneRecord</var>.[[TransferList]], if any, maintaining | ||
their relative order.</p></li> | ||
|
||
<li><p>Return, but continue running these steps in <span>in parallel</span>.</p></li> | ||
|
||
<li> | ||
<p>If the <var>targetOrigin</var> argument is a single literal U+002F SOLIDUS character (/), and | ||
this <code>Window</code> object's <span data-x="concept-document-window">associated | ||
<code>Document</code></span>'s <span>origin</span> is not <span>same origin</span> with | ||
<var>incumbentSettings</var>'s <span>responsible document</span>'s <span>origin</span>, then | ||
abort these steps.</p> | ||
|
||
<p>Otherwise, if the <var>targetOrigin</var> argument is not a single literal U+002A ASTERISK | ||
character (*) and this <code>Window</code> object's <span | ||
data-x="concept-document-window">associated <code>Document</code></span>'s <span>origin</span> | ||
is not <span>same origin</span> with <var>targetOrigin</var>, then abort these steps.</p> | ||
</li> | ||
<li><p>If the <var>targetOrigin</var> argument is not a single literal U+002A ASTERISK character | ||
(*) and <var>targetWindow</var>'s <span data-x="concept-document-window">associated | ||
<code>Document</code></span>'s <span>origin</span> is not <span>same origin</span> with | ||
<var>targetOrigin</var>, then abort these steps.</p></li> | ||
|
||
<li><p>Create a <span data-x="concept-events-trusted">trusted</span> event that uses the | ||
<code>MessageEvent</code> interface, with the event type <code | ||
data-x="event-message">message</code>, which does not bubble, is not cancelable, and has no | ||
default action. The <code data-x="dom-MessageEvent-data">data</code> attribute must be | ||
initialised to the value of <var>message clone</var>, the <code | ||
data-x="dom-MessageEvent-origin">origin</code> attribute must be initialised to the <span | ||
data-x="Unicode serialisation of an origin">Unicode serialisation</span> of the | ||
<span>origin</span> specified by <var>incumbentSettings</var>, the <code | ||
data-x="event-message">message</code>, which does not bubble and is not cancelable. The <code | ||
data-x="dom-MessageEvent-data">data</code> attribute must be initialised to | ||
<var>messageClone</var>, the <code data-x="dom-MessageEvent-origin">origin</code> attribute must | ||
be initialised to the <span data-x="Unicode serialisation of an origin">Unicode | ||
serialisation</span> of <var>incumbentSettings</var>'s <span>origin</span>, the <code | ||
data-x="dom-MessageEvent-source">source</code> attribute must be initialised to the | ||
<code>WindowProxy</code> object corresponding to the <span | ||
data-x="concept-settings-object-global">global object</span> (a <code>Window</code> object) | ||
specified by <var>incumbentSettings</var>, and the <code | ||
data-x="dom-MessageEvent-ports">ports</code> attribute must be initialised to the <var>new | ||
ports</var> array.</p></li> <!-- invariant: the global object is always a Window if the script | ||
can see this method --> | ||
<code>WindowProxy</code> object corresponding <var>incumbentSettings</var>'s <span | ||
data-x="concept-settings-object-global">global object</span> (a <code>Window</code> object), and | ||
the <code data-x="dom-MessageEvent-ports">ports</code> attribute must be initialised to | ||
<var>newPorts</var>.</p></li> <!-- invariant: the global object is always a Window if the | ||
script can see this method --> | ||
|
||
<li><p><span>Queue a task</span> to <span data-x="concept-event-dispatch">dispatch</span> the | ||
event created in the previous step at the <code>Window</code> object on which the method was | ||
invoked. The <span>task source</span> for this <span data-x="concept-task">task</span> is the | ||
<span>posted message task source</span>.</p></li> | ||
event created in the previous step at <var>targetWindow</var>. The <span>task source</span> for | ||
this <span data-x="concept-task">task</span> is the <span>posted message task | ||
source</span>.</p></li> | ||
|
||
</ol> | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
then*