Skip to content

Commit

Permalink
Adding Name and SetName functions for window
Browse files Browse the repository at this point in the history
  • Loading branch information
paavininanda committed Feb 26, 2018
1 parent b1d3d6f commit b9f7aa4
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 39 deletions.
21 changes: 21 additions & 0 deletions components/script/dom/htmliframeelement.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()));
},
_ => {},
}
}
Expand Down
5 changes: 2 additions & 3 deletions components/script/dom/webidls/HTMLIFrameElement.webidl
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions components/script/dom/webidls/Window.webidl
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions components/script/dom/window.rs
Expand Up @@ -1019,6 +1019,16 @@ impl WindowMethods for Window {
fn TestRunner(&self) -> DomRoot<TestRunner> {
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 {
Expand Down
14 changes: 14 additions & 0 deletions components/script/dom/windowproxy.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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<DOMString>,
/// 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,
Expand All @@ -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),
Expand Down Expand Up @@ -276,6 +282,14 @@ impl WindowProxy {
pub fn currently_active(&self) -> Option<PipelineId> {
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)]
Expand Down
@@ -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

This file was deleted.

Expand Up @@ -27,9 +27,6 @@
[Window readonly attribute: applicationCache]
expected: FAIL

[Window attribute: name]
expected: FAIL

[Window attribute: opener]
expected: FAIL

Expand Down

This file was deleted.

9 changes: 0 additions & 9 deletions tests/wpt/metadata/html/dom/interfaces.html.ini
Expand Up @@ -1230,9 +1230,6 @@
[HTMLIFrameElement interface: attribute srcdoc]
expected: FAIL

[HTMLIFrameElement interface: attribute name]
expected: FAIL

[HTMLIFrameElement interface: attribute seamless]
expected: FAIL

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
@@ -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

0 comments on commit b9f7aa4

Please sign in to comment.