summaryrefslogtreecommitdiffstats
path: root/browser/components/preferences/tests/browser_fluent.js
blob: ae83abecf02ea5ad500fb3ddaac607c82209fc97 (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
function whenMainPaneLoadedFinished() {
  return new Promise(function (resolve) {
    const topic = "main-pane-loaded";
    Services.obs.addObserver(function observer() {
      Services.obs.removeObserver(observer, topic);
      resolve();
    }, topic);
  });
}

// Temporary test for an experimental new localization API.
// See bug 1402069 for details.
add_task(async function () {
  // The string is used only when `browserTabsRemoteAutostart` is true
  if (!Services.appinfo.browserTabsRemoteAutostart) {
    ok(true, "fake test to avoid harness complaining");
    return;
  }

  await Promise.all([
    openPreferencesViaOpenPreferencesAPI("general", { leaveOpen: true }),
    whenMainPaneLoadedFinished(),
  ]);

  let doc = gBrowser.contentDocument;
  await doc.l10n.ready;

  let [msg] = await doc.l10n.formatMessages([{ id: "category-general" }]);

  let elem = doc.querySelector(`#category-general`);

  Assert.deepEqual(msg, {
    value: null,
    attributes: [
      { name: "tooltiptext", value: elem.getAttribute("tooltiptext") },
    ],
  });

  BrowserTestUtils.removeTab(gBrowser.selectedTab);
});