summaryrefslogtreecommitdiffstats
path: root/browser/components/newtab/test/browser/browser_newtab_towindow.js
blob: d0a49e63f0d140b63fa711e8a96e991e9d8f0752 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// This test simulates opening the newtab page and moving it to a new window.
// Links in the page should still work.
add_task(async function test_newtab_to_window() {
  await setTestTopSites();

  let tab = await BrowserTestUtils.openNewForegroundTab(
    gBrowser,
    "about:newtab",
    false
  );

  let swappedPromise = BrowserTestUtils.waitForEvent(
    tab.linkedBrowser,
    "SwapDocShells"
  );
  let newWindow = gBrowser.replaceTabWithWindow(tab);
  await swappedPromise;

  is(
    newWindow.gBrowser.selectedBrowser.currentURI.spec,
    "about:newtab",
    "about:newtab moved to window"
  );

  let tabPromise = BrowserTestUtils.waitForNewTab(
    newWindow.gBrowser,
    "https://example.com/",
    true
  );

  await BrowserTestUtils.synthesizeMouse(
    `.top-sites a`,
    2,
    2,
    { accelKey: true },
    newWindow.gBrowser.selectedBrowser
  );

  await tabPromise;

  is(newWindow.gBrowser.tabs.length, 2, "second page is opened");

  BrowserTestUtils.removeTab(newWindow.gBrowser.selectedTab);
  await BrowserTestUtils.closeWindow(newWindow);
});