no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / docshell / test / browser / browser_tab_replace_while_loading.js
blob3c85f7219202936e64853f911159adea7ce74d26
1 /* Any copyright is dedicated to the Public Domain.
2    http://creativecommons.org/publicdomain/zero/1.0/ */
4 "use strict";
6 /* Test for bug 1578379. */
8 add_task(async function test_window_open_about_blank() {
9   const URL =
10     "http://mochi.test:8888/browser/docshell/test/browser/file_open_about_blank.html";
11   let firstTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
12   let promiseTabOpened = BrowserTestUtils.waitForNewTab(
13     gBrowser,
14     "about:blank"
15   );
17   info("Opening about:blank using a click");
18   await SpecialPowers.spawn(firstTab.linkedBrowser, [""], async function () {
19     content.document.querySelector("#open").click();
20   });
22   info("Waiting for the second tab to be opened");
23   let secondTab = await promiseTabOpened;
25   info("Detaching tab");
26   let windowOpenedPromise = BrowserTestUtils.waitForNewWindow();
27   gBrowser.replaceTabWithWindow(secondTab);
28   let win = await windowOpenedPromise;
30   info("Asserting document is visible");
31   let tab = win.gBrowser.selectedTab;
32   await SpecialPowers.spawn(tab.linkedBrowser, [""], async function () {
33     is(
34       content.document.visibilityState,
35       "visible",
36       "Document should be visible"
37     );
38   });
40   await BrowserTestUtils.closeWindow(win);
41   await BrowserTestUtils.removeTab(firstTab);
42 });
44 add_task(async function test_detach_loading_page() {
45   const URL =
46     "http://mochi.test:8888/browser/docshell/test/browser/file_slow_load.sjs";
47   // Open a dummy tab so that detaching the second tab works.
48   let dummyTab = await BrowserTestUtils.openNewForegroundTab(
49     gBrowser,
50     "about:blank"
51   );
52   let slowLoadingTab = await BrowserTestUtils.openNewForegroundTab(
53     gBrowser,
54     URL,
55     /* waitForLoad = */ false
56   );
58   info("Wait for content document to be created");
59   await BrowserTestUtils.waitForCondition(async function () {
60     return SpecialPowers.spawn(
61       slowLoadingTab.linkedBrowser,
62       [URL],
63       async function (url) {
64         return content.document.documentURI == url;
65       }
66     );
67   });
69   info("Detaching tab");
70   let windowOpenedPromise = BrowserTestUtils.waitForNewWindow();
71   gBrowser.replaceTabWithWindow(slowLoadingTab);
72   let win = await windowOpenedPromise;
74   info("Asserting document is visible");
75   let tab = win.gBrowser.selectedTab;
76   await SpecialPowers.spawn(tab.linkedBrowser, [""], async function () {
77     is(content.document.readyState, "loading");
78     is(content.document.visibilityState, "visible");
79   });
81   await BrowserTestUtils.closeWindow(win);
82   await BrowserTestUtils.removeTab(dummyTab);
83 });