mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
parent
59cf735f85
commit
60142f87e2
50 changed files with 132 additions and 128 deletions
|
@ -284,7 +284,7 @@ impl<'a> GlobalRef<'a> {
|
|||
pub fn report_an_error(&self, error_info: ErrorInfo, value: HandleValue) {
|
||||
match *self {
|
||||
GlobalRef::Window(ref window) => window.report_an_error(error_info, value),
|
||||
GlobalRef::Worker(_) => (),
|
||||
GlobalRef::Worker(ref worker) => worker.report_an_error(error_info, value),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,15 +10,18 @@ use dom::bindings::cell::DOMRefCell;
|
|||
use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding;
|
||||
use dom::bindings::codegen::Bindings::DedicatedWorkerGlobalScopeBinding::DedicatedWorkerGlobalScopeMethods;
|
||||
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||
use dom::bindings::error::ErrorResult;
|
||||
use dom::bindings::error::{ErrorInfo, ErrorResult};
|
||||
use dom::bindings::global::{GlobalRef, global_root_from_context};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::{Root, RootCollection};
|
||||
use dom::bindings::reflector::Reflectable;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::bindings::structuredclone::StructuredCloneData;
|
||||
use dom::errorevent::ErrorEvent;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::messageevent::MessageEvent;
|
||||
use dom::worker::{TrustedWorkerAddress, WorkerMessageHandler};
|
||||
use dom::worker::{TrustedWorkerAddress, WorkerErrorHandler, WorkerMessageHandler};
|
||||
use dom::workerglobalscope::WorkerGlobalScope;
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use ipc_channel::router::ROUTER;
|
||||
|
@ -32,6 +35,7 @@ use rand::random;
|
|||
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, StackRootTLS, get_reports, new_rt_and_cx};
|
||||
use script_runtime::ScriptThreadEventCategory::WorkerEvent;
|
||||
use script_traits::{TimerEvent, TimerSource, WorkerGlobalScopeInit, WorkerScriptLoadOrigin};
|
||||
use std::cell::Cell;
|
||||
use std::mem::replace;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::atomic::AtomicBool;
|
||||
|
@ -88,6 +92,8 @@ pub struct DedicatedWorkerGlobalScope {
|
|||
#[ignore_heap_size_of = "Can't measure trait objects"]
|
||||
/// Sender to the parent thread.
|
||||
parent_sender: Box<ScriptChan + Send>,
|
||||
/// https://html.spec.whatwg.org/multipage/#in-error-reporting-mode
|
||||
in_error_reporting_mode: Cell<bool>
|
||||
}
|
||||
|
||||
impl DedicatedWorkerGlobalScope {
|
||||
|
@ -116,6 +122,7 @@ impl DedicatedWorkerGlobalScope {
|
|||
timer_event_port: timer_event_port,
|
||||
parent_sender: parent_sender,
|
||||
worker: DOMRefCell::new(None),
|
||||
in_error_reporting_mode: Cell::new(false),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -339,6 +346,41 @@ impl DedicatedWorkerGlobalScope {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#report-the-error
|
||||
pub fn report_an_error(&self, error_info: ErrorInfo, value: HandleValue) {
|
||||
// Step 1.
|
||||
if self.in_error_reporting_mode.get() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 2.
|
||||
self.in_error_reporting_mode.set(true);
|
||||
|
||||
// Steps 3-12.
|
||||
let event = ErrorEvent::new(GlobalRef::Worker(self.upcast()),
|
||||
atom!("error"),
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::Cancelable,
|
||||
error_info.message.as_str().into(),
|
||||
error_info.filename.as_str().into(),
|
||||
error_info.lineno,
|
||||
error_info.column,
|
||||
value);
|
||||
|
||||
// Step 13.
|
||||
let handled = !event.upcast::<Event>().fire(self.upcast::<EventTarget>());
|
||||
if !handled {
|
||||
let worker = self.worker.borrow().as_ref().unwrap().clone();
|
||||
// TODO: Should use the DOM manipulation task source.
|
||||
self.parent_sender
|
||||
.send(CommonScriptMsg::RunnableMsg(WorkerEvent,
|
||||
box WorkerErrorHandler::new(worker, error_info)))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
self.in_error_reporting_mode.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
|
|
@ -9,7 +9,7 @@ interface WorkerGlobalScope : EventTarget {
|
|||
readonly attribute WorkerLocation location;
|
||||
|
||||
//void close();
|
||||
// attribute OnErrorEventHandler onerror;
|
||||
attribute OnErrorEventHandler onerror;
|
||||
// attribute EventHandler onlanguagechange;
|
||||
// attribute EventHandler onoffline;
|
||||
// attribute EventHandler ononline;
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::abstractworker::WorkerScriptMsg;
|
|||
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||
use dom::bindings::codegen::Bindings::WorkerBinding;
|
||||
use dom::bindings::codegen::Bindings::WorkerBinding::WorkerMethods;
|
||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||
use dom::bindings::error::{Error, ErrorResult, Fallible, ErrorInfo};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::Root;
|
||||
|
@ -17,11 +17,13 @@ use dom::bindings::reflector::{Reflectable, reflect_dom_object};
|
|||
use dom::bindings::str::DOMString;
|
||||
use dom::bindings::structuredclone::StructuredCloneData;
|
||||
use dom::dedicatedworkerglobalscope::DedicatedWorkerGlobalScope;
|
||||
use dom::errorevent::ErrorEvent;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::messageevent::MessageEvent;
|
||||
use dom::workerglobalscope::prepare_workerscope_init;
|
||||
use ipc_channel::ipc;
|
||||
use js::jsapi::{HandleValue, JSAutoCompartment, JSContext};
|
||||
use js::jsapi::{HandleValue, JSAutoCompartment, JSContext, NullHandleValue};
|
||||
use js::jsval::UndefinedValue;
|
||||
use script_thread::Runnable;
|
||||
use script_traits::WorkerScriptLoadOrigin;
|
||||
|
@ -137,6 +139,26 @@ impl Worker {
|
|||
let worker = address.root();
|
||||
worker.upcast().fire_simple_event("error");
|
||||
}
|
||||
|
||||
fn dispatch_error(&self, error_info: ErrorInfo) {
|
||||
let global = self.global();
|
||||
let event = ErrorEvent::new(global.r(),
|
||||
atom!("error"),
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::Cancelable,
|
||||
error_info.message.as_str().into(),
|
||||
error_info.filename.as_str().into(),
|
||||
error_info.lineno,
|
||||
error_info.column,
|
||||
NullHandleValue);
|
||||
|
||||
let handled = !event.upcast::<Event>().fire(self.upcast::<EventTarget>());
|
||||
if handled {
|
||||
return;
|
||||
}
|
||||
|
||||
global.r().report_an_error(error_info, NullHandleValue);
|
||||
}
|
||||
}
|
||||
|
||||
impl WorkerMethods for Worker {
|
||||
|
@ -202,3 +224,24 @@ impl Runnable for SimpleWorkerErrorHandler<Worker> {
|
|||
Worker::dispatch_simple_error(this.addr);
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WorkerErrorHandler {
|
||||
address: Trusted<Worker>,
|
||||
error_info: ErrorInfo,
|
||||
}
|
||||
|
||||
impl WorkerErrorHandler {
|
||||
pub fn new(address: Trusted<Worker>, error_info: ErrorInfo) -> WorkerErrorHandler {
|
||||
WorkerErrorHandler {
|
||||
address: address,
|
||||
error_info: error_info,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Runnable for WorkerErrorHandler {
|
||||
fn handler(self: Box<Self>) {
|
||||
let this = *self;
|
||||
this.address.root().dispatch_error(this.error_info);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId};
|
||||
use dom::bindings::codegen::Bindings::EventHandlerBinding::OnErrorEventHandlerNonNull;
|
||||
use dom::bindings::codegen::Bindings::FunctionBinding::Function;
|
||||
use dom::bindings::codegen::Bindings::WorkerGlobalScopeBinding::WorkerGlobalScopeMethods;
|
||||
use dom::bindings::error::{Error, ErrorResult, Fallible, report_pending_exception};
|
||||
use dom::bindings::error::{Error, ErrorResult, Fallible, report_pending_exception, ErrorInfo};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||
|
@ -248,6 +249,9 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
|
|||
})
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#handler-workerglobalscope-onerror
|
||||
error_event_handler!(error, GetOnerror, SetOnerror);
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-workerglobalscope-importscripts
|
||||
fn ImportScripts(&self, url_strings: Vec<DOMString>) -> ErrorResult {
|
||||
let mut urls = Vec::with_capacity(url_strings.len());
|
||||
|
@ -451,4 +455,11 @@ impl WorkerGlobalScope {
|
|||
closing.store(true, Ordering::SeqCst);
|
||||
}
|
||||
}
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#report-the-error
|
||||
pub fn report_an_error(&self, error_info: ErrorInfo, value: HandleValue) {
|
||||
self.downcast::<DedicatedWorkerGlobalScope>()
|
||||
.expect("Should implement report_an_error for this worker")
|
||||
.report_an_error(error_info, value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[digest.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
[SHA-1 with empty source data]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[aes_cbc.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[aes_ctr.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[aes_gcm.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[rsa.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[failures.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[failures_AES-CBC.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[failures_AES-CTR.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[failures_AES-GCM.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[failures_AES-KW.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[failures_ECDH.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[failures_ECDSA.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[failures_HMAC.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[failures_RSA-OAEP.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[failures_RSA-PSS.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[failures_RSASSA-PKCS1-v1_5.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[successes.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[successes_AES-CBC.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[successes_AES-CTR.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[successes_AES-GCM.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[successes_AES-KW.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[successes_ECDH.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[successes_ECDSA.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[successes_HMAC.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[successes_RSA-OAEP.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[successes_RSA-PSS.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[successes_RSASSA-PKCS1-v1_5.worker]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
[WorkerGlobalScope_ErrorEvent_colno.htm]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[ WorkerGlobalScope onerror event handler argument: col ]
|
||||
expected: TIMEOUT
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
[WorkerGlobalScope_ErrorEvent_filename.htm]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[ WorkerGlobalScope onerror event handler argument: location ]
|
||||
expected: TIMEOUT
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
[WorkerGlobalScope_ErrorEvent_lineno.htm]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[ WorkerGlobalScope onerror event handler argument: line ]
|
||||
expected: TIMEOUT
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
[WorkerGlobalScope_ErrorEvent_message.htm]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[ WorkerGlobalScope onerror event handler argument: message ]
|
||||
expected: TIMEOUT
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
[Worker_ErrorEvent_bubbles_cancelable.htm]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[ErrorEvent on worker doesn't bubble and is cancelable]
|
||||
expected: TIMEOUT
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
[Worker_ErrorEvent_filename.htm]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[ AbstractWorker ErrorEvent.filename ]
|
||||
expected: TIMEOUT
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
[Worker_ErrorEvent_lineno.htm]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[ AbstractWorker ErrorEvent.lineno ]
|
||||
expected: TIMEOUT
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
[Worker_ErrorEvent_message.htm]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[ AbstractWorker ErrorEvent.message ]
|
||||
expected: TIMEOUT
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
[Worker_ErrorEvent_type.htm]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[ AbstractWorker ErrorEvent.type ]
|
||||
expected: TIMEOUT
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
[sharedworker.html]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[Base URL in workers: new SharedWorker()]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
[AbstractWorker.onerror.html]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[AbstractWorker.onerror]
|
||||
expected: TIMEOUT
|
||||
|
|
@ -21,9 +21,6 @@
|
|||
[DedicatedWorkerGlobalScope interface: attribute onmessage]
|
||||
expected: FAIL
|
||||
|
||||
[WorkerGlobalScope interface: self must inherit property "onerror" with the proper type (3)]
|
||||
expected: FAIL
|
||||
|
||||
[WorkerGlobalScope interface: self must inherit property "onlanguagechange" with the proper type (4)]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
[exception-in-onerror.html]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[onerror, "not handled" with an error in the onerror function]
|
||||
expected: TIMEOUT
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
[handled.html]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[onerror, "handled"]
|
||||
expected: TIMEOUT
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
[not-handled.html]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[onerror, "not handled"]
|
||||
expected: TIMEOUT
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
[propagate-to-window-onerror.html]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[onerror, "not handled" with only window.onerror defined]
|
||||
expected: TIMEOUT
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[005.html]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
expected: ERROR
|
||||
[dedicated worker in shared worker in dedicated worker]
|
||||
expected: TIMEOUT
|
||||
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
[003.html]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[worker]
|
||||
expected: TIMEOUT
|
||||
|
||||
[shared]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue