Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUse ExtendableMessageEvent for messageerror in service workers #25241 #26607
Conversation
highfive
commented
May 21, 2020
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @nox (or someone else) soon. |
highfive
commented
May 21, 2020
|
Heads up! This PR modifies the following files:
|
|
r? @gterzian |
|
@jdm I followed the coding style in both files, but tidy didn't like, should I alter the format for the changes to please tidy, or leave it as is? |
|
Please run |
|
Okay, I ran ./ mach fmt and everything should be good to go. If any other edits are needed please let me know! |
|
Thank you, I will look at it. First question: are the webgl and taskcluster changes related? |
|
Looks good, and I think we can further leverage WebIDL to do some work for us. It also looks to me like some unrelated changes slipped into the PR. |
| @@ -123,6 +123,21 @@ impl ExtendableMessageEvent { | |||
| ); | |||
| Extendablemessageevent.upcast::<Event>().fire(target); | |||
| } | |||
|
|
|||
| pub fn dispatch_error(target: &EventTarget, scope: &GlobalScope, message: HandleValue) { | |||
| let ExtendableMsgEvent = ExtendableMessageEvent::new( | |||
This comment has been minimized.
This comment has been minimized.
gterzian
May 22, 2020
Member
We can do something similar to what is currently done in messageevent.rs, by:
- In
ExtendableMessageEvent.webidl, un-comment theportsattribute ofExtendableMessageEventInit. - Here, use
let init = ExtendableMessageEvent::MessageEventInit::empty(); - then use the data from init when calling
ExtendableMessageEvent::new.
This comment has been minimized.
This comment has been minimized.
nosark
May 22, 2020
Author
Contributor
Okay, I'll rewrite and cleanup the newlines. My bad. Thank you!
| DOMString::new(), | ||
| Vec::<DomRoot<MessagePort>>::new(), | ||
| ); | ||
|
|
This comment has been minimized.
This comment has been minimized.
gterzian
May 22, 2020
Member
nit: I don't think we need the newline here(not something fmt will fix).
This comment has been minimized.
This comment has been minimized.
| ExtendableMessageEvent::dispatch_error( | ||
| target, | ||
| scope.upcast(), | ||
| message.handle(), |
This comment has been minimized.
This comment has been minimized.
gterzian
May 22, 2020
Member
When we will be using ExtendableMessageEvent::MessageEventInit::empty(), we don't need to pass the HandleValue anymore, since it will be part of the empty initialized value.
This comment has been minimized.
This comment has been minimized.
nosark
May 22, 2020
Author
Contributor
Okay, for some reason I thought we needed the data for the error handling. I apologize I'm newer to the code base. I'll get this fixed right away. Thank you for the input!
|
While we are at it, let's also add some spec links to https://github.com/servo/servo/pull/26607/files#diff-ee0d03fc9e0cdadcde40c50bd0f8369eL30 For the struct as a whole it would be https://w3c.github.io/ServiceWorker/#extendablemessageevent-interface and you'll see below the links for the various members(not complete one to one match but you'll see), for example for The docs require a triple |
|
@gterzian are the changes you're referencing already covered in the above comments? I didn't touch any other files other than manifest (with ./mach update-manifest), extendablemessageevent.rs, and serviceworkerglobalscope.rs. I did pull upstream to keep my fork synced, maybe that caused the unexpected changes? |
Yes maybe, how did you do it, with a git merge? What we usually do is a rebase, although it's unnecessary unless there are some actual merge conflicts(there is a guide here https://github.com/servo/servo/wiki/Beginner's-guide-to-rebasing-and-squashing). So the files I am referring to are: etc/taskcluster/macos/Brewfile-build.lock.json and I think those changes should be removed from the PR(some might have been generated by |
|
etc/taskcluster/macos/Brewfile-build.lock.json the test files were changed on the pull from upstream. The etc/... files changed only upon setting up the fork to build in the readme for my environment. Weird.... I run git pull upstream master and I accept any incoming merges if conflicts arise but this last pull I didn't have to resolve any conflicts. I'll read the reabase and squashing doc |
|
Ok, I think if you rebase those change might go away, if they are already on master? Otherwise It think you can also manually undo them. Let me know if you run into some issues.
What I usually do is |
|
@gterzian I'm not sure I'm following you in regards to the spec links and docs. Could you please elaborate? Should I be adding the spec link above the struct and any other respectively? |
|
Yes I'm referring to the /// <https://w3c.github.io/ServiceWorker/#extendablemessageevent-interface>
#[dom_struct]
#[allow(non_snake_case)]
pub struct ExtendableMessageEvent {}and then if you look at the members of the struct, you will see some match the IDL definition and have their own link in the spec, and could be separately documented like for example: /// <https://w3c.github.io/ServiceWorker/#extendablemessage-event-origin>
#[ignore_malloc_size_of = "mozjs"]
data: Heap<JSVal>, |
|
@gterzian I'll add the docs and get my branch rebased. Thank you! |
|
Error syncing changes upstream. Logs saved in error-snapshot-1590517887990. |
|
Error syncing changes upstream. Logs saved in error-snapshot-1590518520183. |
|
Great, the actual changes look good, and it looks like some extra commits slipped in as well. I can't tell exactly what happened, my guess is a And then also you can squash your commits into one. |
|
Yeah, I'm not sure. I'll try the rebase and then squash everything into one commit. Thanks @gterzian! |
|
Ok, thanks for adding the docs and using the empty init. One comment left, and we also need to remove those unrelated changes, I think this can simply be done manually? And then finally, it will also require a rebase, like:
Then it should be good to do. |
| init.data.handle(), | ||
| init.origin.clone().unwrap(), | ||
| init.lastEventId.clone().unwrap(), | ||
| Vec::<DomRoot<MessagePort>>::new(), |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
nosark
Jun 4, 2020
Author
Contributor
Okay, I'll uncomment this and replace the initialized MessagePort vec with the parents port property.
| @@ -0,0 +1,202 @@ | |||
| { | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| @@ -0,0 +1,169 @@ | |||
| { | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| @@ -8719,7 +8719,7 @@ | |||
| [] | |||
| ], | |||
| "npot-video.theora.ogv": [ | |||
| "4458678fbfd81997ee5eff54f8b5e7fbd855264a", | |||
| "e2e7a25177072b19cb21be65c57d3b60c48cc9ce", | |||
This comment has been minimized.
This comment has been minimized.
gterzian
Jun 2, 2020
Member
Also this should be undone, I would suggest just manually re-adding the old hashes. And then we need to re-add the binary files that have been removed below.
This comment has been minimized.
This comment has been minimized.
nosark
Jun 4, 2020
Author
Contributor
Okay, I'll diff the changes to the Manifest.json and copy the old hashes in to replace the changed hashes.
|
@gterzian I'm running into an interesting error. It's the side effect of uncommenting the message port related line in the ExtendableMessageEvent web IDL. Any ideas as to where I should be focusing my effort? Thanks in advance!
|
|
Ok, the solution is the replace the un-commented line with |
|
That probably won't be enough - I think our codegen is missing logic for importing types that are only specific in dictionaries. You can work around for right now by adding |
| @@ -20,5 +20,5 @@ dictionary ExtendableMessageEventInit : ExtendableEventInit { | |||
| DOMString origin; | |||
| DOMString lastEventId; | |||
| // (Client or ServiceWorker /*or MessagePort*/)? source; | |||
| // sequence<MessagePort>? ports; | |||
| sequence<MessagePort> ports; | |||
This comment has been minimized.
This comment has been minimized.
gterzian
Jul 20, 2020
Member
We can add a bunch of default values to the init, so that it matches https://w3c.github.io/ServiceWorker/#extendablemessageevent
For example:
sequence<MessagePort> ports = [];DOMString origin = "";
You can look at MessageEvent.webidl which does the same thing.
That way you can remove the various unwrap following the call to init above.
|
Thanks for sticking through with this, looks like we've almost reached the finish line! |
|
@gterzian No problem! we'll get there, so close lol |
|
@gterzian @jdm I've added all of the defaults from the ExtendableMessageEvent.webidl and everything is good until I come acrossed the source attribute. It looks like we need to implement GetSource for ExtendableMessageEventMethods and a similar SrcObject enum like but for a ClientOrServiceWorkerOrMessagePort type similar to to implement GetSource(). Should I implement these as well to finish off extendablemessageevent.rs for now, or should I leave the source commented out in the ExtendableMessageEvent.webidl and commit? Thoughts? Thanks in advance! |
|
Thanks for looking into it, we can leave source commented-out in this PR, that work is tracked over at #24659 |
|
Okay cool. Thanks @gterzian ! |
|
I think it would be good to go following a squash of the two commits into one. |
|
@gterzian Done! Thanks for all of your help! |
|
Great work! @bors-servo r+ |
|
|
Use ExtendableMessageEvent for messageerror in service workers #25241 <!-- Please describe your changes on the following line: --> added function dispatch_error to the ExtendableMessageEvent implmentation and replaced the MessageEvent dispatch error call with the ExtendableMessageEvent dispatch error call in serviceworkerglobalscope.rs --- <!-- 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 #25241 (GitHub issue number if applicable) <!-- Either: --> - [x] There are tests for these changes OR - [x] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
|
@gterzian thanks! |
|
|
|
@bors-servo retry
I think this is #23290 |
|
|
nosark commentedMay 21, 2020
•
edited
added function dispatch_error to the ExtendableMessageEvent implmentation and replaced the MessageEvent dispatch error call with the ExtendableMessageEvent dispatch error call in serviceworkerglobalscope.rs
./mach build -ddoes not report any errors./mach test-tidydoes not report any errors