dom/ipc/tests/test_NuwaProcessDeadlock.html
author Mike Hommey <mh+mozilla@glandium.org>
Wed, 10 Jun 2015 09:58:50 +0900
changeset 247858 5c0acaf8f47857f634ffdf3151f5418f18cbb97d
parent 238234 a255a2f9d4f3e50ec3fbeb8b8b4a02f94e1d399d
child 268239 a682a92c03095b9ffaf65afec837f8dd2599bcb5
permissions -rw-r--r--
bug 1172632 - Move some allocator related configure checks in a common location for both top-level and js/src to use. r=mshal

<!DOCTYPE HTML>
<html>
<!--
Test if Nuwa process created successfully.
-->
<head>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body onload="setup()">

<script type="application/javascript;version=1.7">
"use strict";

function runTest()
{
  info("Launch the Nuwa process");
  let cpmm = SpecialPowers.Cc["@mozilla.org/childprocessmessagemanager;1"]
                          .getService(SpecialPowers.Ci.nsISyncMessageSender);
  let seenNuwaReady = false;
  let msgHandler = {
    receiveMessage: function receiveMessage(msg) {
      msg = SpecialPowers.wrap(msg);
      if (msg.name == 'TEST-ONLY:nuwa-ready') {
        ok(true, "Got nuwa-ready");
        is(seenNuwaReady, false, "Already received nuwa ready");
        seenNuwaReady = true;
      } else if (msg.name == 'TEST-ONLY:nuwa-add-new-process') {
        ok(true, "Got nuwa-add-new-process");
        is(seenNuwaReady, true, "Receive nuwa-add-new-process before nuwa-ready");
        shutdown();
      }
    }
  };

  function shutdown() {
    info("Shut down the test case");
    cpmm.removeMessageListener("TEST-ONLY:nuwa-ready", msgHandler);
    cpmm.removeMessageListener("TEST-ONLY:nuwa-add-new-process", msgHandler);

    SimpleTest.finish();
  }

  cpmm.addMessageListener("TEST-ONLY:nuwa-ready", msgHandler);
  cpmm.addMessageListener("TEST-ONLY:nuwa-add-new-process", msgHandler);


  // Setting this pref to true should cause us to prelaunch a process.
  SpecialPowers.setBoolPref('dom.ipc.processPrelaunch.enabled', true);
}

function setup()
{
  info("Set up preferences for testing deadlock in the Nuwa process.");
  SimpleTest.waitForExplicitFinish();

  SpecialPowers.pushPrefEnv({
    'set': [
      ['dom.ipc.processPrelaunch.enabled', false],
      ['dom.ipc.preallocatedProcessManager.testMode', true],
      ['dom.ipc.processPrelaunch.testMode', true]  // For testing deadlock
    ]
  }, runTest);
}

</script>
</body>
</html>