dom/browser-element/mochitest/priority/test_Preallocated.html

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

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

mercurial