Implement error reporting for workers.

Fixes #3311.
Fixes #13158.
This commit is contained in:
Ms2ger 2016-09-05 18:02:14 +02:00
parent 59cf735f85
commit 60142f87e2
50 changed files with 132 additions and 128 deletions

View file

@ -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);
}
}