summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui/test/browser_open_in_lazy_tab.js
blob: e9a6405021b0e86581a25794f5ea2e8fa4d7ecaf (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
46
47
48
49
50
51
52
53
54
"use strict";

/**
 * Check that customize mode can be loaded in a lazy tab.
 */
add_task(async function open_customize_mode_in_lazy_tab() {
  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank", {
    createLazyBrowser: true,
  });
  gCustomizeMode.setTab(tab);

  is(tab.linkedPanel, "", "Tab should be lazy");

  let title = gNavigatorBundle.getFormattedString("customizeMode.tabTitle", [
    document.getElementById("bundle_brand").getString("brandShortName"),
  ]);
  is(tab.label, title, "Tab should have correct title");

  let tabLoaded = new Promise(resolve => {
    gBrowser.addTabsProgressListener({
      async onLocationChange(aBrowser) {
        if (tab.linkedBrowser == aBrowser) {
          gBrowser.removeTabsProgressListener(this);
          await Promise.resolve();
          resolve();
        }
      },
    });
  });
  let customizePromise = BrowserTestUtils.waitForEvent(
    gNavToolbox,
    "customizationready"
  );
  gCustomizeMode.enter();
  await customizePromise;
  await tabLoaded;

  is(
    tab.getAttribute("customizemode"),
    "true",
    "Tab should be in customize mode"
  );

  let customizationContainer = document.getElementById(
    "customization-container"
  );
  is(
    customizationContainer.hidden,
    false,
    "Customization container should be visible"
  );

  await endCustomizing();
});