-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Implement postMessage for ServiceWorkers #12910
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
Conversation
|
Heads up! This PR modifies the following files:
|
310c4dd to
1f5b94e
Compare
|
Great work! Note that the specification has steps for postMessage that include using a different interface than the MessageEvent one, but I'm happy to leave that as a followup. -S-awaiting-review +S-needs-code-changes Reviewed 12 of 13 files at r1. components/script/dom/serviceworker.rs, line 35 [r1] (raw file):
Defined in ipc-channel. now. components/script/dom/serviceworker.rs, line 118 [r1] (raw file):
We should consider buffering messages here and sending them when the sender is received. components/script/dom/serviceworkerglobalscope.rs, line 55 [r1] (raw file):
I'm not sure what this is referring to. components/script/dom/serviceworkerglobalscope.rs, line 89 [r1] (raw file):
This should be removed. components/script/dom/serviceworkerglobalscope.rs, line 242 [r1] (raw file):
I'm tempted to call components/script/dom/workerglobalscope.rs, line 401 [r1] (raw file):
The components/script/dom/bindings/structuredclone.rs, line 50 [r1] (raw file):
This should be a components/script/dom/bindings/structuredclone.rs, line 57 [r1] (raw file):
Let's make this accept the tuple struct mentioned previously, rather than raw pointers and numbers, so that we can't create StructureCloneData values out of arbitrary data buffers. components/script_traits/script_msg.rs, line 163 [r1] (raw file):
This should hold a tests/html/service-worker/index.html, line 29 [r1] (raw file):
My buffering proposal avoids this requirement. Comments from Reviewable |
|
My mistake, those are steps for Client.postMessage - I meant these steps instead, which uses ExtendableMessageEvent. Reviewed 1 of 13 files at r1. Comments from Reviewable |
|
Yep, i will be swapping Review status: all files reviewed at latest revision, 10 unresolved discussions. components/script/dom/serviceworker.rs, line 118 [r1] (raw file):
|
|
Review status: all files reviewed at latest revision, 10 unresolved discussions. components/script/dom/serviceworker.rs, line 118 [r1] (raw file):
|
|
So @jdm i gave a re-thought on this PR, and now that i know that StructuredCloneData can be destructured and we can pass |
851826d to
fec8bca
Compare
|
-S-awaiting-review +S-needs-code-changes Reviewed 10 of 10 files at r2. components/script/serviceworker_manager.rs, line 114 [r2] (raw file):
components/script/serviceworker_manager.rs, line 115 [r2] (raw file):
This clone shouldn't be necessary with the above change. components/script/serviceworker_manager.rs, line 120 [r2] (raw file):
Isn't this a perfectly normal situation if there are no buffered messages? components/script/serviceworker_manager.rs, line 165 [r2] (raw file):
Traditionally one would use the entry API for this instead. components/script/dom/serviceworker.rs, line 114 [r2] (raw file):
components/script/dom/serviceworker.rs, line 115 [r2] (raw file):
Hmm, so we always bounce postMessage through the constellation now? BackupMessage isn't a good description, in that case. Comments from Reviewable |
|
Review status: 12 of 13 files reviewed at latest revision, 6 unresolved discussions, some commit checks failed. components/script/serviceworker_manager.rs, line 120 [r2] (raw file):
|
|
-S-awaiting-review +S-needs-code-changes Reviewed 5 of 5 files at r3. components/constellation/constellation.rs, line 988 [r3] (raw file):
This is still an odd name here. components/script/dom/serviceworker.rs, line 115 [r2] (raw file):
|
7cd7827 to
7a21fb2
Compare
| script_url.as_str(), | ||
| scope_url, | ||
| skip_waiting) | ||
| } |
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.
Refactored this into a single method as this was just an unneccessary indirection.
35f33d1 to
ca255f2
Compare
|
-S-needs-rebase -S-awaiting-review +S-needs-code-changes Reviewed 17 of 17 files at r6, 17 of 17 files at r7, 5 of 5 files at r8. components/script/dom/serviceworkerregistration.rs, line 42 at r8 (raw file):
Let's make scope a Url, and change ServiceWorkerContainer::Register to not turn its url into a string quite so soon. components/script/dom/bindings/structuredclone.rs, line 70 at r7 (raw file):
This documentation should be reinstated. components/script/dom/bindings/structuredclone.rs, line 61 at r8 (raw file):
nit: extra space after (. Also, does this need to be public? Comments from Reviewable |
ca255f2 to
314dedb
Compare
|
Review status: 16 of 19 files reviewed at latest revision, 5 unresolved discussions. components/script/dom/bindings/structuredclone.rs, line 61 at r8 (raw file):
|
|
@bors-servo: r+ Reviewed 3 of 3 files at r9. Comments from Reviewable |
|
📌 Commit 314dedb has been approved by |
Implement postMessage for ServiceWorkers <!-- Please describe your changes on the following line: --> Fixes #12773 r? @jdm Changes: * Implements `postMessage` on `ServiceWorker` object. * Removes unused channels from sw and their scopes. * Fixes a crash when calling `scope.script_chan()` in sw-scopes event handling. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #12773 <!-- Either: --> - [X] There are tests for these changes at `tests/html/service-worker` <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12910) <!-- Reviewable:end -->
|
💔 Test failed - mac-rel-wpt |
Possibly #12654 |
|
⚡ Previous build results for arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, windows-dev are reusable. Rebuilding only mac-rel-wpt... |
|
☀️ Test successful - arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows-dev |
Fixes #12773
r? @jdm
Changes:
postMessageonServiceWorkerobject.scope.script_chan()in sw-scopes event handling../mach build -ddoes not report any errors./mach test-tidydoes not report any errorstests/html/service-workerThis change is