tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_aboutwelcome_import.js (2405B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 const IMPORT_SCREEN = {
      6  id: "AW_IMPORT",
      7  content: {
      8    primary_button: {
      9      label: "import",
     10      action: {
     11        navigate: true,
     12        type: "SHOW_MIGRATION_WIZARD",
     13      },
     14    },
     15  },
     16 };
     17 
     18 add_task(async function test_wait_import_modal() {
     19  await setAboutWelcomeMultiStage(
     20    JSON.stringify([IMPORT_SCREEN, { id: "AW_NEXT", content: {} }])
     21  );
     22  const { cleanup, browser } = await openMRAboutWelcome();
     23 
     24  // execution
     25  await test_screen_content(
     26    browser,
     27    "renders IMPORT screen",
     28    //Expected selectors
     29    ["main.AW_IMPORT", "button[value='primary_button']"],
     30 
     31    //Unexpected selectors:
     32    ["main.AW_NEXT"]
     33  );
     34 
     35  const wizardPromise = BrowserTestUtils.waitForMigrationWizard(window);
     36  const prefsTab = await BrowserTestUtils.openNewForegroundTab(
     37    gBrowser,
     38    "about:preferences"
     39  );
     40  await onButtonClick(browser, "button.primary");
     41  const wizard = await wizardPromise;
     42 
     43  await test_screen_content(
     44    browser,
     45    "still shows IMPORT screen",
     46    //Expected selectors
     47    ["main.AW_IMPORT", "button[value='primary_button']"],
     48 
     49    //Unexpected selectors:
     50    ["main.AW_NEXT"]
     51  );
     52 
     53  await BrowserTestUtils.removeTab(wizard);
     54 
     55  await test_screen_content(
     56    browser,
     57    "moved to NEXT screen",
     58    //Expected selectors
     59    ["main.AW_NEXT"],
     60 
     61    //Unexpected selectors:
     62    []
     63  );
     64 
     65  // cleanup
     66  await SpecialPowers.popPrefEnv(); // for setAboutWelcomeMultiStage
     67  BrowserTestUtils.removeTab(prefsTab);
     68  await cleanup();
     69 });
     70 
     71 add_task(async function test_wait_import_spotlight() {
     72  const spotlightPromise = TestUtils.topicObserved("subdialog-loaded");
     73  ChromeUtils.importESModule(
     74    "resource:///modules/asrouter/Spotlight.sys.mjs"
     75  ).Spotlight.showSpotlightDialog(gBrowser.selectedBrowser, {
     76    content: { modal: "tab", screens: [IMPORT_SCREEN] },
     77  });
     78  const [win] = await spotlightPromise;
     79 
     80  const wizardPromise = BrowserTestUtils.waitForMigrationWizard(window);
     81  const prefsTab = await BrowserTestUtils.openNewForegroundTab(
     82    gBrowser,
     83    "about:preferences"
     84  );
     85  win.document
     86    .querySelector(".onboardingContainer button[value='primary_button']")
     87    .click();
     88  const wizard = await wizardPromise;
     89 
     90  await BrowserTestUtils.removeTab(wizard);
     91 
     92  // cleanup
     93  BrowserTestUtils.removeTab(prefsTab);
     94 });