Tue, 06 Jan 2015 21:39:09 +0100
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 | <title>Test for idle api permissions</title> |
michael@0 | 5 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 7 | </head> |
michael@0 | 8 | <body> |
michael@0 | 9 | <p id="display"></p> |
michael@0 | 10 | <div id="content" style="display: none"> |
michael@0 | 11 | </div> |
michael@0 | 12 | <pre id="test"> |
michael@0 | 13 | <script type="application/javascript"> |
michael@0 | 14 | |
michael@0 | 15 | var idleObserver = { |
michael@0 | 16 | onidle: null, |
michael@0 | 17 | onactive: null |
michael@0 | 18 | }; |
michael@0 | 19 | |
michael@0 | 20 | function doAddIdleObserver(obs) { |
michael@0 | 21 | var i = document.createElement("iframe"); |
michael@0 | 22 | document.body.appendChild(i); |
michael@0 | 23 | var added = false; |
michael@0 | 24 | try { |
michael@0 | 25 | i.contentWindow.navigator.addIdleObserver(obs); |
michael@0 | 26 | added = true; |
michael@0 | 27 | } catch (e) { } |
michael@0 | 28 | i.remove(); |
michael@0 | 29 | return added; |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function run_test() { |
michael@0 | 33 | // addIdleObserver checks whether time is > 0. |
michael@0 | 34 | this.idleObserver.time = 100; |
michael@0 | 35 | |
michael@0 | 36 | var added = doAddIdleObserver(this.idleObserver, false); |
michael@0 | 37 | ok(!added, "Should not be able to add idle observer without permission"); |
michael@0 | 38 | |
michael@0 | 39 | SpecialPowers.addPermission("idle", true, document); |
michael@0 | 40 | |
michael@0 | 41 | added = doAddIdleObserver(this.idleObserver, true); |
michael@0 | 42 | ok(added, "Should be able to add idle observer with permission."); |
michael@0 | 43 | |
michael@0 | 44 | SimpleTest.finish(); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 48 | addLoadEvent(run_test); |
michael@0 | 49 | </script> |
michael@0 | 50 | </pre> |
michael@0 | 51 | </body> |
michael@0 | 52 | </html> |