Repository navigation
Implement ExtendableEvent as base type for ServiceWorker events - #13292
Conversation
|
Heads up! This PR modifies the following files:
|
69e6765 to
1b7e0ae
Compare
|
|
||
| fn dispatch_activate(&self) { | ||
| let event = ExtendableEvent::new(GlobalRef::Worker(self.upcast::<WorkerGlobalScope>()), | ||
| atom!("activate"), |
| [Constructor(DOMString type, | ||
| optional ExtendableEventInit eventInitDict), | ||
| Exposed=ServiceWorker, | ||
| Pref="dom.serviceworker.enabled" ] |
There was a problem hiding this comment.
nit: remove the extra space before ]
|
|
||
| [ Constructor(DOMString type, optional ExtendableMessageEventInit eventInitDict), | ||
| Exposed=ServiceWorker, | ||
| Pref="dom.serviceworker.enabled" ] |
There was a problem hiding this comment.
nit: remove the extra space after [ and before ]
| impl ExtendableMessageEvent { | ||
| pub fn new_uninitialized(global: GlobalRef) -> Root<ExtendableMessageEvent> { | ||
| ExtendableMessageEvent::new_initialized(global, | ||
| HandleValue::undefined(), |
| extensions_allowed: true | ||
| } | ||
| } | ||
| pub fn new_uninitialized(global: GlobalRef) -> Root<ExtendableEvent> { |
There was a problem hiding this comment.
I don't see any need to have the split between initialized/uninitialized. That's only for older event types that can be created in an uninitialized states.
| init.parent.cancelable)) | ||
| } | ||
|
|
||
| fn init_extendable_event(&self, |
There was a problem hiding this comment.
Let's move the initialization into new directly.
| DOMString::new()) | ||
| } | ||
|
|
||
| pub fn new_initialized(global: GlobalRef, |
There was a problem hiding this comment.
No need for the initialized/uninitialized split.
| pub fn WaitUntil(&self, _cx: *mut JSContext, val: HandleValue) { | ||
| // Step 1 | ||
| if !self.extensions_allowed { | ||
| // TODO throw invalid state error, but this does not return a `Fallible` ? |
| type_: DOMString, | ||
| init: &ExtendableEventBinding::ExtendableEventInit) -> Fallible<Root<ExtendableEvent>> { | ||
| Ok(ExtendableEvent::new(global, | ||
| Atom::from(type_), |
1b7e0ae to
55ee2db
Compare
58a9301 to
c06c2b4
Compare
jdm
left a comment
There was a problem hiding this comment.
The indentation in dispatch_activate is still incorrect.
| let ev = reflect_dom_object(box ExtendableEvent::new_inherited(), global, ExtendableEventBinding::Wrap); | ||
| { | ||
| let ev = ev.upcast::<Event>(); | ||
| if !ev.dispatching() { |
There was a problem hiding this comment.
No need for this; we can't be dispatching in the constructor.
| DOMString::new()) | ||
| } | ||
|
|
||
| pub fn new_initialized(global: GlobalRef, |
c06c2b4 to
bddb13a
Compare
jdm
left a comment
There was a problem hiding this comment.
We can include the update to string_cache now, since it's been published.
| pub fn new(global: GlobalRef, | ||
| type_: Atom, | ||
| bubbles: bool, | ||
| cancelable: bool) |
There was a problem hiding this comment.
Yes, in event.init_event(). Made changes.
|
|
||
| pub fn Constructor(global: GlobalRef, | ||
| type_: DOMString, | ||
| init: &ExtendableEventBinding::ExtendableEventInit) -> Fallible<Root<ExtendableEvent>> { |
|
|
||
| // https://w3c.github.io/ServiceWorker/#wait-until-method | ||
| pub fn WaitUntil(&self, _cx: *mut JSContext, val: HandleValue) { | ||
| pub fn WaitUntil(&self, _cx: *mut JSContext, val: HandleValue) -> Fallible<()> { |
There was a problem hiding this comment.
We can use ErrorResult instead of Fallible<()>.
| event.init_event(type_, bubbles, cancelable); | ||
| } | ||
| ev | ||
| reflect_dom_object(ev, global, ExtendableMessageEventBinding::Wrap) |
There was a problem hiding this comment.
We should reflect the object as soon as possible after creating it, otherwise we risk GC-unsafety.
bddb13a to
1533d3e
Compare
1533d3e to
10d43c6
Compare
| }; | ||
| ev.data.set(data.get()); | ||
| let ev = reflect_dom_object(ev, global, ExtendableMessageEventBinding::Wrap); | ||
| { |
There was a problem hiding this comment.
@jdm Will this be safe place of invocation for reflect_dom_object ?
|
@bors-servo: delegate+ |
|
✌️ @creativcoder can now approve this pull request |
10d43c6 to
8b10cca
Compare
|
@bors-servo r=jdm |
|
📌 Commit 8b10cca has been approved by |
Implement ExtendableEvent as base type for ServiceWorker events <!-- Please describe your changes on the following line: --> r? @jdm --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [X] These changes do not require tests because refactor <!-- 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/13292) <!-- Reviewable:end -->
|
☀️ Test successful - arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows-dev |
r? @jdm
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is