tor-browser

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

browser_remote_attribute.js (2488B)


      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 
      5 "use strict";
      6 
      7 /**
      8 * These tests check that the remote attribute is true for remote panels.
      9 * This attribute is needed for Mac to properly render the panel.
     10 */
     11 add_task(async function check_remote_attribute() {
     12  // The panel is created on the fly, so we can't simply wait for focus
     13  // inside it.
     14  //let pocketPanelShown = BrowserTestUtils.waitForEvent(
     15  //  document,
     16  //  "popupshown",
     17  //  true
     18  //);
     19  let pocketPanelShown = popupShown(document);
     20  // Using Pocket panel as it's an available remote panel.
     21  let pocketButton = document.getElementById("save-to-pocket-button");
     22  pocketButton.click();
     23  await pocketPanelShown;
     24 
     25  let pocketPanel = document.getElementById("customizationui-widget-panel");
     26  is(
     27    pocketPanel.getAttribute("remote"),
     28    "true",
     29    "Pocket panel has remote attribute"
     30  );
     31 
     32  // Close panel and cleanup.
     33  let pocketPanelHidden = popupHidden(pocketPanel);
     34  pocketPanel.hidePopup();
     35  await pocketPanelHidden;
     36 });
     37 
     38 add_task(async function check_remote_attribute_overflow() {
     39  let win = await BrowserTestUtils.openNewBrowserWindow();
     40  let overflowPanel = win.document.getElementById("widget-overflow");
     41  overflowPanel.setAttribute("animate", "false");
     42 
     43  // Force a narrow window to get an overflow toolbar.
     44  win.resizeTo(kForceOverflowWidthPx, win.outerHeight);
     45  let navbar = win.document.getElementById(CustomizableUI.AREA_NAVBAR);
     46  await TestUtils.waitForCondition(() => navbar.hasAttribute("overflowing"));
     47 
     48  // Open the overflow panel view.
     49  let overflowPanelShown = popupShown(overflowPanel);
     50  let overflowPanelButton = win.document.getElementById(
     51    "nav-bar-overflow-button"
     52  );
     53  overflowPanelButton.click();
     54  await overflowPanelShown;
     55 
     56  // Using Pocket panel as it's an available remote panel.
     57  let pocketButton = win.document.getElementById("save-to-pocket-button");
     58  pocketButton.click();
     59  await BrowserTestUtils.waitForEvent(win.document, "ViewShown");
     60 
     61  is(
     62    overflowPanel.getAttribute("remote"),
     63    "true",
     64    "Pocket overflow panel has remote attribute"
     65  );
     66 
     67  // Close panel and cleanup.
     68  let overflowPanelHidden = popupHidden(overflowPanel);
     69  overflowPanel.hidePopup();
     70  await overflowPanelHidden;
     71  overflowPanel.removeAttribute("animate");
     72  await BrowserTestUtils.closeWindow(win);
     73 });