Skip to content

Browsing context names - #20036

Merged
bors-servo merged 1 commit into
servo:masterfrom
paavininanda:BrowsingNames
Feb 26, 2018
Merged

bors-servo merged 1 commit into
servo:masterfrom
paavininanda:BrowsingNames

Conversation

@paavininanda

@paavininanda paavininanda commented Feb 13, 2018 •

Copy link
Copy Markdown
Contributor

  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

@highfive

Copy link
Copy Markdown

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @metajack (or someone else) soon.

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/htmliframeelement.rs, components/script/dom/htmltextareaelement.rs, components/script/dom/windowproxy.rs, components/script/dom/webidls/HTMLIFrameElement.webidl, components/script/dom/window.rs and 1 more
  • @fitzgen: components/script/dom/htmliframeelement.rs, components/script/dom/htmltextareaelement.rs, components/script/dom/windowproxy.rs, components/script/dom/webidls/HTMLIFrameElement.webidl, components/script/dom/window.rs and 1 more
  • @KiChjang: components/script/dom/htmliframeelement.rs, components/script/dom/htmltextareaelement.rs, components/script/dom/windowproxy.rs, components/script/dom/webidls/HTMLIFrameElement.webidl, components/script/dom/window.rs and 1 more

@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Feb 13, 2018
@paavininanda

Copy link
Copy Markdown
Contributor Author

r? @jdm

@highfive highfive assigned jdm and unassigned metajack Feb 13, 2018
@paavininanda paavininanda changed the title Browsing names Browsing context names Feb 13, 2018
@bors-servo

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #19975) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Feb 13, 2018
@paavininanda
paavininanda force-pushed the BrowsingNames branch 2 times, most recently from 276d7cd to b2fc4e0 Compare February 13, 2018 15:19

@cbrewster cbrewster left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!
There are some changes that need to made to make sure browsing context names are updated in all the appropriate places (windows/iframes in other script threads)

// attribute DOMString srcdoc;

// https://github.com/servo/servo/issues/14453
// [CEReactions]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncomment the [CEReactions] annotation here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still commented out.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read it wrong :/ long back.

Comment thread components/script/dom/window.rs Outdated
self.test_runner.or_init(|| TestRunner::new(self.upcast()))
}

// https://fetch.spec.whatwg.org/multipage/browsers.html#browsing-context-names

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be https://html.spec.whatwg.org/multipage/#dom-name

}

// https://fetch.spec.whatwg.org/multipage/browsers.html#browsing-context-names
fn Name(&self) -> DOMString {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be https://html.spec.whatwg.org/multipage/#dom-name

// https://html.spec.whatwg.org/multipage/#other-elements,-attributes-and-apis:attr-iframe-frameborder
make_setter!(SetFrameBorder, "frameborder");

fn SetName(&self, name: DOMString) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add spec comment: https://html.spec.whatwg.org/multipage/#dom-iframe-name

}
}

fn Name(&self) -> DOMString {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add spec comment: https://html.spec.whatwg.org/multipage/#dom-iframe-name

make_setter!(SetFrameBorder, "frameborder");

fn SetName(&self, name: DOMString) {
window_from_node(self).window_proxy().set_name(name.clone());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably don't want to do this as it would set the name of the browsing context of the window that contains the iframe. We just want to set the name of the content window's browsing context. (The browsing context inside the iframe).

Note: If the child window is on a different script thread, we must send a message to the constellation which will then send a message back to the script thread with child window and update the name there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So do we need to send a message to constellation using script_traits::ScriptMsg ? If yes then which method of all the available methods is to be used ?

Comment thread components/script/dom/window.rs Outdated
// https://fetch.spec.whatwg.org/multipage/browsers.html#browsing-context-names
fn SetName(&self, name: DOMString) {
self.window_proxy().set_name(name.clone());
if let Some(parent) = self.window_proxy().parent() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe we should be setting the parent browsing context's name, just the browsing context of this window.

top_level_browsing_context_id: TopLevelBrowsingContextId,

/// The name of the browsing context
name: DomRefCell<DOMString>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is something that should be stored on the WindowProxy or if it will need to be stored in the constellation on the BrowsingContext. cc @asajeffrey @jdm

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment in the issue said so 😅 #14453

@cbrewster cbrewster Feb 13, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's quite possible it should be stored here, just wanted to double check 😄

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect we can get away with only storing the name in script/, rather than duplicating it in the constellation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdm: not sure about that, what about when an existing bc has a document opened in a new (to it) script thread?

@cbrewster cbrewster added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Feb 13, 2018
@asajeffrey

Copy link
Copy Markdown
Contributor

Hi there, this is all looking good for the case of immutable access to the browsing context name.

The problem as mentioned by @cbrewster is the mutable case, since this would involve sending a message to the constellation to notify it of the name change. Moreover, the name change is expected to be synchronous, which is probably going to make the logic quite torturous.

Perhaps the thing to do is just implement the immutable case, mark the attribute read-only in the webidl, with a comment referencing an issue to implement setting the BC name?

Seem like a good idea? @paavininanda @jdm?

@jdm

jdm commented Feb 14, 2018

Copy link
Copy Markdown
Member

https://mozilla.logbot.info/servo/20180214#c14302329-c14302486 is a discussion I had with asajeffrey. I think they're right that we should put off the message-sending part of this; it will require a bit more thought to make sure we're not missing anything. We don't need to make the name read-only, though; for the case we care about the most, the implementation that modifies the name stored in the window proxy should work for our same-origin iframe case.

@jdm jdm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One other change that we'll need (to support changing the name attribute on an iframe):

  • in attribute_mutated in htmliframeelement.rs, add a branch for the "name" attribute and do:
let value = mutation.new_value(attr).map_or("", |v| &v);
self.SetName(DOMString::from(value.to_owned()));

pub struct HTMLIFrameElement {
htmlelement: HTMLElement,
top_level_browsing_context_id: Cell<Option<TopLevelBrowsingContextId>>,
name: DomRefCell<DOMString>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not need to store a name in this data structure.

}

fn Name(&self) -> DOMString {
window_from_node(self).window_proxy().get_name()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use self.GetContentWindow(), and if it exists we can call get_name() on it.

Comment thread components/script/dom/windowproxy.rs Outdated
reflector: Reflector::new(),
browsing_context_id: browsing_context_id,
top_level_browsing_context_id: top_level_browsing_context_id,
name: DomRefCell::new(DOMString::new()),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To support the case of <iframe src="whatever.html" name="hello">, we need to do this:

let name = frame_element.map_or(DOMString::new(), |e| e.get_string_attribute(&local_name!("name")));
...
name: DomRefCell::new(name),

@paavininanda

Copy link
Copy Markdown
Contributor Author

let value = mutation.new_value(attr).map_or("", |v| &v);

This is giving an error -
borrowed value does not live long enough
v dropped here while still borrowed

@jdm

jdm commented Feb 15, 2018

Copy link
Copy Markdown
Member

Try

let new_value = mutation.new_value(attr);
let value = new_value.as_ref().map_or("", |v| &v);

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Feb 15, 2018

@jdm jdm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there! Once the [CEReactions] attribute is added, we can run this through the tryserver and hopefully get a long list of new test results!

// https://github.com/servo/servo/issues/14453
// [CEReactions]
// attribute DOMString name;
attribute DOMString name;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to keep the [CEReactions] attribute.

// https://html.spec.whatwg.org/multipage/#dom-iframe-name
fn SetName(&self, name: DOMString) {
if let Some(window) = self.GetContentWindow() {
let mut child_window = &*window;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line actually necessary? If it is, we should at least be able to remove the mut.

// https://html.spec.whatwg.org/multipage/#dom-iframe-name
fn Name(&self) -> DOMString {
if let Some(window) = self.GetContentWindow() {
let mut child_window = &*window;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as previous.

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-rebase There are merge conflict errors. labels Feb 22, 2018
@paavininanda

Copy link
Copy Markdown
Contributor Author

Didn't work, still getting the same error.

@jdm

jdm commented Feb 23, 2018

Copy link
Copy Markdown
Member

Oh! I ran it locally and realized that the test is written poorly (since it uses JS strict mode but does not declare var name before assigning it), but it happens to work in browsers because of the name attribute on the Window object. That means that the test was not working at all before these changes, and now is showing us the actual test results that we care about. That means you can go ahead and save the logs of running the tests and update the expected test results:
wget http://build.servo.org/builders/linux-rel-wpt/builds/8021/steps/test__1/logs/test-wpt.log/text -o log1 && ./mach update-wpt log1 and wget http://build.servo.org/builders/linux-rel-css/builds/8007/steps/test/logs/test-wpt.log/ -o log2 && ./mach update-wpt log2.

@jdm

jdm commented Feb 23, 2018

Copy link
Copy Markdown
Member

Oh, and you can undo the change to gl-uniformmatrix4fv.html before committing.

@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label Feb 23, 2018
Comment thread tests/wpt/mozilla/meta/MANIFEST.json Outdated
[
{}
]
],

@paavininanda paavininanda Feb 23, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll have to manually remove all the ./.DS_Store part

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should just be able to revert all of the MANIFEST.json changes entirely.

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Feb 23, 2018
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Feb 23, 2018
@paavininanda
paavininanda force-pushed the BrowsingNames branch 2 times, most recently from 3608bd7 to 88c5fdd Compare February 25, 2018 16:57
@jdm

jdm commented Feb 25, 2018

Copy link
Copy Markdown
Member

The changes to gl-uniformmatrix4fv.html.ini are missing; otherwise this looks good.

@jdm

jdm commented Feb 25, 2018

Copy link
Copy Markdown
Member

You should be able to run ./mach test-wpt tests/wpt/mozilla/tests/webgl/conformance-1.0.3/conformance/uniforms/gl-uniformmatrix4fv.html --no-pause-after-test --log-raw /tmp/wpt then ./mach update-wpt /tmp/wpt to update the ini file correctly.

@jdm

jdm commented Feb 26, 2018

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit b9f7aa4 has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Feb 26, 2018
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit b9f7aa4 with merge 7de2043...

bors-servo pushed a commit that referenced this pull request Feb 26, 2018
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 #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 -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - mac-rel-wpt1

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Feb 26, 2018
@jdm

jdm commented Feb 26, 2018

Copy link
Copy Markdown
Member

@bors-servo

Copy link
Copy Markdown
Contributor

⚡ Previous build results for android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev are reusable. Rebuilding only mac-rel-wpt1...

@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev
Approved by: jdm
Pushing 7de2043 to master...

@bors-servo
bors-servo merged commit b9f7aa4 into servo:master Feb 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-tests-failed The changes caused existing tests to fail.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants