Repository navigation
SharedWorker: Implement constructor, port wiring, and connect event delivery - #44761
Conversation
7173fe6 to
13df311
Compare
|
🔨 Triggering try run (#25460135341) for Linux (WPT) |
|
Test results for linux-wpt from try job (#25460135341): Flaky unexpected result (62)
Stable unexpected results that are known to be intermittent (13)
|
|
✨ Try run (#25460135341) succeeded. |
…elivery Signed-off-by: Taym Haddadi <[email protected]>
Signed-off-by: Taym Haddadi <[email protected]>
Signed-off-by: Taym Haddadi <[email protected]>
Signed-off-by: Taym Haddadi <[email protected]>
Signed-off-by: Taym Haddadi <[email protected]>
b19b861 to
b6d159d
Compare
TimvdLippe
left a comment
There was a problem hiding this comment.
WPT setup LGTM, thanks for cleaning that up. The actual implementation I will defer to other reviewers, as I am not yet familiar with that. Glad to see so many tests starting to pass 🎉
gterzian
left a comment
There was a problem hiding this comment.
LGTM overall as a first step, with some comments mostly about documentation.
| } | ||
| }, | ||
| SharedWorkerScriptMsg::CommonWorker(WorkerScriptMsg::DOMMessage(_)) => { | ||
| unreachable!("SharedWorkerGlobalScope does not support direct DOMMessage dispatch") |
There was a problem hiding this comment.
Is this because of the message port being used for those, right? Good to clarify.
Also debug_assert probably better choice than unreachable.
| let credentials = worker_options.parent.credentials.convert(); | ||
|
|
||
| // Step 3. Let outsideSettings be this's relevant settings object. | ||
| // (outsideSettings is `global` throughout.) |
There was a problem hiding this comment.
Note bad to keep it as a note.
| debugger_global: &DebuggerGlobalScope, | ||
| ) -> SharedWorkerGlobalScope { | ||
| SharedWorkerGlobalScope { | ||
| // Step 9. Set worker global scope's type to options["type"]. |
There was a problem hiding this comment.
this doesn't seem to belong here, it seems to be step 10.3 of run a worker.
| own_sender: Sender<SharedWorkerScriptMsg>, | ||
| worker: DomRefCell<Option<TrustedSharedWorkerAddress>>, | ||
| parent_event_loop_sender: ScriptEventLoopSender, | ||
| pending_connects: DomRefCell<Vec<Dom<MessagePort>>>, |
There was a problem hiding this comment.
There should be only ever one pending no?
| if let Some(dedicated) = self.downcast::<DedicatedWorkerGlobalScope>() { | ||
| dedicated.fire_queued_messages(cx); | ||
| } else if let Some(shared) = self.downcast::<SharedWorkerGlobalScope>() { | ||
| shared.enable_outside_port_message_queue(); |
| worker.upcast().fire_event(cx, atom!("error")); | ||
| } | ||
|
|
||
| pub(crate) fn enable_outside_port_message_queue( |
There was a problem hiding this comment.
Step 11 of onComplete of run a worker.
| .expect("Sending to parent failed"); | ||
| } | ||
|
|
||
| pub(crate) fn enable_outside_port_message_queue(&self) { |
| ) | ||
| } | ||
|
|
||
| pub(crate) fn forward_simple_error_at_worker(&self) { |
| global.font_context().cloned(), | ||
| ); | ||
|
|
||
| sender |
There was a problem hiding this comment.
Good to clarify this is kind of the onComplete hook, except that it could be received by the worker too early, in which case the effect is queued.
| // TODO Step 9. Let outsideStorageKey be the result of running obtain a storage key | ||
| // for non-storage purposes given outsideSettings. | ||
| // Step 11. Enqueue the following steps to the shared worker manager. | ||
| // TODO Steps 12-16. |
There was a problem hiding this comment.
Good to clarify that the worker now essentially works as a dedicated worker.
Signed-off-by: Taym Haddadi <[email protected]>
this PR implements the SharedWorker constructor, creates and exposes port, starts a SharedWorkerGlobalScope, and delivers connections to the worker through connect events using MessageEvent with the worker port in event.ports[0].
Testing: more SharedWorker WPT test are passing now.
part of #7458