Auto merge of #20036 - paavininanda:BrowsingNames, r=jdm

Browsing context names

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix https://github.com/servo/servo/issues/14453

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20036)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-02-25 21:26:08 -05:00 committed by GitHub
commit 7de2043b9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 76 additions and 39 deletions

View file

@ -457,6 +457,22 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
make_getter!(FrameBorder, "frameborder"); make_getter!(FrameBorder, "frameborder");
// https://html.spec.whatwg.org/multipage/#other-elements,-attributes-and-apis:attr-iframe-frameborder // https://html.spec.whatwg.org/multipage/#other-elements,-attributes-and-apis:attr-iframe-frameborder
make_setter!(SetFrameBorder, "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 { impl VirtualMethods for HTMLIFrameElement {
@ -498,6 +514,11 @@ impl VirtualMethods for HTMLIFrameElement {
self.process_the_iframe_attributes(ProcessingMode::NotFirstTime); 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()));
},
_ => {}, _ => {},
} }
} }

View file

@ -10,9 +10,8 @@ interface HTMLIFrameElement : HTMLElement {
// [CEReactions] // [CEReactions]
// attribute DOMString srcdoc; // attribute DOMString srcdoc;
// https://github.com/servo/servo/issues/14453 [CEReactions]
// [CEReactions] attribute DOMString name;
// attribute DOMString name;
[SameObject, PutForwards=value] [SameObject, PutForwards=value]
readonly attribute DOMTokenList sandbox; readonly attribute DOMTokenList sandbox;

View file

@ -10,8 +10,7 @@
[BinaryName="Self_", Replaceable] readonly attribute WindowProxy self; [BinaryName="Self_", Replaceable] readonly attribute WindowProxy self;
[Unforgeable] readonly attribute Document document; [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; [/*PutForwards=href, */Unforgeable] readonly attribute Location location;
readonly attribute History history; readonly attribute History history;

View file

@ -1025,6 +1025,16 @@ impl WindowMethods for Window {
fn TestRunner(&self) -> DomRoot<TestRunner> { fn TestRunner(&self) -> DomRoot<TestRunner> {
self.test_runner.or_init(|| TestRunner::new(self.upcast())) 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 { impl Window {

View file

@ -2,12 +2,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * 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::conversions::{ToJSValConvertible, root_from_handleobject};
use dom::bindings::error::{Error, throw_dom_exception}; use dom::bindings::error::{Error, throw_dom_exception};
use dom::bindings::inheritance::Castable; use dom::bindings::inheritance::Castable;
use dom::bindings::proxyhandler::{fill_property_descriptor, get_property_descriptor}; use dom::bindings::proxyhandler::{fill_property_descriptor, get_property_descriptor};
use dom::bindings::reflector::{DomObject, Reflector}; use dom::bindings::reflector::{DomObject, Reflector};
use dom::bindings::root::{Dom, DomRoot, RootedReference}; use dom::bindings::root::{Dom, DomRoot, RootedReference};
use dom::bindings::str::DOMString;
use dom::bindings::trace::JSTraceable; use dom::bindings::trace::JSTraceable;
use dom::bindings::utils::{WindowProxyHandler, get_array_index_from_id, AsVoidPtr}; use dom::bindings::utils::{WindowProxyHandler, get_array_index_from_id, AsVoidPtr};
use dom::dissimilaroriginwindow::DissimilarOriginWindow; 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. /// In the case that this is a top-level window, this is our id.
top_level_browsing_context_id: TopLevelBrowsingContextId, top_level_browsing_context_id: TopLevelBrowsingContextId,
/// The name of the browsing context
name: DomRefCell<DOMString>,
/// The pipeline id of the currently active document. /// The pipeline id of the currently active document.
/// May be None, when the currently active document is in another script thread. /// 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, /// We do not try to keep the pipeline id for documents in other threads,
@ -80,10 +84,12 @@ impl WindowProxy {
parent: Option<&WindowProxy>) parent: Option<&WindowProxy>)
-> WindowProxy -> WindowProxy
{ {
let name = frame_element.map_or(DOMString::new(), |e| e.get_string_attribute(&local_name!("name")));
WindowProxy { WindowProxy {
reflector: Reflector::new(), reflector: Reflector::new(),
browsing_context_id: browsing_context_id, browsing_context_id: browsing_context_id,
top_level_browsing_context_id: top_level_browsing_context_id, top_level_browsing_context_id: top_level_browsing_context_id,
name: DomRefCell::new(name),
currently_active: Cell::new(currently_active), currently_active: Cell::new(currently_active),
discarded: Cell::new(false), discarded: Cell::new(false),
frame_element: frame_element.map(Dom::from_ref), frame_element: frame_element.map(Dom::from_ref),
@ -276,6 +282,14 @@ impl WindowProxy {
pub fn currently_active(&self) -> Option<PipelineId> { pub fn currently_active(&self) -> Option<PipelineId> {
self.currently_active.get() 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)] #[allow(unsafe_code)]

View file

@ -1,15 +1,5 @@
[document-fullscreen-enabled-cross-origin.sub.html] [document-fullscreen-enabled-cross-origin.sub.html]
type: testharness 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] [Fullscreen enabled test: cross-origin-allow]
expected: NOTRUN expected: FAIL

View file

@ -1,5 +0,0 @@
[unset_context_name-1.html]
type: testharness
[window.name after navigating to a different origin]
expected: FAIL

View file

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

View file

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

View file

@ -1230,9 +1230,6 @@
[HTMLIFrameElement interface: attribute srcdoc] [HTMLIFrameElement interface: attribute srcdoc]
expected: FAIL expected: FAIL
[HTMLIFrameElement interface: attribute name]
expected: FAIL
[HTMLIFrameElement interface: attribute seamless] [HTMLIFrameElement interface: attribute seamless]
expected: FAIL expected: FAIL
@ -4275,9 +4272,6 @@
[Window interface: existence and properties of interface prototype object] [Window interface: existence and properties of interface prototype object]
expected: FAIL expected: FAIL
[Window interface: attribute name]
expected: FAIL
[Window interface: attribute locationbar] [Window interface: attribute locationbar]
expected: FAIL expected: FAIL
@ -13542,9 +13536,6 @@
[Window interface: window must inherit property "self" with the proper type] [Window interface: window must inherit property "self" with the proper type]
expected: FAIL 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] [Window interface: window must inherit property "locationbar" with the proper type]
expected: FAIL expected: FAIL

View file

@ -1,9 +1,35 @@
[gl-uniformmatrix4fv.html] [gl-uniformmatrix4fv.html]
type: testharness type: testharness
expected: ERROR
[WebGL test #0: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).] [WebGL test #0: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
expected: FAIL expected: FAIL
[WebGL uniformMatrix Conformance Tests] [WebGL uniformMatrix Conformance Tests]
expected: FAIL 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