Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | Test that the preallocated process starts up with priority BACKGROUND. |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 8 | <script type="application/javascript" src="../browserElementTestHelpers.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | |
michael@0 | 13 | <script type="application/javascript;version=1.7"> |
michael@0 | 14 | "use strict"; |
michael@0 | 15 | |
michael@0 | 16 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 17 | browserElementTestHelpers.setEnabledPref(true); |
michael@0 | 18 | browserElementTestHelpers.addPermission(); |
michael@0 | 19 | browserElementTestHelpers.enableProcessPriorityManager(); |
michael@0 | 20 | |
michael@0 | 21 | var preallocationEnabledPref = null; |
michael@0 | 22 | try { |
michael@0 | 23 | preallocationEnabledPref = SpecialPowers.getBoolPref('dom.ipc.processPrelaunch.enabled'); |
michael@0 | 24 | } |
michael@0 | 25 | catch(e) { |
michael@0 | 26 | preallocationEnabledPref = null; |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | var childID = null; |
michael@0 | 30 | |
michael@0 | 31 | var cleanedUp = false; |
michael@0 | 32 | function cleanUp() |
michael@0 | 33 | { |
michael@0 | 34 | if (cleanedUp) { |
michael@0 | 35 | return; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | cleanedUp = true; |
michael@0 | 39 | |
michael@0 | 40 | if (preallocationEnabledPref === null) { |
michael@0 | 41 | SpecialPowers.clearUserPref('dom.ipc.processPrelaunch.enabled'); |
michael@0 | 42 | } else { |
michael@0 | 43 | SpecialPowers.setBoolPref('dom.ipc.processPrelaunch.enabled', |
michael@0 | 44 | preallocationEnabledPref); |
michael@0 | 45 | } |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | // Even if this test times out, we still want to run cleanUp so as to set the |
michael@0 | 49 | // pref back. |
michael@0 | 50 | addEventListener('unload', cleanUp); |
michael@0 | 51 | |
michael@0 | 52 | function runTest() |
michael@0 | 53 | { |
michael@0 | 54 | if (preallocationEnabledPref) { |
michael@0 | 55 | ok(false, "dom.ipc.processPrelaunch.enabled must be " + |
michael@0 | 56 | "false for this test to work."); |
michael@0 | 57 | SimpleTest.finish(); |
michael@0 | 58 | return; |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | // Ensure that the preallocated process initially gets BACKGROUND priority. |
michael@0 | 62 | // That's it. |
michael@0 | 63 | expectProcessCreated().then(function(childID) { |
michael@0 | 64 | return expectPriorityChange(childID, 'PREALLOC', 'CPU_LOW'); |
michael@0 | 65 | }).then(function() { |
michael@0 | 66 | // We need to set the pref asynchoronously or the preallocated process won't |
michael@0 | 67 | // be shut down. |
michael@0 | 68 | SimpleTest.executeSoon(function(){ |
michael@0 | 69 | cleanUp(); |
michael@0 | 70 | SimpleTest.finish(); |
michael@0 | 71 | }); |
michael@0 | 72 | }); |
michael@0 | 73 | |
michael@0 | 74 | // Setting this pref to true should cause us to prelaunch a process. |
michael@0 | 75 | SpecialPowers.setBoolPref('dom.ipc.processPrelaunch.enabled', true); |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | addEventListener('testready', runTest); |
michael@0 | 79 | </script> |
michael@0 | 80 | </body> |
michael@0 | 81 | </html> |