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 | <!-- Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | - http://creativecommons.org/publicdomain/zero/1.0/ --> |
michael@0 | 3 | <!DOCTYPE HTML> |
michael@0 | 4 | <html> |
michael@0 | 5 | <head> |
michael@0 | 6 | <title>Test hidden frames</title> |
michael@0 | 7 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 8 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 9 | </head> |
michael@0 | 10 | <body> |
michael@0 | 11 | <script type="text/javascript" src="mock_gamepad.js"></script> |
michael@0 | 12 | <script class="testbody" type="text/javascript"> |
michael@0 | 13 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 14 | var index = GamepadService.addGamepad("test gamepad", // id |
michael@0 | 15 | SpecialPowers.Ci.nsIGamepadServiceTest.NO_MAPPING, |
michael@0 | 16 | 4, // buttons |
michael@0 | 17 | 2);// axes |
michael@0 | 18 | |
michael@0 | 19 | function pressButton() { |
michael@0 | 20 | GamepadService.newButtonEvent(index, 0, true); |
michael@0 | 21 | GamepadService.newButtonEvent(index, 0, false); |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | function setFrameVisible(f, visible) { |
michael@0 | 25 | var Ci = SpecialPowers.Ci; |
michael@0 | 26 | var docshell = SpecialPowers.wrap(f.contentWindow).QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShell); |
michael@0 | 27 | docshell.isActive = visible; |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | var frames_loaded = 0; |
michael@0 | 31 | var f1, f2; |
michael@0 | 32 | function frame_loaded() { |
michael@0 | 33 | frames_loaded++; |
michael@0 | 34 | if (frames_loaded == 2) { |
michael@0 | 35 | f1 = document.getElementById('f1'); |
michael@0 | 36 | f2 = document.getElementById('f2'); |
michael@0 | 37 | pressButton(); |
michael@0 | 38 | } |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | window.addEventListener("gamepadbuttondown", function() { |
michael@0 | 42 | // Wait to ensure that all frames received the button press as well. |
michael@0 | 43 | SpecialPowers.executeSoon(tests[testNum++]); |
michael@0 | 44 | }); |
michael@0 | 45 | |
michael@0 | 46 | var testNum = 0; |
michael@0 | 47 | var tests = [ |
michael@0 | 48 | test1, |
michael@0 | 49 | test2, |
michael@0 | 50 | ]; |
michael@0 | 51 | |
michael@0 | 52 | function test1() { |
michael@0 | 53 | is(f1.contentWindow.buttonPresses, 1, "right number of button presses in frame 1"); |
michael@0 | 54 | is(f2.contentWindow.buttonPresses, 1, "right number of button presses in frame 2"); |
michael@0 | 55 | |
michael@0 | 56 | // Now hide the second frame and send another button press. |
michael@0 | 57 | setFrameVisible(f2, false); |
michael@0 | 58 | SpecialPowers.executeSoon(function() { pressButton(); }); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | function test2() { |
michael@0 | 62 | is(f1.contentWindow.buttonPresses, 2, "right number of button presses in frame 1"); |
michael@0 | 63 | is(f2.contentWindow.buttonPresses, 1, "right number of button presses in frame 2"); |
michael@0 | 64 | GamepadService.removeGamepad(index); |
michael@0 | 65 | SimpleTest.finish(); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | </script> |
michael@0 | 69 | <iframe id="f1" src="gamepad_frame.html" onload="frame_loaded()"></iframe> |
michael@0 | 70 | <iframe id="f2" src="gamepad_frame.html" onload="frame_loaded()"></iframe> |
michael@0 | 71 | </body> |
michael@0 | 72 | </html> |