4 <title>Test for Bug
1702678</title>
6 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel=
"stylesheet" type=
"text/css" href=
"chrome://mochikit/content/tests/SimpleTest/test.css"/>
10 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=1702678">Mozilla Bug
1702678</a>
12 <script type=
"application/javascript">
19 <meta charset=
"utf-8">
21 // We need to queue a promise reaction job whilch will close the window
22 // during the nested event loop spun up by the window opening code.
23 Promise
.resolve().then(() => {
26 window
.open("data:text/html,Hello");
32 add_task(async function() {
33 // This bug only manifests when opening tabs in new windows.
34 await SpecialPowers.pushPrefEnv({
35 set: [["browser.link.open_newwindow", 2]],
38 // Create a window in a new BrowsingContextGroup so that it will be the last
39 // window in the group when it closes, and the group will be destroyed.
40 window.open(`data
:text
/html
,${encodeURIComponent(HTML)}
`, "", "noopener");
42 // Make a few trips through the event loop to ensure we've had a chance to
43 // open and close the relevant windows.
44 for (let i = 0; i < 10; i++) {
45 await new Promise(resolve => setTimeout(resolve, 0));
48 ok(true, "We didn't crash");