Skip to content

improve spec compliance of window.close#20865

Merged
bors-servo merged 1 commit intoservo:masterfrom
gterzian:improve_spec_compliance_window_close
Jun 4, 2018
Merged

improve spec compliance of window.close#20865
bors-servo merged 1 commit intoservo:masterfrom
gterzian:improve_spec_compliance_window_close

Conversation

@gterzian
Copy link
Copy Markdown
Member

@gterzian gterzian commented May 26, 2018

Improve the spec compliance of https://html.spec.whatwg.org/multipage/window-object.html#dom-window-close, mainly by implementing the steps related to closing a browsing context


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #__ (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

@highfive
Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @asajeffrey: components/constellation/constellation.rs, components/script/dom/window.rs
  • @cbrewster: components/constellation/constellation.rs
  • @paulrouget: ports/servo/browser.rs, components/constellation/constellation.rs
  • @fitzgen: components/script_traits/script_msg.rs, components/script/dom/window.rs
  • @KiChjang: components/script_traits/script_msg.rs, components/script/dom/window.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label May 26, 2018
@servo-wpt-sync
Copy link
Copy Markdown
Collaborator

Opened new PR for upstreamable changes.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#63.

@gterzian gterzian force-pushed the improve_spec_compliance_window_close branch from 7eff72a to 38ef920 Compare May 26, 2018 15:49
@servo-wpt-sync
Copy link
Copy Markdown
Collaborator

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#63.

@gterzian gterzian force-pushed the improve_spec_compliance_window_close branch from 38ef920 to 4160746 Compare May 26, 2018 15:55
@servo-wpt-sync
Copy link
Copy Markdown
Collaborator

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#63.

@gterzian gterzian force-pushed the improve_spec_compliance_window_close branch from 4160746 to 3c5c135 Compare May 26, 2018 16:01
@servo-wpt-sync
Copy link
Copy Markdown
Collaborator

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#63.

@gterzian gterzian force-pushed the improve_spec_compliance_window_close branch from 3c5c135 to df6b835 Compare May 26, 2018 16:10
@servo-wpt-sync
Copy link
Copy Markdown
Collaborator

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#63.

@gterzian gterzian force-pushed the improve_spec_compliance_window_close branch from df6b835 to 12195e7 Compare May 26, 2018 16:16
@servo-wpt-sync
Copy link
Copy Markdown
Collaborator

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#63.

@gterzian gterzian force-pushed the improve_spec_compliance_window_close branch from 12195e7 to b5aedac Compare May 26, 2018 16:17
@servo-wpt-sync
Copy link
Copy Markdown
Collaborator

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#63.

@gterzian gterzian force-pushed the improve_spec_compliance_window_close branch from b5aedac to caea691 Compare May 26, 2018 16:18
@servo-wpt-sync
Copy link
Copy Markdown
Collaborator

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#63.

@gterzian
Copy link
Copy Markdown
Member Author

gterzian commented May 26, 2018

@bors-servo try

@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Trying commit caea691 with merge 3b6649f...

bors-servo pushed a commit that referenced this pull request May 26, 2018
… r=<try>

improve spec compliance of window.close

<!-- Please describe your changes on the following line: -->
Improve the spec compliance of https://html.spec.whatwg.org/multipage/window-object.html#dom-window-close, mainly by implementing the steps related to [closing a browsing context](https://html.spec.whatwg.org/multipage/window-object.html#close-a-browsing-context)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- 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/20865)
<!-- Reviewable:end -->
@bors-servo
Copy link
Copy Markdown
Contributor

💔 Test failed - linux-dev

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label May 26, 2018
@CYBAI
Copy link
Copy Markdown
Member

CYBAI commented May 26, 2018

Checking files for tidiness...

./components/compositing/compositor_thread.rs:71: found an empty line following a {

./components/constellation/constellation.rs:1040: trailing whitespace

Running the dependency licensing lint...

@gterzian
Copy link
Copy Markdown
Member Author

gterzian commented May 27, 2018

@CYBAI thanks, should have waited for CI to finish...
Looks like all tests were passing, with the exceptions of the known websocket intermittent problem.

@gterzian gterzian force-pushed the improve_spec_compliance_window_close branch from caea691 to 080af33 Compare May 27, 2018 02:38
@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label May 27, 2018
@servo-wpt-sync
Copy link
Copy Markdown
Collaborator

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#63.

@gterzian gterzian force-pushed the improve_spec_compliance_window_close branch from 080af33 to 89889e7 Compare May 27, 2018 02:43
@cbrewster
Copy link
Copy Markdown
Contributor

Sorry I've been busy/without WiFi for a week or so. I should be able to look at this soon.

@gterzian
Copy link
Copy Markdown
Member Author

gterzian commented May 29, 2018

@jdm I haven't had a chance yet to follow the instructions on how to setup wpt as a standalone server, however just trying out window.close manually in Firefox gives me the following warning Scripts may not close windows that were not opened by script. (which seems to be missing the second or if it is a top-level browsing context whose session history contains only one Document part of the spec...).

The way the test currently behaves with Servo is that the window is indeed closed so you can't really see the results, however the test passes (and does not crash like it would without these changes) because done is called in the unload listener, which per the spec happens before the window is actually closed...

I was also thinking that since unload is fired inside document.unload, as opposed to inside a task, we would get some form of deterministic behavior where we can sure that the test will pass in case unload is indeed fired before the window is closed(and I'm guessing it would timeout in Firefox).

Copy link
Copy Markdown
Contributor

@cbrewster cbrewster left a comment

Choose a reason for hiding this comment

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

Looks good. I think we still need to make sure that the compositor shuts down properly.

self.main_thread_script_chan()
.send(MainThreadScriptMsg::ExitWindow(self.upcast::<GlobalScope>().pipeline_id()))
.unwrap();
// Note: check the length of the "session history", as opposed to the joint session history?
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 would probably be something that should be clarified in the spec, perhaps open an issue there. I would think the jsh is the right thing to look at here, but I could be wrong.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

GetScreenAvailSize(IpcSender<(DeviceUintSize)>),
/// Requests that the compositor shut down.
Exit,
GetScreenAvailSize(IpcSender<(DeviceUintSize)>)
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.

nit: add trailing ,

GetScreenSize(..) => "GetScreenSize",
GetScreenAvailSize(..) => "GetScreenAvailSize",
Exit => "Exit",
GetScreenAvailSize(..) => "GetScreenAvailSize"
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.

nit: add trailing ,

}

(Msg::Exit, _) => {
self.start_shutting_down();
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 think this gets called anymore after these changes.

Copy link
Copy Markdown
Member Author

@gterzian gterzian Jun 4, 2018

Choose a reason for hiding this comment

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

By appending WindowEvent::Quit here, compositor.maybe_start_shutting_down ends up being called via Servo's handling of WindowEvent::Quit here, and maybe_start_shutting_down ends up calling start_shutting_down.

The difference is that the compositor is shut down only after the unload steps have been run.

If the embedder were to handle tabs or something similar, it wouldn't have to send a WindowEvent::Quit in case other "tabs" were still running... (and I might actually have to end up doing something similar as part of #20678 to make some of the related tests pass)

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.

Ah missed that! This sounds reasonable.

@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 Jun 3, 2018
// Nothing left to do for now,
// but could hide a tab, and show another one, instead of quitting.
self.event_queue.push(WindowEvent::Quit);
}
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.

Just found the , is inconsistent in this pattern matching.
Should we fix it in this PR or have an E-easy issue to make the consistency of comma for pattern matching?

Copy link
Copy Markdown
Member Author

@gterzian gterzian Jun 4, 2018

Choose a reason for hiding this comment

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

Thanks, I can add a comma for this specific change, and you could make it consistent across the rest in a separate PR?

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.

Yes, I think I can send one after this one merged.

@gterzian gterzian force-pushed the improve_spec_compliance_window_close branch from e5df6eb to 397e5fd Compare June 4, 2018 05:52
@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 Jun 4, 2018
@servo-wpt-sync
Copy link
Copy Markdown
Collaborator

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#63.

@gterzian
Copy link
Copy Markdown
Member Author

gterzian commented Jun 4, 2018

@cbrewster Thanks for the review, I've fixed the nits and replied to the other points...

@gterzian gterzian force-pushed the improve_spec_compliance_window_close branch from 397e5fd to 2753e5e Compare June 4, 2018 07:03
@servo-wpt-sync
Copy link
Copy Markdown
Collaborator

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#63.

@cbrewster
Copy link
Copy Markdown
Contributor

LGTM, the test does fail in other browsers, but I believe it is spec compliant. The test should be updated in the future if the spec ends up changing.

@bors-servo r+

@bors-servo
Copy link
Copy Markdown
Contributor

📌 Commit 2753e5e has been approved by cbrewster

@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 Jun 4, 2018
@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Testing commit 2753e5e with merge 65eff4f...

bors-servo pushed a commit that referenced this pull request Jun 4, 2018
… r=cbrewster

improve spec compliance of window.close

<!-- Please describe your changes on the following line: -->
Improve the spec compliance of https://html.spec.whatwg.org/multipage/window-object.html#dom-window-close, mainly by implementing the steps related to [closing a browsing context](https://html.spec.whatwg.org/multipage/window-object.html#close-a-browsing-context)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- 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/20865)
<!-- Reviewable:end -->
@gterzian
Copy link
Copy Markdown
Member Author

gterzian commented Jun 4, 2018

@cbrewster thanks for checking the other browsers!

@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: cbrewster
Pushing 65eff4f to master...

@bors-servo bors-servo merged commit 2753e5e into servo:master Jun 4, 2018
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jun 4, 2018
@gterzian gterzian deleted the improve_spec_compliance_window_close branch June 4, 2018 13:02
jdm pushed a commit to web-platform-tests/wpt that referenced this pull request Jun 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants