mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Use ExtendableMessageEvent for messageerror in service workers
This commit is contained in:
parent
b1bd409047
commit
95ddcf5d4d
3 changed files with 27 additions and 8 deletions
|
@ -28,11 +28,16 @@ use servo_atoms::Atom;
|
|||
#[dom_struct]
|
||||
#[allow(non_snake_case)]
|
||||
pub struct ExtendableMessageEvent {
|
||||
/// https://w3c.github.io/ServiceWorker/#extendableevent
|
||||
event: ExtendableEvent,
|
||||
/// https://w3c.github.io/ServiceWorker/#dom-extendablemessageevent-data
|
||||
#[ignore_malloc_size_of = "mozjs"]
|
||||
data: Heap<JSVal>,
|
||||
/// <https://w3c.github.io/ServiceWorker/#extendablemessage-event-origin>
|
||||
origin: DOMString,
|
||||
/// https://w3c.github.io/ServiceWorker/#dom-extendablemessageevent-lasteventid
|
||||
lastEventId: DOMString,
|
||||
/// https://w3c.github.io/ServiceWorker/#dom-extendablemessageevent-ports
|
||||
ports: Vec<Dom<MessagePort>>,
|
||||
#[ignore_malloc_size_of = "mozjs"]
|
||||
frozen_ports: DomRefCell<Option<Heap<JSVal>>>,
|
||||
|
@ -95,8 +100,8 @@ impl ExtendableMessageEvent {
|
|||
init.parent.parent.bubbles,
|
||||
init.parent.parent.cancelable,
|
||||
init.data.handle(),
|
||||
init.origin.clone().unwrap(),
|
||||
init.lastEventId.clone().unwrap(),
|
||||
init.origin.clone(),
|
||||
init.lastEventId.clone(),
|
||||
vec![],
|
||||
);
|
||||
Ok(ev)
|
||||
|
@ -123,6 +128,21 @@ impl ExtendableMessageEvent {
|
|||
);
|
||||
Extendablemessageevent.upcast::<Event>().fire(target);
|
||||
}
|
||||
|
||||
pub fn dispatch_error(target: &EventTarget, scope: &GlobalScope) {
|
||||
let init = ExtendableMessageEventBinding::ExtendableMessageEventInit::empty();
|
||||
let ExtendableMsgEvent = ExtendableMessageEvent::new(
|
||||
scope,
|
||||
atom!("messageerror"),
|
||||
init.parent.parent.bubbles,
|
||||
init.parent.parent.cancelable,
|
||||
init.data.handle(),
|
||||
init.origin.clone(),
|
||||
init.lastEventId.clone(),
|
||||
init.ports.clone(),
|
||||
);
|
||||
ExtendableMsgEvent.upcast::<Event>().fire(target);
|
||||
}
|
||||
}
|
||||
|
||||
impl ExtendableMessageEventMethods for ExtendableMessageEvent {
|
||||
|
|
|
@ -19,7 +19,6 @@ use crate::dom::extendableevent::ExtendableEvent;
|
|||
use crate::dom::extendablemessageevent::ExtendableMessageEvent;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::identityhub::Identities;
|
||||
use crate::dom::messageevent::MessageEvent;
|
||||
use crate::dom::worker::TrustedWorkerAddress;
|
||||
use crate::dom::workerglobalscope::WorkerGlobalScope;
|
||||
use crate::fetch::load_whole_resource;
|
||||
|
@ -446,7 +445,7 @@ impl ServiceWorkerGlobalScope {
|
|||
ports,
|
||||
);
|
||||
} else {
|
||||
MessageEvent::dispatch_error(target, scope.upcast());
|
||||
ExtendableMessageEvent::dispatch_error(target, scope.upcast());
|
||||
}
|
||||
},
|
||||
CommonWorker(WorkerScriptMsg::Common(msg)) => {
|
||||
|
|
|
@ -16,9 +16,9 @@ interface ExtendableMessageEvent : ExtendableEvent {
|
|||
};
|
||||
|
||||
dictionary ExtendableMessageEventInit : ExtendableEventInit {
|
||||
any data;
|
||||
DOMString origin;
|
||||
DOMString lastEventId;
|
||||
any data = null;
|
||||
DOMString origin = "";
|
||||
DOMString lastEventId = "";
|
||||
// (Client or ServiceWorker /*or MessagePort*/)? source;
|
||||
// sequence<MessagePort>? ports;
|
||||
sequence<MessagePort> ports = [];
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue