From 1f8106a1dc84ade7c6be3c5da6faeb19b1462797 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sat, 21 Jan 2017 01:26:19 +0100 Subject: [PATCH] Expose PopStateEvent only in Window --- components/script/dom/document.rs | 2 +- components/script/dom/popstateevent.rs | 14 +++++++------- components/script/dom/webidls/PopStateEvent.webidl | 3 ++- .../semantics/interface-objects/002.worker.js.ini | 3 --- .../wpt/mozilla/tests/mozilla/interfaces.worker.js | 1 - 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 570c684965e..e05c167229b 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -2624,7 +2624,7 @@ impl DocumentMethods for Document { "pagetransitionevent" => Ok(Root::upcast(PageTransitionEvent::new_uninitialized(&self.window))), "popstateevent" => - Ok(Root::upcast(PopStateEvent::new_uninitialized(self.window.upcast()))), + Ok(Root::upcast(PopStateEvent::new_uninitialized(&self.window))), "progressevent" => Ok(Root::upcast(ProgressEvent::new_uninitialized(self.window.upcast()))), "storageevent" => { diff --git a/components/script/dom/popstateevent.rs b/components/script/dom/popstateevent.rs index 44183f7483f..fde05e30394 100644 --- a/components/script/dom/popstateevent.rs +++ b/components/script/dom/popstateevent.rs @@ -11,7 +11,7 @@ use dom::bindings::js::{MutHeapJSVal, Root}; use dom::bindings::reflector::reflect_dom_object; use dom::bindings::str::DOMString; use dom::event::Event; -use dom::globalscope::GlobalScope; +use dom::window::Window; use js::jsapi::{HandleValue, JSContext}; use js::jsval::JSVal; use servo_atoms::Atom; @@ -32,19 +32,19 @@ impl PopStateEvent { } } - pub fn new_uninitialized(global: &GlobalScope) -> Root { + pub fn new_uninitialized(window: &Window) -> Root { reflect_dom_object(box PopStateEvent::new_inherited(), - global, + window, PopStateEventBinding::Wrap) } - pub fn new(global: &GlobalScope, + pub fn new(window: &Window, type_: Atom, bubbles: bool, cancelable: bool, state: HandleValue) -> Root { - let ev = PopStateEvent::new_uninitialized(global); + let ev = PopStateEvent::new_uninitialized(window); ev.state.set(state.get()); { let event = ev.upcast::(); @@ -54,11 +54,11 @@ impl PopStateEvent { } #[allow(unsafe_code)] - pub fn Constructor(global: &GlobalScope, + pub fn Constructor(window: &Window, type_: DOMString, init: &PopStateEventBinding::PopStateEventInit) -> Fallible> { - Ok(PopStateEvent::new(global, + Ok(PopStateEvent::new(window, Atom::from(type_), init.parent.bubbles, init.parent.cancelable, diff --git a/components/script/dom/webidls/PopStateEvent.webidl b/components/script/dom/webidls/PopStateEvent.webidl index f5052df597f..4508cac6288 100644 --- a/components/script/dom/webidls/PopStateEvent.webidl +++ b/components/script/dom/webidls/PopStateEvent.webidl @@ -3,7 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // https://html.spec.whatwg.org/multipage/#the-popstateevent-interface -[Constructor(DOMString type, optional PopStateEventInit eventInitDict), Exposed=(Window,Worker)] +[Constructor(DOMString type, optional PopStateEventInit eventInitDict), + Exposed=Window] interface PopStateEvent : Event { readonly attribute any state; }; diff --git a/tests/wpt/metadata/workers/semantics/interface-objects/002.worker.js.ini b/tests/wpt/metadata/workers/semantics/interface-objects/002.worker.js.ini index b97352bf940..9e5b372448a 100644 --- a/tests/wpt/metadata/workers/semantics/interface-objects/002.worker.js.ini +++ b/tests/wpt/metadata/workers/semantics/interface-objects/002.worker.js.ini @@ -3,6 +3,3 @@ [The Location interface object should not be exposed.] expected: FAIL - [The PopStateEvent interface object should not be exposed.] - expected: FAIL - diff --git a/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js b/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js index d7039e0bd66..06fd14d5c6e 100644 --- a/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js +++ b/tests/wpt/mozilla/tests/mozilla/interfaces.worker.js @@ -41,7 +41,6 @@ test_interfaces([ "PerformanceTiming", "Plugin", "PluginArray", - "PopStateEvent", "ProgressEvent", "Request", "Response",