Bug 1634252 - Add test case r=kmag
authorPaul Bone <pbone@mozilla.com>
Thu, 04 Jun 2020 08:25:12 +0000
changeset 597930 cf0703e56c9fc1d6261517baa2c26377d10b80f5
parent 597929 dae19c12350d4069bdca8396e05310100a6943c7
child 597931 0ceadf0ed0f1884144f6d060284958a6ce3ec4ee
push id13310
push userffxbld-merge
push dateMon, 29 Jun 2020 14:50:06 +0000
treeherdermozilla-beta@15a59a0afa5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1634252
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1634252 - Add test case r=kmag Differential Revision: https://phabricator.services.mozilla.com/D76994
browser/base/content/test/tabs/browser.ini
browser/base/content/test/tabs/browser_file_to_http_named_popup.js
--- a/browser/base/content/test/tabs/browser.ini
+++ b/browser/base/content/test/tabs/browser.ini
@@ -27,16 +27,17 @@ support-files =
 [browser_e10s_switchbrowser.js]
 [browser_e10s_about_process.js]
 [browser_e10s_mozillaweb_process.js]
 [browser_e10s_chrome_process.js]
 skip-if = debug # Bug 1444565, Bug 1457887
 [browser_e10s_javascript.js]
 [browser_file_to_http_script_closable.js]
 support-files = tab_that_closes.html
+[browser_file_to_http_named_popup.js]
 [browser_multiselect_tabs_active_tab_selected_by_default.js]
 [browser_multiselect_tabs_bookmark.js]
 [browser_multiselect_tabs_clear_selection_when_tab_switch.js]
 [browser_multiselect_tabs_close_other_tabs.js]
 [browser_multiselect_tabs_close_tabs_to_the_right.js]
 [browser_multiselect_tabs_close_using_shortcuts.js]
 [browser_multiselect_tabs_close.js]
 [browser_multiselect_tabs_copy_through_drag_and_drop.js]
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/tabs/browser_file_to_http_named_popup.js
@@ -0,0 +1,60 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
+
+const TEST_FILE = fileURL("dummy_page.html");
+const TEST_HTTP = httpURL("dummy_page.html");
+
+// Test for Bug 1634252
+add_task(async function() {
+  await BrowserTestUtils.withNewTab(TEST_FILE, async function(fileBrowser) {
+    info("Tab ready");
+
+    async function summonPopup(firstRun) {
+      var winPromise;
+      if (firstRun) {
+        winPromise = BrowserTestUtils.waitForNewWindow({
+          url: TEST_HTTP,
+        });
+      }
+
+      await SpecialPowers.spawn(
+        fileBrowser,
+        [TEST_HTTP, firstRun],
+        (target, firstRun_) => {
+          var win = content.open(target, "named", "width=400,height=400");
+          win.focus();
+          ok(win, "window.open was successful");
+          if (firstRun_) {
+            content.document.firstWindow = win;
+          } else {
+            content.document.otherWindow = win;
+          }
+        }
+      );
+
+      if (firstRun) {
+        // We should only wait for the window the first time, because only the
+        // later times no new window should be created.
+        info("Waiting for new window");
+        var win = await winPromise;
+        ok(win, "Got a window");
+      }
+    }
+
+    info("Opening window");
+    await summonPopup(true);
+    info("Opening window again");
+    await summonPopup(false);
+
+    await SpecialPowers.spawn(fileBrowser, [], () => {
+      ok(content.document.firstWindow, "Window is non-null");
+      is(
+        content.document.otherWindow,
+        content.document.firstWindow,
+        "Windows are the same"
+      );
+
+      content.document.firstWindow.close();
+    });
+  });
+});