aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/htmlelement.rs60
-rw-r--r--components/script/dom/macros.rs3
-rw-r--r--tests/wpt/metadata/html/webappapis/scripting/events/event-handler-attributes-body-window.html.ini21
-rw-r--r--tests/wpt/metadata/html/webappapis/scripting/events/event-handler-attributes-frameset-window.html.ini19
-rw-r--r--tests/wpt/metadata/html/webappapis/scripting/events/event-handler-attributes-windowless-body.html.ini6
5 files changed, 47 insertions, 62 deletions
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs
index c5b7e6d0251..b5cd0930def 100644
--- a/components/script/dom/htmlelement.rs
+++ b/components/script/dom/htmlelement.rs
@@ -5,6 +5,7 @@
use crate::dom::activation::{synthetic_click_activation, ActivationSource};
use crate::dom::attr::Attr;
use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
+use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::OnErrorEventHandlerNonNull;
use crate::dom::bindings::codegen::Bindings::HTMLElementBinding;
use crate::dom::bindings::codegen::Bindings::HTMLElementBinding::HTMLElementMethods;
use crate::dom::bindings::codegen::Bindings::HTMLLabelElementBinding::HTMLLabelElementMethods;
@@ -181,36 +182,37 @@ impl HTMLElementMethods for HTMLElement {
self.dataset.or_init(|| DOMStringMap::new(self))
}
- // https://html.spec.whatwg.org/multipage/#handler-onload
- fn GetOnload(&self) -> Option<Rc<EventHandlerNonNull>> {
+ // https://html.spec.whatwg.org/multipage/#handler-onerror
+ fn GetOnerror(&self) -> Option<Rc<OnErrorEventHandlerNonNull>> {
if self.is_body_or_frameset() {
let document = document_from_node(self);
if document.has_browsing_context() {
- document.window().GetOnload()
+ document.window().GetOnerror()
} else {
None
}
} else {
self.upcast::<EventTarget>()
- .get_event_handler_common("load")
+ .get_event_handler_common("error")
}
}
- // https://html.spec.whatwg.org/multipage/#handler-onload
- fn SetOnload(&self, listener: Option<Rc<EventHandlerNonNull>>) {
+ // https://html.spec.whatwg.org/multipage/#handler-onerror
+ fn SetOnerror(&self, listener: Option<Rc<OnErrorEventHandlerNonNull>>) {
if self.is_body_or_frameset() {
let document = document_from_node(self);
if document.has_browsing_context() {
- document.window().SetOnload(listener)
+ document.window().SetOnerror(listener)
}
} else {
+ // special setter for error
self.upcast::<EventTarget>()
- .set_event_handler_common("load", listener)
+ .set_error_event_handler("error", listener)
}
}
- // https://html.spec.whatwg.org/multipage/#handler-onresize
- fn GetOnresize(&self) -> Option<Rc<EventHandlerNonNull>> {
+ // https://html.spec.whatwg.org/multipage/#handler-onload
+ fn GetOnload(&self) -> Option<Rc<EventHandlerNonNull>> {
if self.is_body_or_frameset() {
let document = document_from_node(self);
if document.has_browsing_context() {
@@ -220,20 +222,20 @@ impl HTMLElementMethods for HTMLElement {
}
} else {
self.upcast::<EventTarget>()
- .get_event_handler_common("resize")
+ .get_event_handler_common("load")
}
}
- // https://html.spec.whatwg.org/multipage/#handler-onresize
- fn SetOnresize(&self, listener: Option<Rc<EventHandlerNonNull>>) {
+ // https://html.spec.whatwg.org/multipage/#handler-onload
+ fn SetOnload(&self, listener: Option<Rc<EventHandlerNonNull>>) {
if self.is_body_or_frameset() {
let document = document_from_node(self);
if document.has_browsing_context() {
- document.window().SetOnresize(listener);
+ document.window().SetOnload(listener)
}
} else {
self.upcast::<EventTarget>()
- .set_event_handler_common("resize", listener)
+ .set_event_handler_common("load", listener)
}
}
@@ -293,6 +295,34 @@ impl HTMLElementMethods for HTMLElement {
}
}
+ // https://html.spec.whatwg.org/multipage/#handler-onresize
+ fn GetOnresize(&self) -> Option<Rc<EventHandlerNonNull>> {
+ if self.is_body_or_frameset() {
+ let document = document_from_node(self);
+ if document.has_browsing_context() {
+ document.window().GetOnresize()
+ } else {
+ None
+ }
+ } else {
+ self.upcast::<EventTarget>()
+ .get_event_handler_common("resize")
+ }
+ }
+
+ // https://html.spec.whatwg.org/multipage/#handler-onresize
+ fn SetOnresize(&self, listener: Option<Rc<EventHandlerNonNull>>) {
+ if self.is_body_or_frameset() {
+ let document = document_from_node(self);
+ if document.has_browsing_context() {
+ document.window().SetOnresize(listener)
+ }
+ } else {
+ self.upcast::<EventTarget>()
+ .set_event_handler_common("resize", listener)
+ }
+ }
+
// https://html.spec.whatwg.org/multipage/#handler-onscroll
fn GetOnscroll(&self) -> Option<Rc<EventHandlerNonNull>> {
if self.is_body_or_frameset() {
diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs
index fe578f6f675..21124fd37c4 100644
--- a/components/script/dom/macros.rs
+++ b/components/script/dom/macros.rs
@@ -430,7 +430,9 @@ macro_rules! window_owned_beforeunload_event_handler(
// As more methods get added, just update them here.
macro_rules! global_event_handlers(
() => (
+ // These are special when on body/frameset elements
event_handler!(blur, GetOnblur, SetOnblur);
+ error_event_handler!(error, GetOnerror, SetOnerror);
event_handler!(focus, GetOnfocus, SetOnfocus);
event_handler!(load, GetOnload, SetOnload);
event_handler!(resize, GetOnresize, SetOnresize);
@@ -460,7 +462,6 @@ macro_rules! global_event_handlers(
event_handler!(durationchange, GetOndurationchange, SetOndurationchange);
event_handler!(emptied, GetOnemptied, SetOnemptied);
event_handler!(ended, GetOnended, SetOnended);
- error_event_handler!(error, GetOnerror, SetOnerror);
event_handler!(formdata, GetOnformdata, SetOnformdata);
event_handler!(input, GetOninput, SetOninput);
event_handler!(invalid, GetOninvalid, SetOninvalid);
diff --git a/tests/wpt/metadata/html/webappapis/scripting/events/event-handler-attributes-body-window.html.ini b/tests/wpt/metadata/html/webappapis/scripting/events/event-handler-attributes-body-window.html.ini
index 62f99bff922..b72fe6022a4 100644
--- a/tests/wpt/metadata/html/webappapis/scripting/events/event-handler-attributes-body-window.html.ini
+++ b/tests/wpt/metadata/html/webappapis/scripting/events/event-handler-attributes-body-window.html.ini
@@ -1,14 +1,9 @@
[event-handler-attributes-body-window.html]
type: testharness
- [error]
- expected: FAIL
[HTMLBodyElement event handlers]
expected: FAIL
- [shadowed error (document.body)]
- expected: FAIL
-
[not shadowed auxclick (document.body)]
expected: FAIL
@@ -27,9 +22,6 @@
[not shadowed paste (document.body)]
expected: FAIL
- [shadowed error (document.createElement("body"))]
- expected: FAIL
-
[not shadowed auxclick (document.createElement("body"))]
expected: FAIL
@@ -48,27 +40,15 @@
[not shadowed paste (document.createElement("body"))]
expected: FAIL
- [shadowed resize (window)]
- expected: FAIL
-
[not shadowed loadend (window)]
expected: FAIL
- [shadowed resize (document.body)]
- expected: FAIL
-
- [shadowed resize (document.createElement("body"))]
- expected: FAIL
-
[not shadowed securitypolicyviolation (window)]
expected: FAIL
[not shadowed auxclick (window)]
expected: FAIL
- [shadowed error (window)]
- expected: FAIL
-
[not shadowed slotchange (window)]
expected: FAIL
@@ -113,4 +93,3 @@
[not shadowed webkitanimationstart (window)]
expected: FAIL
-
diff --git a/tests/wpt/metadata/html/webappapis/scripting/events/event-handler-attributes-frameset-window.html.ini b/tests/wpt/metadata/html/webappapis/scripting/events/event-handler-attributes-frameset-window.html.ini
index 459422d322e..c9d948d5eac 100644
--- a/tests/wpt/metadata/html/webappapis/scripting/events/event-handler-attributes-frameset-window.html.ini
+++ b/tests/wpt/metadata/html/webappapis/scripting/events/event-handler-attributes-frameset-window.html.ini
@@ -1,19 +1,7 @@
[event-handler-attributes-frameset-window.html]
- [shadowed resize (window)]
- expected: FAIL
-
- [shadowed error (document.createElement("frameset"))]
- expected: FAIL
-
[not shadowed paste (document.createElement("frameset"))]
expected: FAIL
- [shadowed resize (document.body)]
- expected: FAIL
-
- [shadowed resize (document.createElement("frameset"))]
- expected: FAIL
-
[not shadowed securitypolicyviolation (document.body)]
expected: FAIL
@@ -44,9 +32,6 @@
[not shadowed paste (document.body)]
expected: FAIL
- [shadowed error (document.body)]
- expected: FAIL
-
[not shadowed copy (document.body)]
expected: FAIL
@@ -56,9 +41,6 @@
[not shadowed cut (document.createElement("frameset"))]
expected: FAIL
- [shadowed error (window)]
- expected: FAIL
-
[not shadowed auxclick (document.createElement("frameset"))]
expected: FAIL
@@ -106,4 +88,3 @@
[not shadowed webkitanimationiteration (document.body)]
expected: FAIL
-
diff --git a/tests/wpt/metadata/html/webappapis/scripting/events/event-handler-attributes-windowless-body.html.ini b/tests/wpt/metadata/html/webappapis/scripting/events/event-handler-attributes-windowless-body.html.ini
index a6fc6b39fc1..87953c35e5f 100644
--- a/tests/wpt/metadata/html/webappapis/scripting/events/event-handler-attributes-windowless-body.html.ini
+++ b/tests/wpt/metadata/html/webappapis/scripting/events/event-handler-attributes-windowless-body.html.ini
@@ -2,9 +2,6 @@
[event-handler-attributes-windowless-body]
expected: FAIL
- [Ignore setting of error window event handlers on windowless body]
- expected: FAIL
-
[auxclick is unaffected on a windowless body]
expected: FAIL
@@ -14,9 +11,6 @@
[securitypolicyviolation is unaffected on a windowless body]
expected: FAIL
- [Ignore setting of error window event handlers on windowless frameset]
- expected: FAIL
-
[auxclick is unaffected on a windowless frameset]
expected: FAIL