summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui/test/browser_remote_attribute.js
blob: 543e62e2bcab9846431f1158d0a4840d0645564e (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

/**
 * These tests check that the remote attribute is true for remote panels.
 * This attribute is needed for Mac to properly render the panel.
 */
add_task(async function check_remote_attribute() {
  // The panel is created on the fly, so we can't simply wait for focus
  // inside it.
  //let pocketPanelShown = BrowserTestUtils.waitForEvent(
  //  document,
  //  "popupshown",
  //  true
  //);
  let pocketPanelShown = popupShown(document);
  // Using Pocket panel as it's an available remote panel.
  let pocketButton = document.getElementById("save-to-pocket-button");
  pocketButton.click();
  await pocketPanelShown;

  let pocketPanel = document.getElementById("customizationui-widget-panel");
  is(
    pocketPanel.getAttribute("remote"),
    "true",
    "Pocket panel has remote attribute"
  );

  // Close panel and cleanup.
  let pocketPanelHidden = popupHidden(pocketPanel);
  pocketPanel.hidePopup();
  await pocketPanelHidden;
});

add_task(async function check_remote_attribute_overflow() {
  let win = await BrowserTestUtils.openNewBrowserWindow();
  let overflowPanel = win.document.getElementById("widget-overflow");
  overflowPanel.setAttribute("animate", "false");

  // Force a narrow window to get an overflow toolbar.
  win.resizeTo(kForceOverflowWidthPx, win.outerHeight);
  let navbar = win.document.getElementById(CustomizableUI.AREA_NAVBAR);
  await TestUtils.waitForCondition(() => navbar.hasAttribute("overflowing"));

  // Open the overflow panel view.
  let overflowPanelShown = popupShown(overflowPanel);
  let overflowPanelButton = win.document.getElementById(
    "nav-bar-overflow-button"
  );
  overflowPanelButton.click();
  await overflowPanelShown;

  // Using Pocket panel as it's an available remote panel.
  let pocketButton = win.document.getElementById("save-to-pocket-button");
  pocketButton.click();
  await BrowserTestUtils.waitForEvent(win.document, "ViewShown");

  is(
    overflowPanel.getAttribute("remote"),
    "true",
    "Pocket overflow panel has remote attribute"
  );

  // Close panel and cleanup.
  let overflowPanelHidden = popupHidden(overflowPanel);
  overflowPanel.hidePopup();
  await overflowPanelHidden;
  overflowPanel.removeAttribute("animate");
  await BrowserTestUtils.closeWindow(win);
});