Backed out 7 changesets (bug 1845150) for causing dt failures on browser_screenshot_b...
[gecko.git] / browser / components / protocolhandler / test / browser / browser_registerProtocolHandler_notification.js
blobe96ed7060eea8dab073f669952458ea87d05395f
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/. */
5 const TEST_PATH = getRootDirectory(gTestPath).replace(
6   "chrome://mochitests/content",
7   "https://example.com"
8 );
9 add_task(async function () {
10   let notificationValue = "Protocol Registration: web+testprotocol";
11   let testURI = TEST_PATH + "browser_registerProtocolHandler_notification.html";
13   BrowserTestUtils.startLoadingURIString(
14     window.gBrowser.selectedBrowser,
15     testURI
16   );
17   await TestUtils.waitForCondition(
18     function () {
19       // Do not start until the notification is up
20       let notificationBox = window.gBrowser.getNotificationBox();
21       let notification =
22         notificationBox.getNotificationWithValue(notificationValue);
23       return notification;
24     },
25     "Still can not get notification after retrying 100 times.",
26     100,
27     100
28   );
30   let notificationBox = window.gBrowser.getNotificationBox();
31   let notification =
32     notificationBox.getNotificationWithValue(notificationValue);
33   ok(notification, "Notification box should be displayed");
34   if (notification == null) {
35     finish();
36     return;
37   }
38   is(
39     notification.getAttribute("type"),
40     "info",
41     "We expect this notification to have the type of 'info'."
42   );
44   // Make sure the CSS is fully loaded...
45   ok(
46     await TestUtils.waitForCondition(
47       () =>
48         notification.ownerGlobal.getComputedStyle(
49           notification.messageImage,
50           "::after"
51         ).backgroundImage == 'url("chrome://global/skin/icons/info-filled.svg")'
52     ),
53     "We expect this notification to have an icon."
54   );
56   let buttons = notification.buttonContainer.getElementsByClassName(
57     "notification-button"
58   );
59   is(buttons.length, 1, "We expect see one button.");
61   let button = buttons[0];
62   isnot(button.label, null, "We expect the add button to have a label.");
63   todo(button.accesskey, "We expect the add button to have a accesskey.");
64 });