dom/alarm/test/test_bug1037079.html

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 <!DOCTYPE HTML>
     2 <html>
     3 <head>
     4   <meta charset="utf-8">
     5   <title>Test time alert is fired for Bug 1037079</title>
     6   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     7   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     8 </head>
     9 <body>
    10 <p id="display"></p>
    11 <div id="content" style="display: none"></div>
    12 <pre id="test">
    13   <script type="application/javascript">
    15   "use strict";
    17   function testFireTimeAlert() {
    18     var secondsLater = new Date();
    19     secondsLater.setSeconds(secondsLater.getSeconds() + 10);
    21     var domRequest;
    22     try {
    23       // Set system message handler.
    24       navigator.mozSetMessageHandler('alarm', function(message){
    25         ok(true, "Time alert has been fired.");
    26         SimpleTest.finish();
    27       });
    29       domRequest = navigator.mozAlarms.add(secondsLater, "honorTimezone",
    30     		                               {type: "timer"});
    31     } catch (e) {
    32       ok(false, "Unexpected exception trying to set time alert.");
    34       return SimpleTest.finish();
    35     }
    36     domRequest.onsuccess = function(e) {
    37       ok(true, "Set time alert. Waiting to be fired.");
    38     };
    39     domRequest.onerror = function(e) {
    40       ok(false, "Unable to set time alert.");
    42       SimpleTest.finish();
    43     };
    44   }
    46   function startTests() {
    47     SpecialPowers.pushPrefEnv({
    48       "set": [["dom.mozAlarms.enabled", true]]
    49     }, function() {
    50       var isAllowedToTest = true;
    52       if (navigator.appVersion.indexOf("Android") !== -1) {
    53         ok(true, "mozAlarms is not allowed on Android for now. " +
    54                  "TODO Bug 863557.");
    55         isAllowedToTest = false;
    56       } else if (SpecialPowers.wrap(document).nodePrincipal.appStatus ==
    57                  SpecialPowers.Ci.nsIPrincipal.APP_STATUS_NOT_INSTALLED) {
    58         ok(true, "mozAlarms is not allowed for non-installed apps. " +
    59                  "TODO Bug 876981.");
    60         isAllowedToTest = false;
    61       }
    63       if (isAllowedToTest) {
    64         ok(true, "Start to test...");
    65         testFireTimeAlert();
    66       } else {
    67         // A sanity check to make sure we must run tests on Firefox OS (B2G).
    68         if (navigator.userAgent.indexOf("Mobile") != -1 &&
    69             navigator.appVersion.indexOf("Android") == -1) {
    70           ok(false, "Should run the test on Firefox OS (B2G)!");
    71         }
    73         SimpleTest.finish();
    74       }
    75     });
    76   }
    78   SimpleTest.expectAssertions(0, 9);
    79   SimpleTest.waitForExplicitFinish();
    80   if (SpecialPowers.hasPermission("alarms", document)) {
    81     startTests();
    82   } else {
    83     // Add the permissions and reload so they propogate
    84     SpecialPowers.addPermission("alarms", true, document);
    85     window.location.reload();
    86   }
    88   </script>
    89 </pre>
    90 </body>
    91 </html>

mercurial