Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 Test if Nuwa process created successfully.
5 -->
6 <head>
7 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
9 </head>
10 <body>
12 <script type="application/javascript;version=1.7">
13 "use strict";
15 SimpleTest.waitForExplicitFinish();
17 function TestLoader() {}
19 TestLoader.prototype = {
20 _waitingTask: 0,
21 onTestReady: null,
22 unlockTestReady: function() {
23 this._waitingTask--;
24 this._maybeLoadTest();
25 },
26 lockTestReady: function() {
27 this._waitingTask++;
28 },
29 _maybeLoadTest: function() {
30 if (this._waitingTask == 0) {
31 this.onTestReady();
32 }
33 }
34 }
36 var testLoader = new TestLoader();
37 testLoader.lockTestReady();
38 window.addEventListener('load', function() {
39 testLoader.unlockTestReady();
40 });
42 function setPref(pref, value) {
43 testLoader.lockTestReady();
44 if (value !== undefined && value !== null) {
45 SpecialPowers.pushPrefEnv({'set': [[pref, value]]}, function() { testLoader.unlockTestReady(); });
46 } else {
47 SpecialPowers.pushPrefEnv({'clear': [[pref]]}, function() { testLoader.unlockTestReady(); });
48 }
49 }
51 setPref('dom.ipc.processPriorityManager.testMode', true);
52 setPref('dom.ipc.processPriorityManager.enabled', true);
53 setPref('dom.ipc.processPriorityManager.backgroundLRUPoolLevels', 2);
54 setPref('dom.ipc.processPrelaunch.testMode', true); // For testing deadlock.
56 function runTest()
57 {
58 // Shutdown preallocated process.
59 SpecialPowers.setBoolPref('dom.ipc.processPrelaunch.enabled', false);
60 let cpmm = SpecialPowers.Cc["@mozilla.org/childprocessmessagemanager;1"]
61 .getService(SpecialPowers.Ci.nsISyncMessageSender);
62 let seenNuwaReady = false;
63 let msgHandler = {
64 receiveMessage: function receiveMessage(msg) {
65 msg = SpecialPowers.wrap(msg);
66 if (msg.name == 'TEST-ONLY:nuwa-ready') {
67 ok(true, "Got nuwa-ready");
68 is(seenNuwaReady, false, "Already received nuwa ready");
69 seenNuwaReady = true;
70 } else if (msg.name == 'TEST-ONLY:nuwa-add-new-process') {
71 ok(true, "Got nuwa-add-new-process");
72 is(seenNuwaReady, true, "Receive nuwa-add-new-process before nuwa-ready");
73 testEnd();
74 }
75 }
76 };
77 let timeout = setTimeout(function() {
78 ok(false, "Nuwa process is not launched");
79 testEnd();
80 }, 90000);
82 function testEnd() {
83 cpmm.removeMessageListener("TEST-ONLY:nuwa-ready", msgHandler);
84 cpmm.removeMessageListener("TEST-ONLY:nuwa-add-new-process", msgHandler);
85 clearTimeout(timeout);
86 setPref('dom.ipc.processPrelaunch.testMode', false);
87 SimpleTest.finish();
88 }
90 cpmm.addMessageListener("TEST-ONLY:nuwa-ready", msgHandler);
91 cpmm.addMessageListener("TEST-ONLY:nuwa-add-new-process", msgHandler);
94 // Setting this pref to true should cause us to prelaunch a process.
95 SpecialPowers.setBoolPref('dom.ipc.processPrelaunch.enabled', true);
96 }
98 testLoader.onTestReady = runTest;
99 </script>
100 </body>
101 </html>