summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui/test/browser_exit_background_customize_mode.js
blob: ec9e3b03af0b14492a1c8ff02c82d8fe30ac6d64 (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
"use strict";

/**
 * Tests that if customize mode is currently attached to a background
 * tab, and that tab browses to a new location, that customize mode
 * is detached from that tab.
 */
add_task(async function test_exit_background_customize_mode() {
  let nonCustomizingTab = gBrowser.selectedTab;

  Assert.equal(
    gBrowser.tabContainer.querySelector("tab[customizemode=true]"),
    null,
    "Should not have a tab marked as being the customize tab now."
  );

  await startCustomizing();
  is(gBrowser.tabs.length, 2, "Should have 2 tabs");

  let custTab = gBrowser.selectedTab;

  let finishedCustomizing = BrowserTestUtils.waitForEvent(
    gNavToolbox,
    "aftercustomization"
  );
  await BrowserTestUtils.switchTab(gBrowser, nonCustomizingTab);
  await finishedCustomizing;

  let newURL = "http://example.com/";
  BrowserTestUtils.loadURI(custTab.linkedBrowser, newURL);
  await BrowserTestUtils.browserLoaded(custTab.linkedBrowser, false, newURL);

  Assert.equal(
    gBrowser.tabContainer.querySelector("tab[customizemode=true]"),
    null,
    "Should not have a tab marked as being the customize tab now."
  );

  await startCustomizing();
  is(gBrowser.tabs.length, 3, "Should have 3 tabs now");

  await endCustomizing();
  BrowserTestUtils.removeTab(custTab);
});