tor-browser

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

browser_panelUINotifications_modals.js (1998B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const { AppMenuNotifications } = ChromeUtils.importESModule(
      7  "resource://gre/modules/AppMenuNotifications.sys.mjs"
      8 );
      9 
     10 add_task(async function testModals() {
     11  is(
     12    PanelUI.notificationPanel.state,
     13    "closed",
     14    "update-manual doorhanger is closed."
     15  );
     16  let mainActionCalled = false;
     17  let mainAction = {
     18    callback: () => {
     19      mainActionCalled = true;
     20    },
     21  };
     22  AppMenuNotifications.showNotification("update-manual", mainAction);
     23 
     24  isnot(
     25    PanelUI.notificationPanel.state,
     26    "closed",
     27    "update-manual doorhanger is showing."
     28  );
     29  let notifications = [...PanelUI.notificationPanel.children].filter(
     30    n => !n.hidden
     31  );
     32  is(
     33    notifications.length,
     34    1,
     35    "PanelUI doorhanger is only displaying one notification."
     36  );
     37  let doorhanger = notifications[0];
     38  is(
     39    doorhanger.id,
     40    "appMenu-update-manual-notification",
     41    "PanelUI is displaying the update-manual notification."
     42  );
     43 
     44  let popuphiddenPromise = BrowserTestUtils.waitForEvent(
     45    PanelUI.notificationPanel,
     46    "popuphidden"
     47  );
     48 
     49  let dialogPromise = BrowserTestUtils.promiseAlertDialogOpen("accept");
     50  Services.prompt.asyncAlert(
     51    window.browsingContext,
     52    Services.prompt.MODAL_TYPE_INTERNAL_WINDOW,
     53    "Test alert",
     54    "Test alert description"
     55  );
     56  await popuphiddenPromise;
     57  is(
     58    PanelUI.notificationPanel.state,
     59    "closed",
     60    "update-manual doorhanger is closed."
     61  );
     62 
     63  let popupshownPromise = BrowserTestUtils.waitForEvent(
     64    PanelUI.notificationPanel,
     65    "popupshown"
     66  );
     67 
     68  await dialogPromise;
     69  await popupshownPromise;
     70  isnot(
     71    PanelUI.notificationPanel.state,
     72    "closed",
     73    "update-manual doorhanger is showing."
     74  );
     75 
     76  doorhanger.button.click();
     77  ok(mainActionCalled, "Main action callback was called");
     78  is(
     79    PanelUI.notificationPanel.state,
     80    "closed",
     81    "update-manual doorhanger is closed."
     82  );
     83 });