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 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 "use strict";
6 module.metadata = {
7 "stability": "experimental"
8 };
10 var { exit, stdout } = require("../system");
11 var cfxArgs = require("@test/options");
13 function runTests(findAndRunTests) {
14 var harness = require("./harness");
16 function onDone(tests) {
17 stdout.write("\n");
18 var total = tests.passed + tests.failed;
19 stdout.write(tests.passed + " of " + total + " tests passed.\n");
21 if (tests.failed == 0) {
22 if (tests.passed === 0)
23 stdout.write("No tests were run\n");
24 exit(0);
25 } else {
26 if (cfxArgs.verbose || cfxArgs.parseable)
27 printFailedTests(tests, stdout.write);
28 exit(1);
29 }
30 };
32 // We may have to run test on next cycle, otherwise XPCOM components
33 // are not correctly updated.
34 // For ex: nsIFocusManager.getFocusedElementForWindow may throw
35 // NS_ERROR_ILLEGAL_VALUE exception.
36 require("../timers").setTimeout(function () {
37 harness.runTests({
38 findAndRunTests: findAndRunTests,
39 iterations: cfxArgs.iterations || 1,
40 filter: cfxArgs.filter,
41 profileMemory: cfxArgs.profileMemory,
42 stopOnError: cfxArgs.stopOnError,
43 verbose: cfxArgs.verbose,
44 parseable: cfxArgs.parseable,
45 print: stdout.write,
46 onDone: onDone
47 });
48 }, 0);
49 }
51 function printFailedTests(tests, print) {
52 let iterationNumber = 0;
53 let singleIteration = tests.testRuns.length == 1;
54 let padding = singleIteration ? "" : " ";
56 print("\nThe following tests failed:\n");
58 for each (let testRun in tests.testRuns) {
59 iterationNumber++;
61 if (!singleIteration)
62 print(" Iteration " + iterationNumber + ":\n");
64 for each (let test in testRun) {
65 if (test.failed > 0) {
66 print(padding + " " + test.name + ": " + test.errors +"\n");
67 }
68 }
69 print("\n");
70 }
71 }
73 function main() {
74 var testsStarted = false;
76 if (!testsStarted) {
77 testsStarted = true;
78 runTests(function findAndRunTests(loader, nextIteration) {
79 loader.require("../deprecated/unit-test").findAndRunTests({
80 testOutOfProcess: false,
81 testInProcess: true,
82 stopOnError: cfxArgs.stopOnError,
83 filter: cfxArgs.filter,
84 onDone: nextIteration
85 });
86 });
87 }
88 };
90 if (require.main === module)
91 main();
93 exports.runTestsFromModule = function runTestsFromModule(module) {
94 let id = module.id;
95 // Make a copy of exports as it may already be frozen by module loader
96 let exports = {};
97 Object.keys(module.exports).forEach(function(key) {
98 exports[key] = module.exports[key];
99 });
101 runTests(function findAndRunTests(loader, nextIteration) {
102 // Consider that all these tests are CommonJS ones
103 loader.require('../../test').run(exports);
105 // Reproduce what is done in unit-test-finder.findTests()
106 let tests = [];
107 for each (let name in Object.keys(exports).sort()) {
108 tests.push({
109 setup: exports.setup,
110 teardown: exports.teardown,
111 testFunction: exports[name],
112 name: id + "." + name
113 });
114 }
116 // Reproduce what is done by unit-test.findAndRunTests()
117 var { TestRunner } = loader.require("../deprecated/unit-test");
118 var runner = new TestRunner();
119 runner.startMany({
120 tests: tests,
121 stopOnError: cfxArgs.stopOnError,
122 onDone: nextIteration
123 });
124 });
125 }