From b9f7aa468610b7091eb7e3cdc34a085f7931302d Mon Sep 17 00:00:00 2001 From: paavininanda Date: Tue, 13 Feb 2018 14:51:20 +0530 Subject: [PATCH] Adding Name and SetName functions for window --- components/script/dom/htmliframeelement.rs | 21 ++++++++++++++ .../dom/webidls/HTMLIFrameElement.webidl | 5 ++-- components/script/dom/webidls/Window.webidl | 3 +- components/script/dom/window.rs | 10 +++++++ components/script/dom/windowproxy.rs | 14 ++++++++++ ...llscreen-enabled-cross-origin.sub.html.ini | 12 +------- .../unset_context_name-1.html.ini | 5 ---- .../window-properties.html.ini | 3 -- .../choose-default-002.html.ini | 5 ---- .../wpt/metadata/html/dom/interfaces.html.ini | 9 ------ .../uniforms/gl-uniformmatrix4fv.html.ini | 28 ++++++++++++++++++- 11 files changed, 76 insertions(+), 39 deletions(-) delete mode 100644 tests/wpt/metadata/html/browsers/browsing-the-web/history-traversal/unset_context_name-1.html.ini delete mode 100644 tests/wpt/metadata/html/browsers/windows/browsing-context-names/choose-default-002.html.ini diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index b03cfdce07ee..41bb2a23e6ae 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -457,6 +457,22 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement { make_getter!(FrameBorder, "frameborder"); // https://html.spec.whatwg.org/multipage/#other-elements,-attributes-and-apis:attr-iframe-frameborder make_setter!(SetFrameBorder, "frameborder"); + + // https://html.spec.whatwg.org/multipage/#dom-iframe-name + fn SetName(&self, name: DOMString) { + if let Some(window) = self.GetContentWindow() { + window.set_name(name) + } + } + + // https://html.spec.whatwg.org/multipage/#dom-iframe-name + fn Name(&self) -> DOMString { + if let Some(window) = self.GetContentWindow() { + window.get_name() + } else { + DOMString::new() + } + } } impl VirtualMethods for HTMLIFrameElement { @@ -498,6 +514,11 @@ impl VirtualMethods for HTMLIFrameElement { self.process_the_iframe_attributes(ProcessingMode::NotFirstTime); } }, + &local_name!("name") => { + let new_value = mutation.new_value(attr); + let value = new_value.as_ref().map_or("", |v| &v); + self.SetName(DOMString::from(value.to_owned())); + }, _ => {}, } } diff --git a/components/script/dom/webidls/HTMLIFrameElement.webidl b/components/script/dom/webidls/HTMLIFrameElement.webidl index fec8768e8e8b..db32f2a5174c 100644 --- a/components/script/dom/webidls/HTMLIFrameElement.webidl +++ b/components/script/dom/webidls/HTMLIFrameElement.webidl @@ -10,9 +10,8 @@ interface HTMLIFrameElement : HTMLElement { // [CEReactions] // attribute DOMString srcdoc; - // https://github.com/servo/servo/issues/14453 - // [CEReactions] - // attribute DOMString name; + [CEReactions] + attribute DOMString name; [SameObject, PutForwards=value] readonly attribute DOMTokenList sandbox; diff --git a/components/script/dom/webidls/Window.webidl b/components/script/dom/webidls/Window.webidl index d6da05480cfc..c2954c1044da 100644 --- a/components/script/dom/webidls/Window.webidl +++ b/components/script/dom/webidls/Window.webidl @@ -10,8 +10,7 @@ [BinaryName="Self_", Replaceable] readonly attribute WindowProxy self; [Unforgeable] readonly attribute Document document; - // https://github.com/servo/servo/issues/14453 - // attribute DOMString name; + attribute DOMString name; [/*PutForwards=href, */Unforgeable] readonly attribute Location location; readonly attribute History history; diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index a564d00ee5f5..f4cba0aac1f4 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -1019,6 +1019,16 @@ impl WindowMethods for Window { fn TestRunner(&self) -> DomRoot { self.test_runner.or_init(|| TestRunner::new(self.upcast())) } + + // https://html.spec.whatwg.org/multipage/#dom-name + fn SetName(&self, name: DOMString) { + self.window_proxy().set_name(name); + } + + // https://html.spec.whatwg.org/multipage/#dom-name + fn Name(&self) -> DOMString { + self.window_proxy().get_name() + } } impl Window { diff --git a/components/script/dom/windowproxy.rs b/components/script/dom/windowproxy.rs index 1ab615c9824f..55f136183613 100644 --- a/components/script/dom/windowproxy.rs +++ b/components/script/dom/windowproxy.rs @@ -2,12 +2,14 @@ * 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/. */ +use dom::bindings::cell::DomRefCell; use dom::bindings::conversions::{ToJSValConvertible, root_from_handleobject}; use dom::bindings::error::{Error, throw_dom_exception}; use dom::bindings::inheritance::Castable; use dom::bindings::proxyhandler::{fill_property_descriptor, get_property_descriptor}; use dom::bindings::reflector::{DomObject, Reflector}; use dom::bindings::root::{Dom, DomRoot, RootedReference}; +use dom::bindings::str::DOMString; use dom::bindings::trace::JSTraceable; use dom::bindings::utils::{WindowProxyHandler, get_array_index_from_id, AsVoidPtr}; use dom::dissimilaroriginwindow::DissimilarOriginWindow; @@ -55,6 +57,8 @@ pub struct WindowProxy { /// In the case that this is a top-level window, this is our id. top_level_browsing_context_id: TopLevelBrowsingContextId, + /// The name of the browsing context + name: DomRefCell, /// The pipeline id of the currently active document. /// May be None, when the currently active document is in another script thread. /// We do not try to keep the pipeline id for documents in other threads, @@ -80,10 +84,12 @@ impl WindowProxy { parent: Option<&WindowProxy>) -> WindowProxy { + let name = frame_element.map_or(DOMString::new(), |e| e.get_string_attribute(&local_name!("name"))); WindowProxy { reflector: Reflector::new(), browsing_context_id: browsing_context_id, top_level_browsing_context_id: top_level_browsing_context_id, + name: DomRefCell::new(name), currently_active: Cell::new(currently_active), discarded: Cell::new(false), frame_element: frame_element.map(Dom::from_ref), @@ -276,6 +282,14 @@ impl WindowProxy { pub fn currently_active(&self) -> Option { self.currently_active.get() } + + pub fn get_name(&self) -> DOMString { + self.name.borrow().clone() + } + + pub fn set_name(&self, name: DOMString) { + *self.name.borrow_mut() = name; + } } #[allow(unsafe_code)] diff --git a/tests/wpt/metadata/fullscreen/api/document-fullscreen-enabled-cross-origin.sub.html.ini b/tests/wpt/metadata/fullscreen/api/document-fullscreen-enabled-cross-origin.sub.html.ini index 2fc8b31f6c0f..d8dd046621fa 100644 --- a/tests/wpt/metadata/fullscreen/api/document-fullscreen-enabled-cross-origin.sub.html.ini +++ b/tests/wpt/metadata/fullscreen/api/document-fullscreen-enabled-cross-origin.sub.html.ini @@ -1,15 +1,5 @@ [document-fullscreen-enabled-cross-origin.sub.html] type: testharness - expected: TIMEOUT - [Fullscreen enabled test: same-origin-default] - expected: NOTRUN - - [Fullscreen enabled test: same-origin-allow] - expected: NOTRUN - - [Fullscreen enabled test: cross-origin-default] - expected: NOTRUN - [Fullscreen enabled test: cross-origin-allow] - expected: NOTRUN + expected: FAIL diff --git a/tests/wpt/metadata/html/browsers/browsing-the-web/history-traversal/unset_context_name-1.html.ini b/tests/wpt/metadata/html/browsers/browsing-the-web/history-traversal/unset_context_name-1.html.ini deleted file mode 100644 index fef85273b998..000000000000 --- a/tests/wpt/metadata/html/browsers/browsing-the-web/history-traversal/unset_context_name-1.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[unset_context_name-1.html] - type: testharness - [window.name after navigating to a different origin] - expected: FAIL - diff --git a/tests/wpt/metadata/html/browsers/the-window-object/window-properties.html.ini b/tests/wpt/metadata/html/browsers/the-window-object/window-properties.html.ini index 905abfcd4921..0f4e7c4c09ca 100644 --- a/tests/wpt/metadata/html/browsers/the-window-object/window-properties.html.ini +++ b/tests/wpt/metadata/html/browsers/the-window-object/window-properties.html.ini @@ -27,9 +27,6 @@ [Window readonly attribute: applicationCache] expected: FAIL - [Window attribute: name] - expected: FAIL - [Window attribute: opener] expected: FAIL diff --git a/tests/wpt/metadata/html/browsers/windows/browsing-context-names/choose-default-002.html.ini b/tests/wpt/metadata/html/browsers/windows/browsing-context-names/choose-default-002.html.ini deleted file mode 100644 index d8f7385bac6b..000000000000 --- a/tests/wpt/metadata/html/browsers/windows/browsing-context-names/choose-default-002.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[choose-default-002.html] - type: testharness - [The current browsing context must be chosen if the given name is empty string] - expected: FAIL - diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini index 983a2f63ba0c..13a6c0a31cd2 100644 --- a/tests/wpt/metadata/html/dom/interfaces.html.ini +++ b/tests/wpt/metadata/html/dom/interfaces.html.ini @@ -1230,9 +1230,6 @@ [HTMLIFrameElement interface: attribute srcdoc] expected: FAIL - [HTMLIFrameElement interface: attribute name] - expected: FAIL - [HTMLIFrameElement interface: attribute seamless] expected: FAIL @@ -4275,9 +4272,6 @@ [Window interface: existence and properties of interface prototype object] expected: FAIL - [Window interface: attribute name] - expected: FAIL - [Window interface: attribute locationbar] expected: FAIL @@ -13542,9 +13536,6 @@ [Window interface: window must inherit property "self" with the proper type] expected: FAIL - [Window interface: window must inherit property "name" with the proper type] - expected: FAIL - [Window interface: window must inherit property "locationbar" with the proper type] expected: FAIL diff --git a/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/uniforms/gl-uniformmatrix4fv.html.ini b/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/uniforms/gl-uniformmatrix4fv.html.ini index e30e0715bd89..6558b7e815f2 100644 --- a/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/uniforms/gl-uniformmatrix4fv.html.ini +++ b/tests/wpt/mozilla/meta/webgl/conformance-1.0.3/conformance/uniforms/gl-uniformmatrix4fv.html.ini @@ -1,9 +1,35 @@ [gl-uniformmatrix4fv.html] type: testharness - expected: ERROR [WebGL test #0: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).] expected: FAIL [WebGL uniformMatrix Conformance Tests] expected: FAIL + [WebGL test #0: getError expected: INVALID_VALUE. Was INVALID_OPERATION : should fail with insufficient array size for uniformMatrix2fv] + expected: FAIL + + [WebGL test #2: getError expected: INVALID_VALUE. Was INVALID_OPERATION : should fail with more than 1 array size for uniformMatrix2fv] + expected: FAIL + + [WebGL test #4: getError expected: INVALID_VALUE. Was NO_ERROR : uniformMatrix2fv should return INVALID_VALUE with transpose = true] + expected: FAIL + + [WebGL test #5: getError expected: INVALID_VALUE. Was INVALID_OPERATION : should fail with insufficient array size for uniformMatrix3fv] + expected: FAIL + + [WebGL test #7: getError expected: INVALID_VALUE. Was INVALID_OPERATION : should fail with more than 1 array size for uniformMatrix3fv] + expected: FAIL + + [WebGL test #9: getError expected: INVALID_VALUE. Was NO_ERROR : uniformMatrix3fv should return INVALID_VALUE with transpose = true] + expected: FAIL + + [WebGL test #10: getError expected: INVALID_VALUE. Was INVALID_OPERATION : should fail with insufficient array size for uniformMatrix4fv] + expected: FAIL + + [WebGL test #12: getError expected: INVALID_VALUE. Was INVALID_OPERATION : should fail with more than 1 array size for uniformMatrix4fv] + expected: FAIL + + [WebGL test #14: getError expected: INVALID_VALUE. Was NO_ERROR : uniformMatrix4fv should return INVALID_VALUE with transpose = true] + expected: FAIL +