diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs
index 8c718c5ab29..f0348c27b76 100644
--- a/components/script/dom/htmlelement.rs
+++ b/components/script/dom/htmlelement.rs
@@ -162,6 +162,24 @@ impl HTMLElementMethods for HTMLElement {
}
}
+ // https://html.spec.whatwg.org/multipage/#handler-onresize
+ fn GetOnresize(&self) -> Option> {
+ if self.is_body_or_frameset() {
+ window_from_node(self).GetOnload()
+ } else {
+ self.upcast::().get_event_handler_common("resize")
+ }
+ }
+
+ // https://html.spec.whatwg.org/multipage/#handler-onresize
+ fn SetOnresize(&self, listener: Option>) {
+ if self.is_body_or_frameset() {
+ window_from_node(self).SetOnresize(listener);
+ } else {
+ self.upcast::().set_event_handler_common("resize", listener)
+ }
+ }
+
// https://html.spec.whatwg.org/multipage/#dom-click
fn Click(&self) {
if let Some(i) = self.downcast::() {
diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs
index 1bfa576a1d6..fb548266263 100644
--- a/components/script/dom/macros.rs
+++ b/components/script/dom/macros.rs
@@ -333,6 +333,7 @@ macro_rules! error_event_handler(
macro_rules! global_event_handlers(
() => (
event_handler!(load, GetOnload, SetOnload);
+ event_handler!(resize, GetOnresize, SetOnresize);
global_event_handlers!(NoOnload);
);
diff --git a/components/script/dom/webidls/EventHandler.webidl b/components/script/dom/webidls/EventHandler.webidl
index 91753edf9c7..9c822ae9522 100644
--- a/components/script/dom/webidls/EventHandler.webidl
+++ b/components/script/dom/webidls/EventHandler.webidl
@@ -34,6 +34,7 @@ interface GlobalEventHandlers {
attribute EventHandler onreset;
attribute EventHandler onsubmit;
attribute EventHandler ontoggle;
+ attribute EventHandler onresize;
};
[NoInterfaceObject]
diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json
index d1d5c65385e..90ef7985c25 100644
--- a/tests/wpt/metadata/MANIFEST.json
+++ b/tests/wpt/metadata/MANIFEST.json
@@ -33318,6 +33318,12 @@
"deleted": [],
"items": {
"testharness": {
+ "html/webappapis/scripting/events/event-handler-onresize.html": [
+ {
+ "path": "html/webappapis/scripting/events/event-handler-onresize.html",
+ "url": "/html/webappapis/scripting/events/event-handler-onresize.html"
+ }
+ ],
"websockets/Create-asciiSep-protocol-string.htm": [
{
"path": "websockets/Create-asciiSep-protocol-string.htm",
diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini
index 31778f3116c..113ec51d195 100644
--- a/tests/wpt/metadata/html/dom/interfaces.html.ini
+++ b/tests/wpt/metadata/html/dom/interfaces.html.ini
@@ -186,9 +186,6 @@
[Document interface: attribute onratechange]
expected: FAIL
- [Document interface: attribute onresize]
- expected: FAIL
-
[Document interface: attribute onscroll]
expected: FAIL
@@ -1725,9 +1722,6 @@
[HTMLElement interface: attribute onratechange]
expected: FAIL
- [HTMLElement interface: attribute onresize]
- expected: FAIL
-
[HTMLElement interface: attribute onscroll]
expected: FAIL
@@ -1956,9 +1950,6 @@
[HTMLElement interface: document.createElement("noscript") must inherit property "onratechange" with the proper type (79)]
expected: FAIL
- [HTMLElement interface: document.createElement("noscript") must inherit property "onresize" with the proper type (81)]
- expected: FAIL
-
[HTMLElement interface: document.createElement("noscript") must inherit property "onscroll" with the proper type (82)]
expected: FAIL
@@ -8730,9 +8721,6 @@
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "onratechange" with the proper type (141)]
expected: FAIL
- [Document interface: document.implementation.createDocument(null, "", null) must inherit property "onresize" with the proper type (143)]
- expected: FAIL
-
[Document interface: document.implementation.createDocument(null, "", null) must inherit property "onscroll" with the proper type (144)]
expected: FAIL
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 0869c29c2c8..a48897fc852 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
@@ -9,9 +9,6 @@
[focus]
expected: FAIL
- [resize]
- expected: FAIL
-
[scroll]
expected: FAIL
diff --git a/tests/wpt/web-platform-tests/html/webappapis/scripting/events/event-handler-onresize.html b/tests/wpt/web-platform-tests/html/webappapis/scripting/events/event-handler-onresize.html
new file mode 100644
index 00000000000..8686716e19a
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/webappapis/scripting/events/event-handler-onresize.html
@@ -0,0 +1,38 @@
+
+HTMLBodyElement.onresize
+
+
+
+
+
+