diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs
index 806086a6b03..438aa79ec74 100644
--- a/components/script/dom/htmlbodyelement.rs
+++ b/components/script/dom/htmlbodyelement.rs
@@ -83,6 +83,18 @@ impl HTMLBodyElementMethods for HTMLBodyElement {
let win = window_from_node(self);
win.r().SetOnunload(listener)
}
+
+ // https://html.spec.whatwg.org/multipage/#the-body-element
+ fn GetOnstorage(&self) -> Option> {
+ let win = window_from_node(self);
+ win.r().GetOnstorage()
+ }
+
+ // https://html.spec.whatwg.org/multipage/#the-body-element
+ fn SetOnstorage(&self, listener: Option>) {
+ let win = window_from_node(self);
+ win.r().SetOnstorage(listener)
+ }
}
diff --git a/components/script/dom/webidls/EventHandler.webidl b/components/script/dom/webidls/EventHandler.webidl
index 8848c3aafbb..7ff237f2ceb 100644
--- a/components/script/dom/webidls/EventHandler.webidl
+++ b/components/script/dom/webidls/EventHandler.webidl
@@ -36,6 +36,7 @@ interface GlobalEventHandlers {
[NoInterfaceObject]
interface WindowEventHandlers {
attribute EventHandler onunload;
+ attribute EventHandler onstorage;
};
// The spec has |attribute OnErrorEventHandler onerror;| on
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 4ada66c36cc..7172177af77 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -513,6 +513,9 @@ impl WindowMethods for Window {
// https://html.spec.whatwg.org/multipage/#handler-window-onunload
event_handler!(unload, GetOnunload, SetOnunload);
+ // https://html.spec.whatwg.org/multipage/#handler-window-onstorage
+ event_handler!(storage, GetOnstorage, SetOnstorage);
+
// https://html.spec.whatwg.org/multipage/#handler-onerror
error_event_handler!(error, GetOnerror, SetOnerror);
diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini
index 205cff1f1af..ecb19827604 100644
--- a/tests/wpt/metadata/html/dom/interfaces.html.ini
+++ b/tests/wpt/metadata/html/dom/interfaces.html.ini
@@ -2244,9 +2244,6 @@
[HTMLBodyElement interface: attribute onpopstate]
expected: FAIL
- [HTMLBodyElement interface: attribute onstorage]
- expected: FAIL
-
[HTMLBodyElement interface: document.createElement("body") must inherit property "link" with the proper type (1)]
expected: FAIL
@@ -2292,9 +2289,6 @@
[HTMLBodyElement interface: document.createElement("body") must inherit property "onpopstate" with the proper type (16)]
expected: FAIL
- [HTMLBodyElement interface: document.createElement("body") must inherit property "onstorage" with the proper type (17)]
- expected: FAIL
-
[HTMLHeadingElement interface: existence and properties of interface object]
expected: FAIL