diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index e05c167229b..dd78af6ecd6 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -7,6 +7,7 @@ use devtools_traits::ScriptToDevtoolsControlMsg; use document_loader::{DocumentLoader, LoadType}; use dom::activation::{ActivationSource, synthetic_click_activation}; use dom::attr::Attr; +use dom::beforeunloadevent::BeforeUnloadEvent; use dom::bindings::callback::ExceptionHandling; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods; @@ -2603,6 +2604,8 @@ impl DocumentMethods for Document { fn CreateEvent(&self, mut interface: DOMString) -> Fallible> { interface.make_ascii_lowercase(); match &*interface { + "beforeunloadevent" => + Ok(Root::upcast(BeforeUnloadEvent::new_uninitialized(&self.window))), "closeevent" => Ok(Root::upcast(CloseEvent::new_uninitialized(self.window.upcast()))), "customevent" => diff --git a/tests/wpt/metadata/dom/events/EventTarget-dispatchEvent.html.ini b/tests/wpt/metadata/dom/events/EventTarget-dispatchEvent.html.ini index 201224d1802..cdf64e987c2 100644 --- a/tests/wpt/metadata/dom/events/EventTarget-dispatchEvent.html.ini +++ b/tests/wpt/metadata/dom/events/EventTarget-dispatchEvent.html.ini @@ -3,9 +3,6 @@ [If the event's initialized flag is not set, an InvalidStateError must be thrown (AnimationEvent).] expected: FAIL - [If the event's initialized flag is not set, an InvalidStateError must be thrown (BeforeUnloadEvent).] - expected: FAIL - [If the event's initialized flag is not set, an InvalidStateError must be thrown (CompositionEvent).] expected: FAIL diff --git a/tests/wpt/metadata/dom/nodes/Document-createEvent.html.ini b/tests/wpt/metadata/dom/nodes/Document-createEvent.html.ini index c8062768eb4..783ad1e01c5 100644 --- a/tests/wpt/metadata/dom/nodes/Document-createEvent.html.ini +++ b/tests/wpt/metadata/dom/nodes/Document-createEvent.html.ini @@ -19,24 +19,6 @@ [createEvent('ANIMATIONEVENT') should be initialized correctly.] expected: FAIL - [BeforeUnloadEvent should be an alias for BeforeUnloadEvent.] - expected: FAIL - - [createEvent('BeforeUnloadEvent') should be initialized correctly.] - expected: FAIL - - [beforeunloadevent should be an alias for BeforeUnloadEvent.] - expected: FAIL - - [createEvent('beforeunloadevent') should be initialized correctly.] - expected: FAIL - - [BEFOREUNLOADEVENT should be an alias for BeforeUnloadEvent.] - expected: FAIL - - [createEvent('BEFOREUNLOADEVENT') should be initialized correctly.] - expected: FAIL - [CompositionEvent should be an alias for CompositionEvent.] expected: FAIL