Auto merge of #17665 - jdm:postmessage-panic, r=KiChjang

Avoid panic when postMessage targets closed window.

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #17664
- [X] There are tests for these changes

<!-- 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/17665)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-07-11 12:28:33 -07:00 committed by GitHub
commit 2a575acabe
3 changed files with 26 additions and 1 deletions

View file

@ -13929,6 +13929,12 @@
{}
]
],
"mozilla/postmessage_closed.html": [
[
"/_mozilla/mozilla/postmessage_closed.html",
{}
]
],
"mozilla/preferences.html": [
[
"/_mozilla/mozilla/preferences.html",
@ -26770,6 +26776,10 @@
"47c91f505cb8120a7f4b310b260f13408f06b8fc",
"testharness"
],
"mozilla/postmessage_closed.html": [
"70fc1b9dad5f611285f8f4ed04454800283e223c",
"testharness"
],
"mozilla/preferences.html": [
"7584699a938adf516ea3b7d6f22fd11d0b0942cf",
"testharness"

View file

@ -0,0 +1,14 @@
<!doctype html>
<meta charset="utf-8">
<title>Window.postMessage does not panic when a window is closed before the message is received</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe></iframe>
<script>
async_test(function(t) {
var i = document.querySelector('iframe');
i.contentWindow.postMessage('hi', '*');
i.remove();
t.step_timeout(function() { t.done() }, 0);
});
</script>