diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 8cd3655d7c5..cbfc214f040 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -11,8 +11,8 @@ use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilter; -use dom::bindings::codegen::InheritTypes::{DocumentDerived, EventCast, HTMLElementCast}; -use dom::bindings::codegen::InheritTypes::{HTMLHeadElementCast, ElementCast}; +use dom::bindings::codegen::InheritTypes::{DocumentDerived, EventCast, HTMLBodyElementCast}; +use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLHeadElementCast, ElementCast}; use dom::bindings::codegen::InheritTypes::{DocumentTypeCast, HTMLHtmlElementCast, NodeCast}; use dom::bindings::codegen::InheritTypes::{EventTargetCast, HTMLAnchorElementCast}; use dom::bindings::codegen::InheritTypes::{HTMLAnchorElementDerived, HTMLAppletElementDerived}; @@ -226,6 +226,8 @@ pub trait DocumentHelpers<'a> { modifiers: KeyModifiers, compositor: &mut Box); fn node_from_nodes_and_strings(self, nodes: Vec) -> Fallible>; + fn get_body_attribute(self, local_name: &Atom) -> DOMString; + fn set_body_attribute(self, local_name: &Atom, value: DOMString); /// Handles a mouse-move event coming from the compositor. fn handle_mouse_move_event(self, @@ -742,6 +744,21 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> { } } + fn get_body_attribute(self, local_name: &Atom) -> DOMString { + match self.GetBody().and_then(HTMLBodyElementCast::to_temporary).root() { + Some(ref body) => { + ElementCast::from_ref(body.r()).get_string_attribute(local_name) + }, + None => "".to_owned() + } + } + + fn set_body_attribute(self, local_name: &Atom, value: DOMString) { + if let Some(ref body) = self.GetBody().and_then(HTMLBodyElementCast::to_temporary).root() { + ElementCast::from_ref(body.r()).set_string_attribute(local_name, value); + } + } + fn set_current_script(self, script: Option>) { self.current_script.set(script.map(JS::from_rooted)); } @@ -1493,6 +1510,14 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { Ok(()) } + fn BgColor(self) -> DOMString { + self.get_body_attribute(&atom!("bgcolor")) + } + + fn SetBgColor(self, value: DOMString) { + self.set_body_attribute(&atom!("bgcolor"), value) + } + global_event_handlers!(); event_handler!(readystatechange, GetOnreadystatechange, SetOnreadystatechange); } diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs index 1fb38160cd2..bf11d11c43c 100644 --- a/components/script/dom/htmlbodyelement.rs +++ b/components/script/dom/htmlbodyelement.rs @@ -19,6 +19,7 @@ use dom::virtualmethods::VirtualMethods; use dom::window::WindowHelpers; use cssparser::RGBA; +use string_cache::Atom; use util::str::{self, DOMString}; use std::borrow::ToOwned; @@ -57,6 +58,11 @@ impl HTMLBodyElement { } impl<'a> HTMLBodyElementMethods for JSRef<'a, HTMLBodyElement> { + + // https://html.spec.whatwg.org/#dom-body-bgcolor + make_getter!(BgColor, "bgcolor"); + make_setter!(SetBgColor, "bgcolor"); + fn GetOnunload(self) -> Option { let win = window_from_node(self).root(); win.r().GetOnunload() diff --git a/components/script/dom/webidls/Document.webidl b/components/script/dom/webidls/Document.webidl index 6ea1368a6d2..2f01882ddb4 100644 --- a/components/script/dom/webidls/Document.webidl +++ b/components/script/dom/webidls/Document.webidl @@ -137,7 +137,7 @@ partial interface Document { // [TreatNullAs=EmptyString] attribute DOMString linkColor; // [TreatNullAs=EmptyString] attribute DOMString vlinkColor; // [TreatNullAs=EmptyString] attribute DOMString alinkColor; - // [TreatNullAs=EmptyString] attribute DOMString bgColor; + [TreatNullAs=EmptyString] attribute DOMString bgColor; [SameObject] readonly attribute HTMLCollection anchors; diff --git a/components/script/dom/webidls/HTMLBodyElement.webidl b/components/script/dom/webidls/HTMLBodyElement.webidl index 981ff03490a..f68f51e866e 100644 --- a/components/script/dom/webidls/HTMLBodyElement.webidl +++ b/components/script/dom/webidls/HTMLBodyElement.webidl @@ -3,9 +3,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -// https://www.whatwg.org/html/#htmlbodyelement +// https://html.spec.whatwg.org/#the-body-element interface HTMLBodyElement : HTMLElement { - // also has obsolete members }; HTMLBodyElement implements WindowEventHandlers; @@ -16,6 +15,6 @@ partial interface HTMLBodyElement { //[TreatNullAs=EmptyString] attribute DOMString link; //[TreatNullAs=EmptyString] attribute DOMString vLink; //[TreatNullAs=EmptyString] attribute DOMString aLink; - //[TreatNullAs=EmptyString] attribute DOMString bgColor; + [TreatNullAs=EmptyString] attribute DOMString bgColor; // attribute DOMString background; }; diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini index 20365fb0f4d..2c481481c74 100644 --- a/tests/wpt/metadata/html/dom/interfaces.html.ini +++ b/tests/wpt/metadata/html/dom/interfaces.html.ini @@ -72,9 +72,6 @@ [Document interface: attribute alinkColor] expected: FAIL - [Document interface: attribute bgColor] - expected: FAIL - [Document interface: operation clear()] expected: FAIL @@ -1170,9 +1167,6 @@ [Document interface: document.implementation.createDocument(null, "", null) must inherit property "alinkColor" with the proper type (74)] expected: FAIL - [Document interface: document.implementation.createDocument(null, "", null) must inherit property "bgColor" with the proper type (75)] - expected: FAIL - [Document interface: document.implementation.createDocument(null, "", null) must inherit property "clear" with the proper type (78)] expected: FAIL @@ -2379,9 +2373,6 @@ [HTMLBodyElement interface: attribute aLink] expected: FAIL - [HTMLBodyElement interface: attribute bgColor] - expected: FAIL - [HTMLBodyElement interface: attribute background] expected: FAIL @@ -2433,9 +2424,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 "bgColor" with the proper type (4)] - expected: FAIL - [HTMLBodyElement interface: document.createElement("body") must inherit property "background" with the proper type (5)] 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 79ad8fe9bcb..21a5e3af112 100644 --- a/tests/wpt/metadata/html/dom/reflection-sections.html.ini +++ b/tests/wpt/metadata/html/dom/reflection-sections.html.ini @@ -975,135 +975,6 @@ [body.aLink: IDL set to object "test-valueOf" followed by IDL get] expected: FAIL - [body.bgColor: typeof IDL attribute] - expected: FAIL - - [body.bgColor: IDL get with DOM attribute unset] - expected: FAIL - - [body.bgColor: setAttribute() to "" followed by IDL get] - expected: FAIL - - [body.bgColor: 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.bgColor: setAttribute() to undefined followed by IDL get] - expected: FAIL - - [body.bgColor: setAttribute() to 7 followed by IDL get] - expected: FAIL - - [body.bgColor: setAttribute() to 1.5 followed by IDL get] - expected: FAIL - - [body.bgColor: setAttribute() to true followed by IDL get] - expected: FAIL - - [body.bgColor: setAttribute() to false followed by IDL get] - expected: FAIL - - [body.bgColor: setAttribute() to object "[object Object\]" followed by IDL get] - expected: FAIL - - [body.bgColor: setAttribute() to NaN followed by IDL get] - expected: FAIL - - [body.bgColor: setAttribute() to Infinity followed by IDL get] - expected: FAIL - - [body.bgColor: setAttribute() to -Infinity followed by IDL get] - expected: FAIL - - [body.bgColor: setAttribute() to "\\0" followed by IDL get] - expected: FAIL - - [body.bgColor: setAttribute() to null followed by IDL get] - expected: FAIL - - [body.bgColor: setAttribute() to object "test-toString" followed by IDL get] - expected: FAIL - - [body.bgColor: setAttribute() to object "test-valueOf" followed by IDL get] - expected: FAIL - - [body.bgColor: IDL set to "" followed by getAttribute()] - expected: FAIL - - [body.bgColor: 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.bgColor: IDL set to undefined followed by getAttribute()] - expected: FAIL - - [body.bgColor: IDL set to undefined followed by IDL get] - expected: FAIL - - [body.bgColor: IDL set to 7 followed by getAttribute()] - expected: FAIL - - [body.bgColor: IDL set to 7 followed by IDL get] - expected: FAIL - - [body.bgColor: IDL set to 1.5 followed by getAttribute()] - expected: FAIL - - [body.bgColor: IDL set to 1.5 followed by IDL get] - expected: FAIL - - [body.bgColor: IDL set to true followed by getAttribute()] - expected: FAIL - - [body.bgColor: IDL set to true followed by IDL get] - expected: FAIL - - [body.bgColor: IDL set to false followed by getAttribute()] - expected: FAIL - - [body.bgColor: IDL set to false followed by IDL get] - expected: FAIL - - [body.bgColor: IDL set to object "[object Object\]" followed by getAttribute()] - expected: FAIL - - [body.bgColor: IDL set to object "[object Object\]" followed by IDL get] - expected: FAIL - - [body.bgColor: IDL set to NaN followed by getAttribute()] - expected: FAIL - - [body.bgColor: IDL set to NaN followed by IDL get] - expected: FAIL - - [body.bgColor: IDL set to Infinity followed by getAttribute()] - expected: FAIL - - [body.bgColor: IDL set to Infinity followed by IDL get] - expected: FAIL - - [body.bgColor: IDL set to -Infinity followed by getAttribute()] - expected: FAIL - - [body.bgColor: IDL set to -Infinity followed by IDL get] - expected: FAIL - - [body.bgColor: IDL set to "\\0" followed by getAttribute()] - expected: FAIL - - [body.bgColor: IDL set to null followed by getAttribute()] - expected: FAIL - - [body.bgColor: IDL set to null followed by IDL get] - expected: FAIL - - [body.bgColor: IDL set to object "test-toString" followed by getAttribute()] - expected: FAIL - - [body.bgColor: IDL set to object "test-toString" followed by IDL get] - expected: FAIL - - [body.bgColor: IDL set to object "test-valueOf" followed by IDL get] - expected: FAIL - [body.background: typeof IDL attribute] expected: FAIL @@ -13302,135 +13173,6 @@ [#document.alinkColor (): IDL set to object "test-valueOf" followed by IDL get] expected: FAIL - [#document.bgColor (): typeof IDL attribute] - expected: FAIL - - [#document.bgColor (): IDL get with DOM attribute unset] - expected: FAIL - - [#document.bgColor (): setAttribute() to "" followed by IDL get] - expected: FAIL - - [#document.bgColor (): 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 - - [#document.bgColor (): setAttribute() to undefined followed by IDL get] - expected: FAIL - - [#document.bgColor (): setAttribute() to 7 followed by IDL get] - expected: FAIL - - [#document.bgColor (): setAttribute() to 1.5 followed by IDL get] - expected: FAIL - - [#document.bgColor (): setAttribute() to true followed by IDL get] - expected: FAIL - - [#document.bgColor (): setAttribute() to false followed by IDL get] - expected: FAIL - - [#document.bgColor (): setAttribute() to object "[object Object\]" followed by IDL get] - expected: FAIL - - [#document.bgColor (): setAttribute() to NaN followed by IDL get] - expected: FAIL - - [#document.bgColor (): setAttribute() to Infinity followed by IDL get] - expected: FAIL - - [#document.bgColor (): setAttribute() to -Infinity followed by IDL get] - expected: FAIL - - [#document.bgColor (): setAttribute() to "\\0" followed by IDL get] - expected: FAIL - - [#document.bgColor (): setAttribute() to null followed by IDL get] - expected: FAIL - - [#document.bgColor (): setAttribute() to object "test-toString" followed by IDL get] - expected: FAIL - - [#document.bgColor (): setAttribute() to object "test-valueOf" followed by IDL get] - expected: FAIL - - [#document.bgColor (): IDL set to "" followed by getAttribute()] - expected: FAIL - - [#document.bgColor (): 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 - - [#document.bgColor (): IDL set to undefined followed by getAttribute()] - expected: FAIL - - [#document.bgColor (): IDL set to undefined followed by IDL get] - expected: FAIL - - [#document.bgColor (): IDL set to 7 followed by getAttribute()] - expected: FAIL - - [#document.bgColor (): IDL set to 7 followed by IDL get] - expected: FAIL - - [#document.bgColor (): IDL set to 1.5 followed by getAttribute()] - expected: FAIL - - [#document.bgColor (): IDL set to 1.5 followed by IDL get] - expected: FAIL - - [#document.bgColor (): IDL set to true followed by getAttribute()] - expected: FAIL - - [#document.bgColor (): IDL set to true followed by IDL get] - expected: FAIL - - [#document.bgColor (): IDL set to false followed by getAttribute()] - expected: FAIL - - [#document.bgColor (): IDL set to false followed by IDL get] - expected: FAIL - - [#document.bgColor (): IDL set to object "[object Object\]" followed by getAttribute()] - expected: FAIL - - [#document.bgColor (): IDL set to object "[object Object\]" followed by IDL get] - expected: FAIL - - [#document.bgColor (): IDL set to NaN followed by getAttribute()] - expected: FAIL - - [#document.bgColor (): IDL set to NaN followed by IDL get] - expected: FAIL - - [#document.bgColor (): IDL set to Infinity followed by getAttribute()] - expected: FAIL - - [#document.bgColor (): IDL set to Infinity followed by IDL get] - expected: FAIL - - [#document.bgColor (): IDL set to -Infinity followed by getAttribute()] - expected: FAIL - - [#document.bgColor (): IDL set to -Infinity followed by IDL get] - expected: FAIL - - [#document.bgColor (): IDL set to "\\0" followed by getAttribute()] - expected: FAIL - - [#document.bgColor (): IDL set to null followed by getAttribute()] - expected: FAIL - - [#document.bgColor (): IDL set to null followed by IDL get] - expected: FAIL - - [#document.bgColor (): IDL set to object "test-toString" followed by getAttribute()] - expected: FAIL - - [#document.bgColor (): IDL set to object "test-toString" followed by IDL get] - expected: FAIL - - [#document.bgColor (): IDL set to object "test-valueOf" followed by IDL get] - expected: FAIL - [meta.itemValue (): typeof IDL attribute] expected: FAIL diff --git a/tests/wpt/metadata/html/obsolete/requirements-for-implementations/other-elements-attributes-and-apis/document-color-02.html.ini b/tests/wpt/metadata/html/obsolete/requirements-for-implementations/other-elements-attributes-and-apis/document-color-02.html.ini index 1d12f3000c1..c06048bc398 100644 --- a/tests/wpt/metadata/html/obsolete/requirements-for-implementations/other-elements-attributes-and-apis/document-color-02.html.ini +++ b/tests/wpt/metadata/html/obsolete/requirements-for-implementations/other-elements-attributes-and-apis/document-color-02.html.ini @@ -3,9 +3,6 @@ [document: fg/bg/link/vlink/alink-color 1] expected: FAIL - [document: fg/bg/link/vlink/alink-color 2] - expected: FAIL - [document: fg/bg/link/vlink/alink-color 3] expected: FAIL diff --git a/tests/wpt/metadata/html/obsolete/requirements-for-implementations/other-elements-attributes-and-apis/document-color-03.html.ini b/tests/wpt/metadata/html/obsolete/requirements-for-implementations/other-elements-attributes-and-apis/document-color-03.html.ini index 48c5e4225af..f89ad9e82df 100644 --- a/tests/wpt/metadata/html/obsolete/requirements-for-implementations/other-elements-attributes-and-apis/document-color-03.html.ini +++ b/tests/wpt/metadata/html/obsolete/requirements-for-implementations/other-elements-attributes-and-apis/document-color-03.html.ini @@ -3,9 +3,6 @@ [document: fg/bg/link/vlink/alink-color 1] expected: FAIL - [document: fg/bg/link/vlink/alink-color 2] - expected: FAIL - [document: fg/bg/link/vlink/alink-color 3] expected: FAIL diff --git a/tests/wpt/metadata/html/obsolete/requirements-for-implementations/other-elements-attributes-and-apis/document-color-04.html.ini b/tests/wpt/metadata/html/obsolete/requirements-for-implementations/other-elements-attributes-and-apis/document-color-04.html.ini index 8ecd1f402c1..9a926969914 100644 --- a/tests/wpt/metadata/html/obsolete/requirements-for-implementations/other-elements-attributes-and-apis/document-color-04.html.ini +++ b/tests/wpt/metadata/html/obsolete/requirements-for-implementations/other-elements-attributes-and-apis/document-color-04.html.ini @@ -3,9 +3,6 @@ [document: fg/bg/link/vlink/alink-color 1] expected: FAIL - [document: fg/bg/link/vlink/alink-color 2] - expected: FAIL - [document: fg/bg/link/vlink/alink-color 3] expected: FAIL