mirror of
https://github.com/servo/servo.git
synced 2025-06-10 09:33:13 +00:00
Auto merge of #12910 - creativcoder:swsender, r=jdm
Implement postMessage for ServiceWorkers <!-- Please describe your changes on the following line: --> Fixes #12773 r? @jdm Changes: * Implements `postMessage` on `ServiceWorker` object. * Removes unused channels from sw and their scopes. * Fixes a crash when calling `scope.script_chan()` in sw-scopes event handling. --- <!-- 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 - [X] These changes fix #12773 <!-- Either: --> - [X] There are tests for these changes at `tests/html/service-worker` <!-- 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/12910) <!-- Reviewable:end -->
This commit is contained in:
commit
0ec4ea4ee1
19 changed files with 256 additions and 118 deletions
|
@ -136,6 +136,9 @@ pub enum ScriptMsg {
|
|||
LogEntry(Option<PipelineId>, Option<String>, LogEntry),
|
||||
/// Notifies the constellation that this pipeline has exited.
|
||||
PipelineExited(PipelineId),
|
||||
/// Send messages from postMessage calls from serviceworker
|
||||
/// to constellation for storing in service worker manager
|
||||
ForwardDOMMessage(DOMMessage, Url),
|
||||
/// Store the data required to activate a service worker for the given scope
|
||||
RegisterServiceWorker(ScopeThings, Url),
|
||||
/// Requests that the compositor shut down.
|
||||
|
@ -159,6 +162,10 @@ pub struct ScopeThings {
|
|||
pub worker_id: WorkerId,
|
||||
}
|
||||
|
||||
/// Message that gets passed to service worker scope on postMessage
|
||||
#[derive(Deserialize, Serialize, Debug, Clone)]
|
||||
pub struct DOMMessage(pub Vec<u8>);
|
||||
|
||||
/// Channels to allow service worker manager to communicate with constellation and resource thread
|
||||
pub struct SWManagerSenders {
|
||||
/// sender for communicating with constellation
|
||||
|
@ -174,6 +181,8 @@ pub enum ServiceWorkerMsg {
|
|||
RegisterServiceWorker(ScopeThings, Url),
|
||||
/// Timeout message sent by active service workers
|
||||
Timeout(Url),
|
||||
/// Message sent by constellation to forward to a running service worker
|
||||
ForwardDOMMessage(DOMMessage, Url),
|
||||
/// Exit the service worker manager
|
||||
Exit,
|
||||
}
|
||||
|
@ -182,5 +191,6 @@ pub enum ServiceWorkerMsg {
|
|||
#[derive(Deserialize, Serialize)]
|
||||
pub enum SWManagerMsg {
|
||||
/// Provide the constellation with a means of communicating with the Service Worker Manager
|
||||
OwnSender(IpcSender<ServiceWorkerMsg>),
|
||||
OwnSender(IpcSender<ServiceWorkerMsg>)
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue