Implement report_an_error on GlobalRef.

This commit is contained in:
Ms2ger 2016-09-05 17:14:28 +02:00
parent 5f702d6e7f
commit b3050855e7
2 changed files with 11 additions and 3 deletions

View file

@ -245,9 +245,7 @@ pub unsafe fn report_pending_exception(cx: *mut JSContext, dispatch_event: bool)
if dispatch_event {
let global = global_root_from_context(cx);
if let GlobalRef::Window(window) = global.r() {
window.report_an_error(error_info, value.handle());
}
global.r().report_an_error(error_info, value.handle());
}
}
}

View file

@ -10,11 +10,13 @@
use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId};
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::conversions::root_from_object;
use dom::bindings::error::ErrorInfo;
use dom::bindings::js::Root;
use dom::bindings::reflector::{Reflectable, Reflector};
use dom::window::{self, ScriptHelpers};
use dom::workerglobalscope::WorkerGlobalScope;
use ipc_channel::ipc::IpcSender;
use js::jsapi::HandleValue;
use js::jsapi::{CurrentGlobalOrNull, GetGlobalForObjectCrossCompartment};
use js::jsapi::{JSContext, JSObject, JS_GetClass, MutableHandleValue};
use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL};
@ -285,6 +287,14 @@ impl<'a> GlobalRef<'a> {
GlobalRef::Worker(ref worker) => worker.get_runnable_wrapper(),
}
}
/// https://html.spec.whatwg.org/multipage/#report-the-error
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(_) => (),
}
}
}
impl GlobalRoot {