tor-browser

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

browser_popupNotification_queue.js (1447B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 /* eslint-disable mozilla/no-arbitrary-setTimeout */
      5 
      6 function test() {
      7  waitForExplicitFinish();
      8 
      9  ok(PopupNotifications, "PopupNotifications object exists");
     10  ok(PopupNotifications.panel, "PopupNotifications panel exists");
     11 
     12  setup();
     13 }
     14 
     15 var tests = [
     16  {
     17    id: "Test#1",
     18    run() {
     19      const panel = document.createXULElement("panel");
     20      panel.setAttribute("id", "non-queue-popup");
     21      panel.setAttribute("type", "arrow");
     22      panel.setAttribute("flip", "both");
     23      panel.setAttribute("consumeoutsideclicks", "false");
     24      document.documentElement.appendChild(panel);
     25 
     26      this.state = "PANEL_SHOWN";
     27      panel.openPopup(null, "topcenter topleft", 100, 100, false, null);
     28 
     29      this.notifyObj = new BasicNotification(this.id);
     30      this.notifyObj.options.queue = true;
     31      showNotification(this.notifyObj);
     32 
     33      new Promise(r => setTimeout(r, 200)).then(() => {
     34        this.state = "PANEL_HIDDEN";
     35        panel.hidePopup();
     36      });
     37    },
     38 
     39    onShown(popup) {
     40      is(
     41        this.state,
     42        "PANEL_HIDDEN",
     43        "The notification is shown only when the panel is dismissed"
     44      );
     45 
     46      checkPopup(popup, this.notifyObj);
     47      triggerMainCommand(popup);
     48    },
     49    onHidden() {},
     50  },
     51 ];