Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: e10s
 - Manifest: docshell/test/chrome/chrome.toml
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1702678">Mozilla Bug 1702678</a>
<script type="application/javascript">
"use strict";
const HTML = `
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <script>
    // We need to queue a promise reaction job whilch will close the window
    // during the nested event loop spun up by the window opening code.
    Promise.resolve().then(() => {
      window.close();
    });
    window.open("data:text/html,Hello");
  <\/script>
</head>
</html>
`;
add_task(async function() {
  // This bug only manifests when opening tabs in new windows.
  await SpecialPowers.pushPrefEnv({
    set: [["browser.link.open_newwindow", 2]],
  });
  // Create a window in a new BrowsingContextGroup so that it will be the last
  // window in the group when it closes, and the group will be destroyed.
  window.open(`data:text/html,${encodeURIComponent(HTML)}`, "", "noopener");
  // Make a few trips through the event loop to ensure we've had a chance to
  // open and close the relevant windows.
  for (let i = 0; i < 10; i++) {
    await new Promise(resolve => setTimeout(resolve, 0));
  }
  ok(true, "We didn't crash");
});
</script>
</body>
</html>