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

"use strict";

XPCOMUtils.defineLazyServiceGetters(this, {
  BrowserHandler: ["@mozilla.org/browser/clh;1", "nsIBrowserHandler"],
});

async function showAboutWelcomeModal() {
  await SpecialPowers.pushPrefEnv({
    set: [["browser.aboutwelcome.showModal", true]],
  });

  BrowserHandler.firstRunProfile = true;

  const data = [
    {
      id: "TEST_SCREEN",
      content: {
        position: "split",
        logo: {},
        title: "test",
      },
    },
  ];

  return {
    data,
    async cleanup() {
      await SpecialPowers.popPrefEnv();
      BrowserHandler.firstRunProfile = false;
    },
  };
}

add_task(async function show_about_welcome_modal() {
  const { data } = await showAboutWelcomeModal();
  await SpecialPowers.pushPrefEnv({
    set: [["browser.aboutwelcome.screens", JSON.stringify(data)]],
  });
  BROWSER_GLUE._maybeShowDefaultBrowserPrompt();
  const [win] = await TestUtils.topicObserved("subdialog-loaded");
  const modal = win.document.querySelector(".onboardingContainer");
  ok(!!modal, "About Welcome modal shown");
  win.close();
});