Errors only pass the special bonus arguments to globals

This commit is contained in:
Patrick Shaughnessy 2020-01-27 15:03:28 -05:00
parent d0f64d9d56
commit ee53e10f70
3 changed files with 24 additions and 31 deletions

View file

@ -33,6 +33,7 @@ use crate::dom::htmlformelement::FormControlElementHelpers;
use crate::dom::node::document_from_node; use crate::dom::node::document_from_node;
use crate::dom::virtualmethods::VirtualMethods; use crate::dom::virtualmethods::VirtualMethods;
use crate::dom::window::Window; use crate::dom::window::Window;
use crate::dom::workerglobalscope::WorkerGlobalScope;
use crate::realms::enter_realm; use crate::realms::enter_realm;
use dom_struct::dom_struct; use dom_struct::dom_struct;
use fnv::FnvHasher; use fnv::FnvHasher;
@ -152,9 +153,9 @@ pub enum CompiledEventListener {
impl CompiledEventListener { impl CompiledEventListener {
// https://html.spec.whatwg.org/multipage/#the-event-handler-processing-algorithm // https://html.spec.whatwg.org/multipage/#the-event-handler-processing-algorithm
pub fn call_or_handle_event<T: DomObject>( pub fn call_or_handle_event(
&self, &self,
object: &T, object: &EventTarget,
event: &Event, event: &Event,
exception_handle: ExceptionHandling, exception_handle: ExceptionHandling,
) { ) {
@ -167,6 +168,7 @@ impl CompiledEventListener {
match *handler { match *handler {
CommonEventHandler::ErrorEventHandler(ref handler) => { CommonEventHandler::ErrorEventHandler(ref handler) => {
if let Some(event) = event.downcast::<ErrorEvent>() { if let Some(event) = event.downcast::<ErrorEvent>() {
if object.is::<Window>() || object.is::<WorkerGlobalScope>() {
let cx = object.global().get_cx(); let cx = object.global().get_cx();
rooted!(in(*cx) let error = event.Error(cx)); rooted!(in(*cx) let error = event.Error(cx));
let return_value = handler.Call_( let return_value = handler.Call_(
@ -189,6 +191,7 @@ impl CompiledEventListener {
} }
return; return;
} }
}
let _ = handler.Call_( let _ = handler.Call_(
object, object,

View file

@ -1,5 +0,0 @@
[document-synthetic-errorevent.html]
type: testharness
[error event is normal (return true does not cancel; one arg) on Document, with a synthetic ErrorEvent]
expected: FAIL

View file

@ -1,5 +0,0 @@
[script-element.html]
type: testharness
[error event behaves normally (return true does not cancel; one arg) on a script element, with a synthetic ErrorEvent]
expected: FAIL