Bug 1705270 - Fix assert when compositor surface is in a pass-through picture r=gfx...
[gecko.git] / browser / base / content / test / notificationbox / browser_notification_stacking.js
blobca9166ce91b0df55318870a356817402721f8b6e
1 /* Any copyright is dedicated to the Public Domain.
2    http://creativecommons.org/publicdomain/zero/1.0/ */
4 "use strict";
6 async function addNotification(box, label, value, priorityName) {
7   let added = BrowserTestUtils.waitForNotificationInNotificationBox(box, value);
8   let priority =
9     gHighPriorityNotificationBox[`PRIORITY_${priorityName}_MEDIUM`];
10   let notification = box.appendNotification(label, value, null, priority);
11   await added;
12   return notification;
15 add_task(async function setup() {
16   await SpecialPowers.pushPrefEnv({
17     set: [["browser.proton.enabled", true]],
18   });
19 });
21 add_task(async function testStackingOrder() {
22   const tabNotificationBox = gBrowser.getNotificationBox();
23   ok(
24     gHighPriorityNotificationBox.stack.hasAttribute("prepend-notifications"),
25     "Browser stack will prepend"
26   );
27   ok(
28     !tabNotificationBox.stack.hasAttribute("prepend-notifications"),
29     "Tab stack will append"
30   );
32   let browserOne = await addNotification(
33     gHighPriorityNotificationBox,
34     "My first browser notification",
35     "browser-one",
36     "INFO"
37   );
39   let tabOne = await addNotification(
40     tabNotificationBox,
41     "My first tab notification",
42     "tab-one",
43     "CRITICAL"
44   );
46   let browserTwo = await addNotification(
47     gHighPriorityNotificationBox,
48     "My second browser notification",
49     "browser-two",
50     "CRITICAL"
51   );
52   let browserThree = await addNotification(
53     gHighPriorityNotificationBox,
54     "My third browser notification",
55     "browser-three",
56     "WARNING"
57   );
59   let tabTwo = await addNotification(
60     tabNotificationBox,
61     "My second tab notification",
62     "tab-two",
63     "INFO"
64   );
65   let tabThree = await addNotification(
66     tabNotificationBox,
67     "My third tab notification",
68     "tab-three",
69     "WARNING"
70   );
72   Assert.deepEqual(
73     [browserThree, browserTwo, browserOne],
74     [...gHighPriorityNotificationBox.stack.children],
75     "Browser notifications prepended"
76   );
77   Assert.deepEqual(
78     [tabOne, tabTwo, tabThree],
79     [...tabNotificationBox.stack.children],
80     "Tab notifications appended"
81   );
83   gHighPriorityNotificationBox.removeAllNotifications(true);
84   tabNotificationBox.removeAllNotifications(true);
85 });