diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs index f107d201969..cdc8f4cfac0 100644 --- a/components/script/dom/htmlbodyelement.rs +++ b/components/script/dom/htmlbodyelement.rs @@ -84,6 +84,17 @@ impl HTMLBodyElementMethods for HTMLBodyElement { fn SetOnstorage(&self, listener: Option>) { window_from_node(self).SetOnstorage(listener) } + + // https://html.spec.whatwg.org/multipage/#dom-body-background + make_getter!(Background, "background"); + + // https://html.spec.whatwg.org/multipage/#dom-body-background + fn SetBackground(&self, value: DOMString) { + let document = document_from_node(self); + let base = document.url(); + *self.background.borrow_mut() = base.join(&value).ok(); + self.upcast::().set_string_attribute(&atom!("background"), value); + } } pub trait HTMLBodyElementLayoutHelpers { diff --git a/components/script/dom/webidls/HTMLBodyElement.webidl b/components/script/dom/webidls/HTMLBodyElement.webidl index 50e834d1813..36a7a99f996 100644 --- a/components/script/dom/webidls/HTMLBodyElement.webidl +++ b/components/script/dom/webidls/HTMLBodyElement.webidl @@ -23,5 +23,5 @@ partial interface HTMLBodyElement { //[TreatNullAs=EmptyString] attribute DOMString aLink; [TreatNullAs=EmptyString] attribute DOMString bgColor; - // attribute DOMString background; + attribute DOMString background; }; diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini index ed64e6f5035..8d3523010a5 100644 --- a/tests/wpt/metadata/html/dom/interfaces.html.ini +++ b/tests/wpt/metadata/html/dom/interfaces.html.ini @@ -2169,9 +2169,6 @@ [HTMLBodyElement interface: attribute aLink] expected: FAIL - [HTMLBodyElement interface: attribute background] - expected: FAIL - [HTMLBodyElement interface: attribute onafterprint] expected: FAIL @@ -2214,9 +2211,6 @@ [HTMLBodyElement interface: document.createElement("body") must inherit property "aLink" with the proper type (3)] expected: FAIL - [HTMLBodyElement interface: document.createElement("body") must inherit property "background" with the proper type (5)] - expected: FAIL - [HTMLBodyElement interface: document.createElement("body") must inherit property "onafterprint" with the proper type (6)] expected: FAIL diff --git a/tests/wpt/metadata/html/dom/reflection-sections.html.ini b/tests/wpt/metadata/html/dom/reflection-sections.html.ini index b3d7609a401..fd287463d0e 100644 --- a/tests/wpt/metadata/html/dom/reflection-sections.html.ini +++ b/tests/wpt/metadata/html/dom/reflection-sections.html.ini @@ -846,135 +846,6 @@ [body.aLink: IDL set to object "test-valueOf" followed by IDL get] expected: FAIL - [body.background: typeof IDL attribute] - expected: FAIL - - [body.background: IDL get with DOM attribute unset] - expected: FAIL - - [body.background: setAttribute() to "" followed by IDL get] - expected: FAIL - - [body.background: setAttribute() to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo " followed by IDL get] - expected: FAIL - - [body.background: setAttribute() to undefined followed by IDL get] - expected: FAIL - - [body.background: setAttribute() to 7 followed by IDL get] - expected: FAIL - - [body.background: setAttribute() to 1.5 followed by IDL get] - expected: FAIL - - [body.background: setAttribute() to true followed by IDL get] - expected: FAIL - - [body.background: setAttribute() to false followed by IDL get] - expected: FAIL - - [body.background: setAttribute() to object "[object Object\]" followed by IDL get] - expected: FAIL - - [body.background: setAttribute() to NaN followed by IDL get] - expected: FAIL - - [body.background: setAttribute() to Infinity followed by IDL get] - expected: FAIL - - [body.background: setAttribute() to -Infinity followed by IDL get] - expected: FAIL - - [body.background: setAttribute() to "\\0" followed by IDL get] - expected: FAIL - - [body.background: setAttribute() to null followed by IDL get] - expected: FAIL - - [body.background: setAttribute() to object "test-toString" followed by IDL get] - expected: FAIL - - [body.background: setAttribute() to object "test-valueOf" followed by IDL get] - expected: FAIL - - [body.background: IDL set to "" followed by getAttribute()] - expected: FAIL - - [body.background: IDL set to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo " followed by getAttribute()] - expected: FAIL - - [body.background: IDL set to undefined followed by getAttribute()] - expected: FAIL - - [body.background: IDL set to undefined followed by IDL get] - expected: FAIL - - [body.background: IDL set to 7 followed by getAttribute()] - expected: FAIL - - [body.background: IDL set to 7 followed by IDL get] - expected: FAIL - - [body.background: IDL set to 1.5 followed by getAttribute()] - expected: FAIL - - [body.background: IDL set to 1.5 followed by IDL get] - expected: FAIL - - [body.background: IDL set to true followed by getAttribute()] - expected: FAIL - - [body.background: IDL set to true followed by IDL get] - expected: FAIL - - [body.background: IDL set to false followed by getAttribute()] - expected: FAIL - - [body.background: IDL set to false followed by IDL get] - expected: FAIL - - [body.background: IDL set to object "[object Object\]" followed by getAttribute()] - expected: FAIL - - [body.background: IDL set to object "[object Object\]" followed by IDL get] - expected: FAIL - - [body.background: IDL set to NaN followed by getAttribute()] - expected: FAIL - - [body.background: IDL set to NaN followed by IDL get] - expected: FAIL - - [body.background: IDL set to Infinity followed by getAttribute()] - expected: FAIL - - [body.background: IDL set to Infinity followed by IDL get] - expected: FAIL - - [body.background: IDL set to -Infinity followed by getAttribute()] - expected: FAIL - - [body.background: IDL set to -Infinity followed by IDL get] - expected: FAIL - - [body.background: IDL set to "\\0" followed by getAttribute()] - expected: FAIL - - [body.background: IDL set to null followed by getAttribute()] - expected: FAIL - - [body.background: IDL set to null followed by IDL get] - expected: FAIL - - [body.background: IDL set to object "test-toString" followed by getAttribute()] - expected: FAIL - - [body.background: IDL set to object "test-toString" followed by IDL get] - expected: FAIL - - [body.background: IDL set to object "test-valueOf" followed by IDL get] - expected: FAIL - [body.itemScope: typeof IDL attribute] expected: FAIL