summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/tabs/browser_tab_label_during_reload.js
blob: ec0728c34a0dd6217ccaa7f5c3498aafb332987c (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

add_task(async function () {
  let tab = (gBrowser.selectedTab = BrowserTestUtils.addTab(
    gBrowser,
    "about:preferences"
  ));
  let browser = tab.linkedBrowser;
  let labelChanges = 0;
  let attrModifiedListener = event => {
    if (event.detail.changed.includes("label")) {
      labelChanges++;
    }
  };
  tab.addEventListener("TabAttrModified", attrModifiedListener);

  await BrowserTestUtils.browserLoaded(browser);
  is(labelChanges, 1, "number of label changes during initial load");
  isnot(tab.label, "", "about:preferences tab label isn't empty");
  isnot(
    tab.label,
    "about:preferences",
    "about:preferences tab label isn't the URI"
  );
  is(
    tab.label,
    browser.contentTitle,
    "about:preferences tab label matches browser.contentTitle"
  );

  labelChanges = 0;
  browser.reload();
  await BrowserTestUtils.browserLoaded(browser);
  is(labelChanges, 0, "number of label changes during reload");

  tab.removeEventListener("TabAttrModified", attrModifiedListener);
  gBrowser.removeTab(tab);
});