Skip to content

Make the service worker send custom response - #12582

Merged
bors-servo merged 1 commit into
servo:masterfrom
creativcoder:sw-fetch
Jul 27, 2016
Merged

bors-servo merged 1 commit into
servo:masterfrom
creativcoder:sw-fetch

Conversation

@creativcoder

@creativcoder creativcoder commented Jul 25, 2016 •

Copy link
Copy Markdown
Contributor

  • ./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/serviceworkerglobalscope.rs, components/script/dom/abstractworker.rs, components/script/dom/abstractworkerglobalscope.rs, components/script/dom/dedicatedworkerglobalscope.rs, components/script/serviceworker_manager.rs

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

Copy link
Copy Markdown

warning Warning warning

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

@creativcoder

Copy link
Copy Markdown
Contributor Author

r? @jdm

@jdm

jdm commented Jul 25, 2016

Copy link
Copy Markdown
Member

-S-awaiting-review +S-needs-code-changes


Reviewed 5 of 5 files at r1.
Review status: 3 of 5 files reviewed at latest revision, 1 unresolved discussion.


components/script/dom/abstractworker.rs, line 21 [r1] (raw file):

    DOMMessage(StructuredCloneData),
    // custom response by service worker
    Response(CustomResponseMediator)

Could create a separate ServiceWorkerScriptMsg that includes this and a WorkerScriptMsg variant? I'm not sure about all the places where we store senders and receivers, but it would be nice to avoid introducing another message that's only used by one worker type.


Comments from Reviewable

@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 Jul 25, 2016
@jdm

jdm commented Jul 25, 2016

Copy link
Copy Markdown
Member

Reviewed 2 of 2 files at r2.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

@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 Jul 26, 2016
@creativcoder

Copy link
Copy Markdown
Contributor Author

Review status: 0 of 4 files reviewed at latest revision, 1 unresolved discussion.


components/script/dom/abstractworker.rs, line 21 [r1] (raw file):

Previously, jdm (Josh Matthews) wrote…

Could create a separate ServiceWorkerScriptMsg that includes this and a WorkerScriptMsg variant? I'm not sure about all the places where we store senders and receivers, but it would be nice to avoid introducing another message that's only used by one worker type.

okay, so I've added the `ServiceWorkerScriptMsg` enum as a seperate msg type in `serviceworkerglobalscope.rs` itself. Does that look ok to you ?

Comments from Reviewable

@jdm

jdm commented Jul 26, 2016

Copy link
Copy Markdown
Member

-S-awaiting-review +S-needs-code-changes


Reviewed 5 of 5 files at r3.
Review status: all files reviewed at latest revision, 2 unresolved discussions.


components/script/serviceworker_manager.rs, line 153 [r3] (raw file):

    fn handle_message_from_resource(&mut self, mediator: CustomResponseMediator) -> bool {
        let worker_sender = self.prepare_activation(&mediator.load_url);
        if serviceworker_enabled() {

This should probably guard the prepare_activation call as well.


components/script/dom/serviceworkerglobalscope.rs, line 44 [r3] (raw file):

    Common(CommonScriptMsg),
    /// Message sent through postMessage
    DOMMessage(StructuredCloneData),

What if we replace these two variants with a CommonWorker(WorkerScriptMsg) variant?


Comments from Reviewable

@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 Jul 26, 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 Jul 26, 2016
},
WorkerScriptMsg::Common(CommonScriptMsg::CollectReports(reports_chan)) => {
ServiceWorkerScriptMsg::CommonWorker(WorkerScriptMsg::Common(CommonScriptMsg::CollectReports(reports_chan))) => {
let scope = self.upcast::<WorkerGlobalScope>();

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 I've made that change adding CommonWorker, but i think this becomes very nested in matching in handle_script_event. Also not sure to reformat the match arms as it exceeds tidy's line length check. Suggestions ?

@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 Jul 26, 2016
@jdm

jdm commented Jul 26, 2016

Copy link
Copy Markdown
Member

-S-awaiting-review +S-needs-code-changes


Reviewed 2 of 2 files at r4.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


components/script/dom/serviceworkerglobalscope.rs, line 241 [r4] (raw file):

Previously, creativcoder (Rahul Sharma) wrote…

@jdm I've made that change adding CommonWorker, but i think this becomes very nested in matching in handle_script_event. Also not sure to reformat the match arms as it exceeds tidy's line length check. Suggestions ?

Go ahead and `use ServiceWorkerScriptMsg::*` and any others that are necessary to reduce the line length.

Comments from Reviewable

@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 Jul 26, 2016
bors-servo pushed a commit that referenced this pull request Jul 26, 2016
Make the service worker send custom response

<!-- Please describe your changes on the following line: -->

---
<!-- 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/12582)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - mac-rel-wpt

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jul 26, 2016
@KiChjang

Copy link
Copy Markdown
Contributor

@bors-servo retry

  • The annoying git

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 36dbd27 with merge 84ae36e...

@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label Jul 26, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - mac-rel-wpt

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jul 26, 2016
@larsbergstrom

Copy link
Copy Markdown
Contributor

@bors-servo retry

  • servo-mac1 was still being provisioned

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 36dbd27 with merge a6ab739...

bors-servo pushed a commit that referenced this pull request Jul 27, 2016
Make the service worker send custom response

<!-- Please describe your changes on the following line: -->

---
<!-- 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/12582)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - mac-rel-wpt

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. S-tests-failed The changes caused existing tests to fail. and removed S-tests-failed The changes caused existing tests to fail. S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jul 27, 2016
@KiChjang

Copy link
Copy Markdown
Contributor

@bors-servo retry

  • The annoying git

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 36dbd27 with merge 3d976cc...

bors-servo pushed a commit that referenced this pull request Jul 27, 2016
Make the service worker send custom response

<!-- Please describe your changes on the following line: -->

---
<!-- 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/12582)
<!-- Reviewable:end -->
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Jul 27, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

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

@bors-servo
bors-servo merged commit 36dbd27 into servo:master Jul 27, 2016
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jul 27, 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.

7 participants