summaryrefslogtreecommitdiffstats
path: root/browser/components/protocolhandler/test/browser/browser_registerProtocolHandler_notification.js
blob: 0f4e41f1a3e8eb86674bba9a48fa98f8f92ce74a (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
/* 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/. */

const TEST_PATH = getRootDirectory(gTestPath).replace(
  "chrome://mochitests/content",
  "https://example.com"
);
add_task(async function () {
  let notificationValue = "Protocol Registration: web+testprotocol";
  let testURI = TEST_PATH + "browser_registerProtocolHandler_notification.html";

  BrowserTestUtils.loadURIString(window.gBrowser.selectedBrowser, testURI);
  await TestUtils.waitForCondition(
    function () {
      // Do not start until the notification is up
      let notificationBox = window.gBrowser.getNotificationBox();
      let notification =
        notificationBox.getNotificationWithValue(notificationValue);
      return notification;
    },
    "Still can not get notification after retrying 100 times.",
    100,
    100
  );

  let notificationBox = window.gBrowser.getNotificationBox();
  let notification =
    notificationBox.getNotificationWithValue(notificationValue);
  ok(notification, "Notification box should be displayed");
  if (notification == null) {
    finish();
    return;
  }
  is(
    notification.getAttribute("type"),
    "info",
    "We expect this notification to have the type of 'info'."
  );

  // Make sure the CSS is fully loaded...
  ok(
    await TestUtils.waitForCondition(
      () =>
        notification.ownerGlobal.getComputedStyle(
          notification.messageImage,
          "::after"
        ).content == 'url("chrome://global/skin/icons/info-filled.svg")'
    ),
    "We expect this notification to have an icon."
  );

  let buttons = notification.buttonContainer.getElementsByClassName(
    "notification-button"
  );
  is(buttons.length, 1, "We expect see one button.");

  let button = buttons[0];
  isnot(button.label, null, "We expect the add button to have a label.");
  todo(button.accesskey, "We expect the add button to have a accesskey.");
});