Repository navigation
Implement job queue for ServiceWorkerRegistration - #13574
Conversation
|
Heads up! This PR modifies the following files:
|
|
You likely need a JSAutoCompartment in place before calling resolve_native. |
|
☔ The latest upstream changes (presumably #13596) made this pull request unmergeable. Please resolve the merge conflicts. |
04c9ee0 to
02812bf
Compare
|
@creativcoder Were you looking to have these changes reviewed at all, or just asking for help with the crash? |
|
@jdm I am at grandma's place and we barely have internet connection here to (sync+build) since the last rebase. I'll continue with the implementation when i reach college (hopefully by 20th) and notify you of code review. :) |
02812bf to
34cd67c
Compare
6f63596 to
9616714
Compare
aff5c89 to
90579e1
Compare
| @@ -0,0 +1,202 @@ | |||
| /* This Source Code Form is subject to the terms of the Mozilla Public | |||
There was a problem hiding this comment.
I mainly try to keep implementations of interfaces in script/dom/, so this file belongs in script/ instead.
| no_jsmanaged_fields!(RGBA); | ||
| no_jsmanaged_fields!(EuclidLength<Unit, T>); | ||
| no_jsmanaged_fields!(Job); | ||
| no_jsmanaged_fields!(JobQueue); |
There was a problem hiding this comment.
This looks scary. Why not derive JSTraceable instead?
|
|
||
| #[allow(unsafe_code)] | ||
| pub fn is_settled(&self) -> bool { | ||
| let mut _state = PromiseState::Pending; |
There was a problem hiding this comment.
let state = unsafe { GetPromiseState(self.promise_object()) };
| fn eq(&self, other: &Self) -> bool { | ||
| let same_job = self.job_type == other.job_type; | ||
| if same_job { | ||
| return match self.job_type { |
| #[allow(unrooted_must_root)] | ||
| // https://w3c.github.io/ServiceWorker/#run-job-algorithm | ||
| pub fn run_job(&mut self, run_job_handler: Box<RunJobHandler>, script_thread: &ScriptThread) { | ||
| let scope_url = run_job_handler.scope_url.clone(); |
| let container = ServiceWorkerContainer::new_inherited(); | ||
| let client = Client::new(&global.as_window()); | ||
| container.client.set(Some(&*client)); | ||
| reflect_dom_object(box container, global, Wrap) |
There was a problem hiding this comment.
I propose we create the client first, and pass it as an argument to new_inherited instead. That should let us use JS<Client> instead.
| fn set_controller(&self, active_worker: &ServiceWorker); | ||
| } | ||
|
|
||
| // TODO remove this trait usage |
There was a problem hiding this comment.
Setting the controller attribute to an active worker needs to happen at a much later stage (not during creation of registration), probably during activate algorithm. Since we are passing the client (which can be used to set the controller) with schedule_job, we may not need this trait then. We can set it from job.client.set_controller(sw).
| pub promise: Rc<Promise>, | ||
| pub equivalent_jobs: Vec<Job>, | ||
| // client can be a window client, worker client so `Client` will be an enum in future | ||
| pub client: Trusted<Client>, |
There was a problem hiding this comment.
It's odd to use Trusted and not TrustedPromise here. Why can't we use JS<Client>?
| let promise = job.promise.clone(); | ||
| // Initialize to an empty vec | ||
| self.0.insert(job.scope_url.clone(), vec![]); | ||
| if !self.0.contains_key(&job.scope_url) { |
There was a problem hiding this comment.
If we use the Entry API here instead, we can get clearer code I think.
| let host = url.host_str().unwrap(); | ||
| host == "127.0.0.0/8" || host == "::1/128" | ||
| // Step 5 | ||
| } else { url.scheme() == "file" } |
There was a problem hiding this comment.
nit: extra space before {, and move the check onto its own line.
90579e1 to
b6f706d
Compare
Implement job queue for ServiceWorkerRegistration <!-- Please describe your changes on the following line: --> Fixes #13424 As of now this PR (Work in Progress), will try to implement (partially) on algorithms namely : [Schedule_Job](https://w3c.github.io/ServiceWorker/#schedule-job-algorithm), [Run_Job](https://w3c.github.io/ServiceWorker/#run-job-algorithm), [Register_Job](https://w3c.github.io/ServiceWorker/#register-algorithm). An issue that needs to be addressed: Resolving the promise value after queueing it as a `dom_manipulation_task` by wrapping it in a runnable `RunJobHandler` (which holds a `TrustedPromise`) and trying to call `resolve_native` results in a crash. [stack trace](http://paste.ofcode.org/zdjJ9npBgX6JsyWQkJjnYk) @jdm I am not sure what's causing the crash ? --- <!-- 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: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/13574) <!-- Reviewable:end -->
|
💔 Test failed - mac-rel-wpt2 |
Ah, so it took off |
0621549 to
f43af21
Compare
|
@jdm Ah, yes. So in the wpt tests, https://github.com/servo/servo/blob/master/tests/wpt/mozilla/tests/mozilla/service-workers/service-worker-registration.html#L18 is registered before https://github.com/servo/servo/blob/master/tests/wpt/mozilla/tests/mozilla/service-workers/service-worker-registration.html#L47 . And both have the same scope url (being an empty string). So the update algorithm just returns us, previously registered one. |
f43af21 to
114c491
Compare
|
@bors-servo: r+ |
|
📌 Commit 114c491 has been approved by |
Implement job queue for ServiceWorkerRegistration <!-- Please describe your changes on the following line: --> Fixes #13424 As of now this PR (Work in Progress), will try to implement (partially) on algorithms namely : [Schedule_Job](https://w3c.github.io/ServiceWorker/#schedule-job-algorithm), [Run_Job](https://w3c.github.io/ServiceWorker/#run-job-algorithm), [Register_Job](https://w3c.github.io/ServiceWorker/#register-algorithm). An issue that needs to be addressed: Resolving the promise value after queueing it as a `dom_manipulation_task` by wrapping it in a runnable `RunJobHandler` (which holds a `TrustedPromise`) and trying to call `resolve_native` results in a crash. [stack trace](http://paste.ofcode.org/zdjJ9npBgX6JsyWQkJjnYk) @jdm I am not sure what's causing the crash ? --- <!-- 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: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/13574) <!-- Reviewable:end -->
|
☀️ Test successful - arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-dev |
| // https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy | ||
| pub fn is_origin_trustworthy(url: &ServoUrl) -> bool { | ||
| // Step 3 | ||
| if url.scheme() == "http" || url.scheme() == "wss" { |
There was a problem hiding this comment.
shouldn't this be https instead of http?
There was a problem hiding this comment.
Yes, except that we don't support HTTPS in our automated tests yet. Certainly a FIXME comment here would be an improvement.
There was a problem hiding this comment.
Noted. I'll add that comment
Update checking origin trustworthy align to spec While reading the [spec of ` Is origin potentially trustworthy? `](https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy), I found our second step is wrong; then, I found Josh said we didn't check it with `https` because we didn't support https in tests yet (#13574 (comment)). IIRC, we've supported https wpt tests now so it might be fine to change it to align with spec. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] There are tests for these changes OR - [ ] 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. -->
Update checking origin trustworthy align to spec While reading the [spec of ` Is origin potentially trustworthy? `](https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy), I found our second step is wrong; then, I found Josh said we didn't check it with `https` because we didn't support https in tests yet (#13574 (comment)). IIRC, we've supported https wpt tests now so it might be fine to change it to align with spec. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] There are tests for these changes OR - [ ] 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. -->

Fixes #13424
As of now this PR (Work in Progress), will try to implement (partially) on algorithms namely : Schedule_Job, Run_Job, Register_Job.
An issue that needs to be addressed:
Resolving the promise value after queueing it as a
dom_manipulation_taskby wrapping it in a runnableRunJobHandler(which holds aTrustedPromise) and trying to callresolve_nativeresults in a crash. stack trace@jdm I am not sure what's causing the crash ?
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is