Expose HashChangeEvent only in Window

This commit is contained in:
Anthony Ramine 2017-01-21 01:26:19 +01:00
parent ee1ff1d385
commit 2221203359
5 changed files with 10 additions and 13 deletions

View file

@ -2614,7 +2614,7 @@ impl DocumentMethods for Document {
"focusevent" => "focusevent" =>
Ok(Root::upcast(FocusEvent::new_uninitialized(&self.window))), Ok(Root::upcast(FocusEvent::new_uninitialized(&self.window))),
"hashchangeevent" => "hashchangeevent" =>
Ok(Root::upcast(HashChangeEvent::new_uninitialized(&self.window.upcast()))), Ok(Root::upcast(HashChangeEvent::new_uninitialized(&self.window))),
"keyboardevent" => "keyboardevent" =>
Ok(Root::upcast(KeyboardEvent::new_uninitialized(&self.window))), Ok(Root::upcast(KeyboardEvent::new_uninitialized(&self.window))),
"messageevent" => "messageevent" =>

View file

@ -11,7 +11,7 @@ use dom::bindings::js::Root;
use dom::bindings::reflector::reflect_dom_object; use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::str::{DOMString, USVString}; use dom::bindings::str::{DOMString, USVString};
use dom::event::Event; use dom::event::Event;
use dom::globalscope::GlobalScope; use dom::window::Window;
use servo_atoms::Atom; use servo_atoms::Atom;
// https://html.spec.whatwg.org/multipage/#hashchangeevent // https://html.spec.whatwg.org/multipage/#hashchangeevent
@ -31,13 +31,13 @@ impl HashChangeEvent {
} }
} }
pub fn new_uninitialized(global: &GlobalScope) -> Root<HashChangeEvent> { pub fn new_uninitialized(window: &Window) -> Root<HashChangeEvent> {
reflect_dom_object(box HashChangeEvent::new_inherited(String::new(), String::new()), reflect_dom_object(box HashChangeEvent::new_inherited(String::new(), String::new()),
global, window,
HashChangeEventBinding::Wrap) HashChangeEventBinding::Wrap)
} }
pub fn new(global: &GlobalScope, pub fn new(window: &Window,
type_: Atom, type_: Atom,
bubbles: bool, bubbles: bool,
cancelable: bool, cancelable: bool,
@ -45,7 +45,7 @@ impl HashChangeEvent {
new_url: String) new_url: String)
-> Root<HashChangeEvent> { -> Root<HashChangeEvent> {
let ev = reflect_dom_object(box HashChangeEvent::new_inherited(old_url, new_url), let ev = reflect_dom_object(box HashChangeEvent::new_inherited(old_url, new_url),
global, window,
HashChangeEventBinding::Wrap); HashChangeEventBinding::Wrap);
{ {
let event = ev.upcast::<Event>(); let event = ev.upcast::<Event>();
@ -54,11 +54,11 @@ impl HashChangeEvent {
ev ev
} }
pub fn Constructor(global: &GlobalScope, pub fn Constructor(window: &Window,
type_: DOMString, type_: DOMString,
init: &HashChangeEventBinding::HashChangeEventInit) init: &HashChangeEventBinding::HashChangeEventInit)
-> Fallible<Root<HashChangeEvent>> { -> Fallible<Root<HashChangeEvent>> {
Ok(HashChangeEvent::new(global, Ok(HashChangeEvent::new(window,
Atom::from(type_), Atom::from(type_),
init.parent.bubbles, init.parent.bubbles,
init.parent.cancelable, init.parent.cancelable,

View file

@ -3,7 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// https://html.spec.whatwg.org/multipage/#hashchangeevent // https://html.spec.whatwg.org/multipage/#hashchangeevent
[Constructor(DOMString type, optional HashChangeEventInit eventInitDict), Exposed=(Window,Worker)] [Constructor(DOMString type, optional HashChangeEventInit eventInitDict),
Exposed=Window]
interface HashChangeEvent : Event { interface HashChangeEvent : Event {
readonly attribute USVString oldURL; readonly attribute USVString oldURL;
readonly attribute USVString newURL; readonly attribute USVString newURL;

View file

@ -6,9 +6,6 @@
[The PopStateEvent interface object should not be exposed.] [The PopStateEvent interface object should not be exposed.]
expected: FAIL expected: FAIL
[The HashChangeEvent interface object should not be exposed.]
expected: FAIL
[The PageTransitionEvent interface object should not be exposed.] [The PageTransitionEvent interface object should not be exposed.]
expected: FAIL expected: FAIL

View file

@ -29,7 +29,6 @@ test_interfaces([
"FileReader", "FileReader",
"FileReaderSync", "FileReaderSync",
"FormData", "FormData",
"HashChangeEvent",
"Headers", "Headers",
"History", "History",
"ImageData", "ImageData",