toolkit/content/tests/chrome/test_bug457632.xul

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

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

mercurial