summaryrefslogtreecommitdiffstats
path: root/browser/components/firefoxview/tests/browser/browser_tab_close_last_tab.js
blob: 021fd01bc21c2921bca09041bc891d27dcc83219 (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const URL = "https://example.com/";

add_task(async function closing_last_tab_should_not_switch_to_fx_view() {
  await SpecialPowers.pushPrefEnv({
    set: [["browser.tabs.closeWindowWithLastTab", false]],
  });
  info("Opening window...");
  const win = await BrowserTestUtils.openNewBrowserWindow({
    waitForTabURL: "about:newtab",
  });
  const firstTab = win.gBrowser.selectedTab;
  info("Opening Firefox View tab...");
  await openFirefoxViewTab(win);
  info("Switch back to new tab...");
  await BrowserTestUtils.switchTab(win.gBrowser, firstTab);
  info("Load web page in new tab...");
  const loaded = BrowserTestUtils.browserLoaded(
    win.gBrowser.selectedBrowser,
    false,
    URL
  );
  BrowserTestUtils.loadURIString(win.gBrowser.selectedBrowser, URL);
  await loaded;
  info("Opening new browser tab...");
  const secondTab = await BrowserTestUtils.openNewForegroundTab(
    win.gBrowser,
    URL
  );
  info("Close all broswer tabs...");
  await BrowserTestUtils.removeTab(firstTab);
  await BrowserTestUtils.removeTab(secondTab);
  isnot(
    win.gBrowser.selectedTab,
    win.FirefoxViewHandler.tab,
    "The selected tab should not be the Firefox View tab"
  );
  await BrowserTestUtils.closeWindow(win);
});