Auto merge of #20865 - gterzian:improve_spec_compliance_window_close, 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 -->
This commit is contained in:
bors-servo 2018-06-04 06:16:45 -04:00 committed by GitHub
commit 65eff4fb8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 123 additions and 39 deletions

View file

@ -275288,6 +275288,11 @@
{}
]
],
"html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-uncloseable-1.html": [
[
{}
]
],
"html/browsers/browsing-the-web/unloading-documents/prompt/001-1.html": [
[
{}
@ -331632,6 +331637,18 @@
{}
]
],
"html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-closeable.html": [
[
"/html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-closeable.html",
{}
]
],
"html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-uncloseable.html": [
[
"/html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-uncloseable.html",
{}
]
],
"html/browsers/browsing-the-web/unloading-documents/prompt/001.html": [
[
"/html/browsers/browsing-the-web/unloading-documents/prompt/001.html",
@ -561991,6 +562008,18 @@
"2b3a56895dbe6450ed38ebbb31a915c9e8b7abd6",
"testharness"
],
"html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-closeable.html": [
"7b60961703fd447aff290aa5fedf6950b242b9d5",
"testharness"
],
"html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-uncloseable-1.html": [
"0e8cf55368a34a0367763cdf902fdf6a5dc51f28",
"support"
],
"html/browsers/browsing-the-web/unloading-documents/prompt-and-unload-script-uncloseable.html": [
"faa25d4925073f71b3ee451427b253cc232c01f7",
"testharness"
],
"html/browsers/browsing-the-web/unloading-documents/prompt/001-1.html": [
"758c04e8df6778e435346c59280c17e02295cca6",
"support"

View file

@ -0,0 +1,22 @@
<!doctype html>
<title>beforeunload and unload events fire after window.close() in script-closeable browsing context</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
beforeunload_fired = false;
var t = async_test();
onload = t.step_func(function() {
window.close();
});
onbeforeunload = t.step_func(function() {
beforeunload_fired = true;
});
onunload = t.step_func(function() {
assert_true(beforeunload_fired);
t.done()
});
</script>

View file

@ -0,0 +1,10 @@
<!doctype html>
script-uncloseable-1
<script>
onbeforeunload = function() {
parent.beforeunload_fired = true;
};
onunload = function() {
parent.unload_fired = true;
};
</script>

View file

@ -0,0 +1,24 @@
<!doctype html>
<title>beforeunload and unload events do not fire after window.close() in script-uncloseable browsing context</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var beforeunload_fired = false;
var unload_fired = false;
var t = async_test();
onload = t.step_func(function() {
var iframe = document.getElementsByTagName("iframe")[0]
iframe.onload = t.step_func(function() {
iframe.contentWindow.close()
t.step_timeout(function() {
assert_false(beforeunload_fired);
assert_false(unload_fired);
t.done();
}, 1000);
});
iframe.src = "prompt-and-unload-script-uncloseable-1.html";
});
</script>
<iframe></iframe>