dom/alarm/test/test_bug1015540.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <meta charset="utf-8">
michael@0 5 <title>Test data Paramter of Alarm API for Bug 1015540</title>
michael@0 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 7 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 8 </head>
michael@0 9 <body>
michael@0 10 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1015540">Bug 1015540</a>
michael@0 11 <p id="display"></p>
michael@0 12 <div id="content" style="display: none"></div>
michael@0 13 <pre id="test">
michael@0 14 <script type="application/javascript">
michael@0 15
michael@0 16 "use strict";
michael@0 17
michael@0 18 // Verify passing a cross-origin object for the data paramter
michael@0 19 function testCrossOriginObject() {
michael@0 20 var tomorrow = new Date();
michael@0 21 tomorrow.setDate(tomorrow.getDate() + 1);
michael@0 22
michael@0 23 var data = document.getElementById('ifr').contentWindow;
michael@0 24
michael@0 25 try {
michael@0 26 navigator.mozAlarms.add(tomorrow, "honorTimezone", data);
michael@0 27 ok(false, "Adding alarms for cross-origin objects should be prohibited.");
michael@0 28 } catch (e) {
michael@0 29 ok(true, "Adding alarms for cross-origin objects is prohibited.");
michael@0 30 }
michael@0 31
michael@0 32 SimpleTest.finish();
michael@0 33 }
michael@0 34
michael@0 35 function startTests() {
michael@0 36 SpecialPowers.pushPrefEnv({
michael@0 37 "set": [["dom.mozAlarms.enabled", true]]
michael@0 38 }, function() {
michael@0 39 SpecialPowers.addPermission("alarms", true, document);
michael@0 40 var isAllowedToTest = true;
michael@0 41
michael@0 42 if (navigator.appVersion.indexOf("Android") !== -1) {
michael@0 43 ok(true, "mozAlarms is not allowed on Android for now. " +
michael@0 44 "TODO Bug 863557.");
michael@0 45 isAllowedToTest = false;
michael@0 46 } else if (SpecialPowers.wrap(document).nodePrincipal.appStatus ==
michael@0 47 SpecialPowers.Ci.nsIPrincipal.APP_STATUS_NOT_INSTALLED) {
michael@0 48 ok(true, "mozAlarms is not allowed for non-installed apps. " +
michael@0 49 "TODO Bug 876981.");
michael@0 50 isAllowedToTest = false;
michael@0 51 }
michael@0 52
michael@0 53 if (isAllowedToTest) {
michael@0 54 ok(true, "Start to test...");
michael@0 55 testCrossOriginObject();
michael@0 56 } else {
michael@0 57 // A sanity check to make sure we must run tests on Firefox OS (B2G).
michael@0 58 if (navigator.userAgent.indexOf("Mobile") != -1 &&
michael@0 59 navigator.appVersion.indexOf("Android") == -1) {
michael@0 60 ok(false, "Should run the test on Firefox OS (B2G)!");
michael@0 61 }
michael@0 62
michael@0 63 SimpleTest.finish();
michael@0 64 }
michael@0 65 });
michael@0 66 }
michael@0 67
michael@0 68 SimpleTest.waitForExplicitFinish();
michael@0 69 </script>
michael@0 70 </pre>
michael@0 71 <iframe id="ifr" onload="startTests()" src="http://example.org/tests/dom/alarm/test/file_empty.html"></iframe>
michael@0 72 </body>
michael@0 73 </html>

mercurial