Skip to content

Implement ExtendableEvent as base type for ServiceWorker events - #13292

Merged
bors-servo merged 1 commit into
servo:masterfrom
creativcoder:extendable
Sep 17, 2016
Merged

bors-servo merged 1 commit into
servo:masterfrom
creativcoder:extendable

Conversation

@creativcoder

@creativcoder creativcoder commented Sep 16, 2016 •

Copy link
Copy Markdown
Contributor

r? @jdm


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #__ (github issue number if applicable).
  • These changes do not require tests because refactor

This change is Reviewable

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @KiChjang: components/script/dom/webidls/ExtendableEvent.webidl, components/script/dom/mod.rs, components/script/dom/webidls/ExtendableMessageEvent.webidl, components/script/dom/extendablemessageevent.rs, components/script/dom/extendableevent.rs, components/script/dom/serviceworkerglobalscope.rs

@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Sep 16, 2016

fn dispatch_activate(&self) {
let event = ExtendableEvent::new(GlobalRef::Worker(self.upcast::<WorkerGlobalScope>()),
atom!("activate"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indentation

[Constructor(DOMString type,
optional ExtendableEventInit eventInitDict),
Exposed=ServiceWorker,
Pref="dom.serviceworker.enabled" ]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove the extra space before ]


[ Constructor(DOMString type, optional ExtendableMessageEventInit eventInitDict),
Exposed=ServiceWorker,
Pref="dom.serviceworker.enabled" ]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove the extra space after [ and before ]

impl ExtendableMessageEvent {
pub fn new_uninitialized(global: GlobalRef) -> Root<ExtendableMessageEvent> {
ExtendableMessageEvent::new_initialized(global,
HandleValue::undefined(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indentation

extensions_allowed: true
}
}
pub fn new_uninitialized(global: GlobalRef) -> Root<ExtendableEvent> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move the initialization into new directly.

DOMString::new())
}

pub fn new_initialized(global: GlobalRef,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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` ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add [Throws] to the webidl method.

type_: DOMString,
init: &ExtendableEventBinding::ExtendableEventInit) -> Fallible<Root<ExtendableEvent>> {
Ok(ExtendableEvent::new(global,
Atom::from(type_),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indentation.

@jdm jdm assigned jdm and unassigned larsbergstrom Sep 16, 2016
@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Sep 16, 2016
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Sep 16, 2016

@jdm jdm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this; we can't be dispatching in the constructor.

DOMString::new())
}

pub fn new_initialized(global: GlobalRef,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be called new.

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Sep 16, 2016
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Sep 16, 2016
@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Sep 16, 2016

@jdm jdm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These aren't used now, are they?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in event.init_event(). Made changes.


pub fn Constructor(global: GlobalRef,
type_: DOMString,
init: &ExtendableEventBinding::ExtendableEventInit) -> Fallible<Root<ExtendableEvent>> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indentation.


// 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<()> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use ErrorResult instead of Fallible<()>.

event.init_event(type_, bubbles, cancelable);
}
ev
reflect_dom_object(ev, global, ExtendableMessageEventBinding::Wrap)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should reflect the object as soon as possible after creating it, otherwise we risk GC-unsafety.

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Sep 17, 2016
};
ev.data.set(data.get());
let ev = reflect_dom_object(ev, global, ExtendableMessageEventBinding::Wrap);
{

@creativcoder creativcoder Sep 17, 2016 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdm Will this be safe place of invocation for reflect_dom_object ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

@jdm jdm added the S-needs-squash Some (or all) of the commits in the PR should be combined. label Sep 17, 2016
@jdm jdm removed the S-awaiting-review There is new code that needs to be reviewed. label Sep 17, 2016
@jdm

jdm commented Sep 17, 2016

Copy link
Copy Markdown
Member

@bors-servo: delegate+
Please squash them all into one commit, then you can merge with r=jdm.

@bors-servo

Copy link
Copy Markdown
Contributor

✌️ @creativcoder can now approve this pull request

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Sep 17, 2016
@creativcoder

Copy link
Copy Markdown
Contributor Author

@bors-servo r=jdm

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 8b10cca has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-squash Some (or all) of the commits in the PR should be combined. labels Sep 17, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 8b10cca with merge 83f687a...

bors-servo pushed a commit that referenced this pull request Sep 17, 2016
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 -->
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows-dev

@bors-servo
bors-servo merged commit 8b10cca into servo:master Sep 17, 2016
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Sep 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants