aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/serviceworkerglobalscope.rs
Commit message (Collapse)AuthorAgeFilesLines
* Strict import formatting (grouping and granularity) (#30325)Samson2023-09-111-20/+22
| | | | | * strict imports formatting * Reformat all imports
* fix: Enter realm before dispatch activate (#30271)Li-Hsuan Hsieh2023-09-011-0/+1
| | | * ref: https://github.com/servo/servo/issues/30141
* No tracing of nop traceable fields (#29926)Samson2023-08-041-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add `no_trace` option to JSTraceable derive * NoTrace wrapper * Port some types to no_trace schematics * Fixing my unsafe mistakes (not tracing traceables) * Add docs & safety guards for no_trace Safety guards (trait shenanigans) guarantees safety usage of `no_trace` * Port canvas_traits to no_trace * Port servo_media to no_trace * Port net_traits to no_trace * Port style to no_trace * Port webgpu to no_trace * Port script_traits to no_trace * Port canvas_traits, devtools_traits, embedder_traits, profile_traits to no_trace * unrooted_must_root lint in seperate file * Add trace_in_no_trace_lint as script_plugin * Composable types in must_not_have_traceable * Introduced HashMapTracedValues wrapper * `HashMap<NoTrace<K>,V>`->`HashMapTracedValues<K,V>` * Port rest of servo's types to no_trace * Port html5ever, euclid, mime and http to no_trace * Port remaining externals to no_trace * Port webxr and Arc<Mutex<_>> * Fix spelling in notrace doc
* Fix race condition and other issues related to Worker destruction. (#30066)Mukilan Thiyagarajan2023-08-031-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix race condition in Worker destruction During shutdown, the main script thread calls JS_RequestInterruptCallback(cx) for each worker thread it owns where cx is the JSContext* created for that worker. Although JS_RequestInterruptCallback is safe to call from threads other than the worker thread, it is possible the JSContext* has already been destroyed For example, as noted in #30022, since the main thread sets the worker's `closing` flag to true to signal termination before it calls JS_RequestInterruptCallback, we can have a race condition where the worker exits its event loop when `closing` flags is set and then it (worker thread) destroys its own JSContext and JSRuntime. When the main thread resumes, it will call JS_RequestInterruptCallback for the worker's context, leading to a use-after-free bug. This patch solves this issue by improving the existing `ContextForRequestInterrupt` abstraction used for sharing the Worker's associated JSContext* with the parent script thread. Instead of simply wrapping a plain `*mut JSContext`, we now wrap the `*mut JSContext` in a nullable mutex i.e Mutex<Option<*mut JSContext>> The mutex lock needs to be held by the parent thread when it calls JS_RequestInterruptCallback. Similary, before the worker destroys its JSContext, it locks and sets the Option to None, signaling that the JSContext can no longer be used for interrupting the worker. This patch also fixes the issue in #30052 by enforcing the use of ContextForRequestInterrupt abstraction which ensures the correct JSContext is used by the main thread when Worker.terminate is called. Fixes #30022, #30052 * Fix Worker.importScripts to handle termination Fixing #30052 uncovered this issue in the implementation of `importScripts` method. After the fix for #30052, the WPT test `/workers/Worker-terminate-forever-during-evaluation.html` started to crash because when evaluation doesn't succeed `importScripts` always returns Error::JSFailed code to the caller, which indicates that there is a Dom/JS exception to be thrown. However, this is not true when the script is terminated, which causes the generated binding layer for 'importScript` to fail the assertion that there is a pending exception. This patch makes `importScripts` work similar to the [logic that evaluates the top-level script][1] of the Worker - it simply prints `evaluate_script failed - (terminated)' if the worker is terminating [1]: https://github.com/servo/servo/blob/3fea90a231a94338d67712398fe3d2ba9d402211/components/script/dom/workerglobalscope.rs#L434
* feat: shorten thread namesyvt2021-07-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Linux kernel imposes a 15-byte limit on thread names[1]. This means information that does not fit in this limit, e.g., the pipeline ID of layout and script threads, is lost in a debugger and profiler (see the first column of the table below). This commit shortens the thread names used in Servo to maximize the amount of information conveyed. It also rectifies some inconsistencies in the names. | Before | After | |-------------------|-------------------| | `BluetoothThread` | `Bluetooth` | | `CanvasThread` | `Canvas` | | `display alert d` | `AlertDialog` | | `FontCacheThread` | `FontCache` | | `GLPlayerThread` | `GLPlayer` | | `HTML Parser` | `Parse:www.examp` | | `LayoutThread Pi` | `Layout(1,1)` | | `Memory profiler` | `MemoryProfiler` | | `Memory profiler` | `MemoryProfTimer` | | `OfflineAudioCon` | `OfflineACResolv` | | `PullTimelineMar` | `PullTimelineDat` | | `ScriptThread Pi` | `Script(1,1)` | | `WebWorker for h` | `WW:www.example.` | | `ServiceWorker f` | `SW:www.example.` | | `ServiceWorkerMa` | `SvcWorkerManage` | | `Time profiler t` | `TimeProfTimer` | | `Time profiler` | `TimeProfiler` | | `WebGL thread` | `WebGL` | | `Choose a device` | `DevicePicker` | | `Pick a file` | `FilePicker` | | `Pick files` | `FilePicker` | [1]: https://stackoverflow.com/questions/5026531/thread-name-longer-than-15-chars
* doc(script): update comments in `run_worker_scope` and `run_serviceworker_scope`yvt2021-07-131-2/+2
| | | | | | | The step numbers changed over time. Note that service workers and non-service workers use different steps defined in different specifications.
* Use ExtendableMessageEvent for messageerror in service workersKyle Nosar2020-07-301-2/+1
|
* ensure clean shutdown of all threads running JSGregory Terzian2020-06-301-2/+12
|
* Make url for "client" referrer mandatoryMatthias Deiml2020-06-171-13/+14
|
* turn serviceworker event-loop back onGregory Terzian2020-06-031-3/+1
|
* add a control chan to workers, use to signal shutdownGregory Terzian2020-06-031-14/+41
|
* add mechanism to join on service- and dedicated-worker threadsGregory Terzian2020-05-291-3/+3
|
* serviceworker: turn-off event-loop, don't assume current scope, clear ↵Gregory Terzian2020-05-211-36/+27
| | | | runtime on shutdown
* Share single gpu_id_hub among all threads in a processKunal Mohan2020-05-151-0/+4
|
* Always pass InRealm to GlobalScope::from_context to avoid getting null globalCYBAI2020-02-161-3/+5
|
* rename compartment to realmKunal Mohan2020-01-241-1/+1
|
* Remove Optional pipeline_idWarren Fisher2019-12-191-1/+1
|
* devtools: save and send cached messagesPaul Rouget2019-12-061-3/+0
|
* Auto merge of #24758 - gterzian:impl_timer_task_source, r=noxbors-servo2019-11-261-47/+40
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement timer-task-source, time-out service worker <!-- Please describe your changes on the following line: --> Implements the timer task-source, and folds the IPC glue-code into a single route set by the globalscope. Also switches service worker to using a dedicated "time-out" mechanism, which previously relied on the timer mechanism(and I think didn't actually implement script timers). --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #24747 (GitHub issue number if applicable) <!-- Either: --> - [ ] 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. -->
| * impl timer-task-source, dedicated time-out mechanism for service-workerGregory Terzian2019-11-191-47/+40
| |
* | Bind runnable dispatching in script_runtimeAkash-Pateria2019-11-191-1/+1
|/
* continue messageport, transferable, postmessage optionsGregory Terzian2019-10-191-2/+13
|
* begin messageport, transferable objects, implKeith Yeung2019-10-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Accept transfer argument for StructuredCloneData::write Allow structured clone reads to return a boolean Add Transferable trait Add basic skeletons to MessagePort Implement transfer and transfer-receiving steps on MessagePort Use transfer and transfer_receive in StructuredClone callbacks Implement MessageChannel Freeze the array object for the MessageEvent ports attribute Implement transfer argument on window.postMessage Use ReentrantMutex instead for MessagePortInternal Accept origin as a parameter in dispatch_jsval Fix BorrowMut crash with pending_port_message Detach port on closure and check for detached during transfer Enable webmessaging tests fix webidl fix
* Modify *::get_cx methods to return a safe JSContext instead of a raw onemarmeladema2019-07-241-2/+2
|
* Wrap(Global)Method now takes a SafeJSContext instead of a JSContextmarmeladema2019-07-241-2/+4
| | | | as first argument.
* Create a helper API for entering a DOM object's compartmentKamil Niski2019-06-291-3/+3
| | | | | | Revert some unnecessary changes Fix fmt errors
* Auto merge of #23351 - CYBAI:fix-modes, r=noxbors-servo2019-05-161-1/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix modes for fetching classic worker script and introduce parser metadata for request While reading [the spec](https://html.spec.whatwg.org/multipage/#fetch-a-classic-worker-script) for `fetch a classic worker script`, I found the `mode` and `credential-mode` are opposite to the spec. So, the first commit will fix it. Also, I found there's a `parser metadata` for `request` so I tried to introduce it in this PR as well. For WPT, I found there's a `/workers/constructors/Worker/same-origin.html` which was disabled in #3180. We pass most of the tests now. --- - [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) - [x] There are tests for these changes <!-- 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/23351) <!-- Reviewable:end -->
| * Introduce parser metadata for requestCYBAI2019-05-111-1/+2
| |
* | Auto merge of #23309 - CYBAI:update-workers, r=noxbors-servo2019-05-111-0/+3
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support WorkerOptions for Worker I'd like to start working on updating SW related codes and I found it will have some algorithms related to module workers. And I found parts of the spec update is related to [fetch a module worker script graph](https://html.spec.whatwg.org/multipage/#fetch-a-module-worker-script-tree), maybe it's worth being a separate PR? --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix part of #23308 - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- 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/23309) <!-- Reviewable:end -->
| * | Update Worker webidl to support WorkerOptionsCYBAI2019-05-111-0/+3
| |/
* / Update to SpiderMonkey 66.Josh Matthews2019-05-101-3/+2
|/
* Create resource timing entry for sync network fetchpylbrecht2019-05-081-11/+15
|
* set referrer in window.load_urlRussell Cousineau2019-04-191-2/+4
| | | | | | | | - this conforms to follow-hyperlinks spec step 13 - this conforms to window-open spec step 14.3 - replace uses of `referrer_url` with `referrer` - in Request class, change "no-referrer" to "" - set websocket fetch referrer to "no-referrer"
* Implementing the builder pattern for RequestInitLucas Fantacuci2019-04-101-12/+9
|
* #8539 Config preferences backend restructurePeter Hall2019-03-201-5/+2
|
* in BC event-loop, only run tasks related to fully-active documentsGregory Terzian2019-03-061-1/+13
|
* Reintroduce parent runtimes for worker threads.Josh Matthews2019-01-151-1/+1
|
* Update MPL license to https (part 3)Jan Andre Ikenmeyer2018-11-191-1/+1
|
* Update crossbeam-channel to 0.3Bastien Orivel2018-11-181-4/+6
|
* Update webidl of ServiceWorkerGlobalScopemandreyel2018-11-131-1/+4
|
* `cargo fix --edition-idioms`Simon Sapin2018-11-081-2/+2
|
* Reorder importsPyfisch2018-11-061-5/+7
|
* Sort `use` statementsSimon Sapin2018-11-061-4/+4
|
* `cargo fix --edition`Simon Sapin2018-11-061-20/+20
|
* Update to new ServiceWorker spec linkCYBAI2018-11-041-1/+1
|
* Format script componentchansuke2018-09-191-131/+182
|
* Replace mpsc with crossbeam/servo channel, update ipc-channelSimon Sapin2018-09-121-3/+2
| | | | Co-authored-by: Gregory Terzian <gterzian@users.noreply.github.com>
* Add the TaskSourceName to CommonScriptMsg::TaskAgustin Chiappe Berrini2018-09-041-12/+12
| | | | Update QueuedTaskConversion and the TaskQueue to use it
* introduce a generic worker event-loopGregory Terzian2018-08-311-64/+41
|
* introduce task-queues, and throttling the performance-timeline task-source, ↵Gregory Terzian2018-08-311-27/+103
| | | | | | in script and worker threads. queue