docshell/test/test_close_onpagehide_by_window_close.html
author Francois Marier <francois@mozilla.com>
Fri, 07 Sep 2018 20:31:18 +0000
changeset 492412 f7a8a2d68c01f5e71f6051406240766e9542f1da
parent 459062 f0f5a81b193f8c8851b0a6448e86c03457966c1a
child 497594 58adc643dcdc20eccb4d30bc454b50420e96c020
permissions -rw-r--r--
Bug 1489590 - Teach the URL classifier about the FastBlock lists. r=dimi a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D5297

<!doctype html>
<title>Test for closing window in pagehide event callback caused by window.close()</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1432396">Mozilla Bug 1432396</a>
<p id="display"></p>
<script>
SimpleTest.waitForExplicitFinish();

const w = window.open("file_close_onpagehide1.html");
window.addEventListener("message", e => {
  is(e.data, "initial", "The initial page loaded");
  w.onpagehide = () => {
    w.close();
    info("try to close the popped up window in onpagehide");
    SimpleTest.finish();
  };
  w.close();
}, { once: true });
</script>