Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 3 | <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
michael@0 | 4 | <!-- |
michael@0 | 5 | XUL Widget Test for bug 457632 |
michael@0 | 6 | --> |
michael@0 | 7 | <window title="Bug 457632" width="500" height="600" |
michael@0 | 8 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 9 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | |
michael@0 | 11 | <notificationbox id="nb"/> |
michael@0 | 12 | |
michael@0 | 13 | <!-- test results are displayed in the html:body --> |
michael@0 | 14 | <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;" |
michael@0 | 15 | onload="test()"/> |
michael@0 | 16 | |
michael@0 | 17 | <!-- test code goes here --> |
michael@0 | 18 | <script type="application/javascript"> |
michael@0 | 19 | <![CDATA[ |
michael@0 | 20 | var gNotificationBox; |
michael@0 | 21 | |
michael@0 | 22 | function completeAnimation(nextTest) { |
michael@0 | 23 | if (!gNotificationBox._animating) { |
michael@0 | 24 | nextTest(); |
michael@0 | 25 | return; |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | setTimeout(completeAnimation, 50, nextTest); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | function test() { |
michael@0 | 32 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 33 | gNotificationBox = document.getElementById("nb"); |
michael@0 | 34 | |
michael@0 | 35 | is(gNotificationBox.allNotifications.length, 0, "There should be no initial notifications"); |
michael@0 | 36 | gNotificationBox.appendNotification("Test notification", |
michael@0 | 37 | "notification1", null, |
michael@0 | 38 | gNotificationBox.PRIORITY_INFO_LOW, |
michael@0 | 39 | null); |
michael@0 | 40 | is(gNotificationBox.allNotifications.length, 1, "Notification exists while animating in"); |
michael@0 | 41 | let notification = gNotificationBox.getNotificationWithValue("notification1"); |
michael@0 | 42 | ok(notification, "Notification should exist while animating in"); |
michael@0 | 43 | |
michael@0 | 44 | // Wait for the notificaton to finish displaying |
michael@0 | 45 | completeAnimation(test1); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | // Tests that a notification that is fully animated in gets removed immediately |
michael@0 | 49 | function test1() { |
michael@0 | 50 | let notification = gNotificationBox.getNotificationWithValue("notification1"); |
michael@0 | 51 | gNotificationBox.removeNotification(notification); |
michael@0 | 52 | notification = gNotificationBox.getNotificationWithValue("notification1"); |
michael@0 | 53 | ok(!notification, "Test 1 showed notification was still present"); |
michael@0 | 54 | ok(!gNotificationBox.currentNotification, "Test 1 said there was still a current notification"); |
michael@0 | 55 | is(gNotificationBox.allNotifications.length, 0, "Test 1 should show no notifications present"); |
michael@0 | 56 | |
michael@0 | 57 | // Wait for the notificaton to finish hiding |
michael@0 | 58 | completeAnimation(test2); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | // Tests that a notification that is animating in gets removed immediately |
michael@0 | 62 | function test2() { |
michael@0 | 63 | let notification = gNotificationBox.appendNotification("Test notification", |
michael@0 | 64 | "notification2", null, |
michael@0 | 65 | gNotificationBox.PRIORITY_INFO_LOW, |
michael@0 | 66 | null); |
michael@0 | 67 | gNotificationBox.removeNotification(notification); |
michael@0 | 68 | notification = gNotificationBox.getNotificationWithValue("notification2"); |
michael@0 | 69 | ok(!notification, "Test 2 showed notification was still present"); |
michael@0 | 70 | ok(!gNotificationBox.currentNotification, "Test 2 said there was still a current notification"); |
michael@0 | 71 | is(gNotificationBox.allNotifications.length, 0, "Test 2 should show no notifications present"); |
michael@0 | 72 | |
michael@0 | 73 | // Get rid of the hiding notifications |
michael@0 | 74 | gNotificationBox.removeAllNotifications(true); |
michael@0 | 75 | test3(); |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | // Tests that a background notification goes away immediately |
michael@0 | 79 | function test3() { |
michael@0 | 80 | let notification = gNotificationBox.appendNotification("Test notification", |
michael@0 | 81 | "notification3", null, |
michael@0 | 82 | gNotificationBox.PRIORITY_INFO_LOW, |
michael@0 | 83 | null); |
michael@0 | 84 | let notification2 = gNotificationBox.appendNotification("Test notification", |
michael@0 | 85 | "notification4", null, |
michael@0 | 86 | gNotificationBox.PRIORITY_INFO_LOW, |
michael@0 | 87 | null); |
michael@0 | 88 | is(gNotificationBox.allNotifications.length, 2, "Test 3 should show 2 notifications present"); |
michael@0 | 89 | gNotificationBox.removeNotification(notification); |
michael@0 | 90 | is(gNotificationBox.allNotifications.length, 1, "Test 3 should show 1 notifications present"); |
michael@0 | 91 | notification = gNotificationBox.getNotificationWithValue("notification3"); |
michael@0 | 92 | ok(!notification, "Test 3 showed notification was still present"); |
michael@0 | 93 | gNotificationBox.removeNotification(notification2); |
michael@0 | 94 | is(gNotificationBox.allNotifications.length, 0, "Test 3 should show 0 notifications present"); |
michael@0 | 95 | notification2 = gNotificationBox.getNotificationWithValue("notification4"); |
michael@0 | 96 | ok(!notification2, "Test 3 showed notification2 was still present"); |
michael@0 | 97 | ok(!gNotificationBox.currentNotification, "Test 3 said there was still a current notification"); |
michael@0 | 98 | |
michael@0 | 99 | // Get rid of the hiding notifications |
michael@0 | 100 | gNotificationBox.removeAllNotifications(true); |
michael@0 | 101 | test4(); |
michael@0 | 102 | } |
michael@0 | 103 | |
michael@0 | 104 | // Tests that a foreground notification hiding a background one goes away |
michael@0 | 105 | function test4() { |
michael@0 | 106 | let notification = gNotificationBox.appendNotification("Test notification", |
michael@0 | 107 | "notification5", null, |
michael@0 | 108 | gNotificationBox.PRIORITY_INFO_LOW, |
michael@0 | 109 | null); |
michael@0 | 110 | let notification2 = gNotificationBox.appendNotification("Test notification", |
michael@0 | 111 | "notification6", null, |
michael@0 | 112 | gNotificationBox.PRIORITY_INFO_LOW, |
michael@0 | 113 | null); |
michael@0 | 114 | gNotificationBox.removeNotification(notification2); |
michael@0 | 115 | notification2 = gNotificationBox.getNotificationWithValue("notification6"); |
michael@0 | 116 | ok(!notification2, "Test 4 showed notification2 was still present"); |
michael@0 | 117 | is(gNotificationBox.currentNotification, notification, "Test 4 said the current notification was wrong"); |
michael@0 | 118 | is(gNotificationBox.allNotifications.length, 1, "Test 4 should show 1 notifications present"); |
michael@0 | 119 | gNotificationBox.removeNotification(notification); |
michael@0 | 120 | notification = gNotificationBox.getNotificationWithValue("notification5"); |
michael@0 | 121 | ok(!notification, "Test 4 showed notification was still present"); |
michael@0 | 122 | ok(!gNotificationBox.currentNotification, "Test 4 said there was still a current notification"); |
michael@0 | 123 | is(gNotificationBox.allNotifications.length, 0, "Test 4 should show 0 notifications present"); |
michael@0 | 124 | |
michael@0 | 125 | // Get rid of the hiding notifications |
michael@0 | 126 | gNotificationBox.removeAllNotifications(true); |
michael@0 | 127 | test5(); |
michael@0 | 128 | } |
michael@0 | 129 | |
michael@0 | 130 | // Tests that removeAllNotifications gets rid of everything |
michael@0 | 131 | function test5() { |
michael@0 | 132 | let notification = gNotificationBox.appendNotification("Test notification", |
michael@0 | 133 | "notification7", null, |
michael@0 | 134 | gNotificationBox.PRIORITY_INFO_LOW, |
michael@0 | 135 | null); |
michael@0 | 136 | let notification2 = gNotificationBox.appendNotification("Test notification", |
michael@0 | 137 | "notification8", null, |
michael@0 | 138 | gNotificationBox.PRIORITY_INFO_LOW, |
michael@0 | 139 | null); |
michael@0 | 140 | gNotificationBox.removeAllNotifications(); |
michael@0 | 141 | notification = gNotificationBox.getNotificationWithValue("notification7"); |
michael@0 | 142 | notification2 = gNotificationBox.getNotificationWithValue("notification8"); |
michael@0 | 143 | ok(!notification, "Test 5 showed notification was still present"); |
michael@0 | 144 | ok(!notification2, "Test 5 showed notification2 was still present"); |
michael@0 | 145 | ok(!gNotificationBox.currentNotification, "Test 5 said there was still a current notification"); |
michael@0 | 146 | is(gNotificationBox.allNotifications.length, 0, "Test 5 should show 0 notifications present"); |
michael@0 | 147 | |
michael@0 | 148 | gNotificationBox.appendNotification("Test notification", |
michael@0 | 149 | "notification9", null, |
michael@0 | 150 | gNotificationBox.PRIORITY_INFO_LOW, |
michael@0 | 151 | null); |
michael@0 | 152 | |
michael@0 | 153 | // Wait for the notificaton to finish displaying |
michael@0 | 154 | completeAnimation(test6); |
michael@0 | 155 | } |
michael@0 | 156 | |
michael@0 | 157 | // Tests whether removing an already removed notification doesn't break things |
michael@0 | 158 | function test6() { |
michael@0 | 159 | let notification = gNotificationBox.getNotificationWithValue("notification9"); |
michael@0 | 160 | ok(notification, "Test 6 should have an initial notification"); |
michael@0 | 161 | gNotificationBox.removeNotification(notification); |
michael@0 | 162 | gNotificationBox.removeNotification(notification); |
michael@0 | 163 | |
michael@0 | 164 | ok(!gNotificationBox.currentNotification, "Test 6 shouldn't be any current notification"); |
michael@0 | 165 | is(gNotificationBox.allNotifications.length, 0, "Test 6 allNotifications.length should be 0"); |
michael@0 | 166 | notification = gNotificationBox.appendNotification("Test notification", |
michael@0 | 167 | "notification10", null, |
michael@0 | 168 | gNotificationBox.PRIORITY_INFO_LOW, |
michael@0 | 169 | null); |
michael@0 | 170 | is(notification, gNotificationBox.currentNotification, "Test 6 should have made the current notification"); |
michael@0 | 171 | gNotificationBox.removeNotification(notification); |
michael@0 | 172 | |
michael@0 | 173 | SimpleTest.finish(); |
michael@0 | 174 | } |
michael@0 | 175 | ]]> |
michael@0 | 176 | </script> |
michael@0 | 177 | |
michael@0 | 178 | </window> |