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.
2 var jsdIScript = SpecialPowers.Ci.jsdIScript;
4 function f1() {
5 var x;
6 }
8 function f2() {
11 var x; var y; x = 1;
12 }
14 function f3() {
17 var x;
19 var y; var y2; y = 1;
20 var z;
22 }
24 var jsdIFilter = SpecialPowers.Ci.jsdIFilter;
26 function testJSD(jsd) {
27 ok(jsd.isOn, "JSD needs to be running for this test.");
29 jsd.functionHook = ({
30 onCall: function(frame, type) {
31 //console.log("Got " + type);
32 console.log("Got " + frame.script.fileName);
33 }
34 });
36 console.log("Triggering functions");
37 f1();
38 f2();
39 f3();
40 console.log("Done with functions");
42 var linemap = {};
43 var firsts = {};
44 var rests = {};
45 var startlines = {};
46 jsd.enumerateScripts({
47 enumerateScript: function(script) {
48 if (/execlines\.js$/.test(script.fileName)) {
49 console.log("script: " + script.fileName + " " + script.functionName);
50 var execLines = script.getExecutableLines(jsdIScript.PCMAP_SOURCETEXT, 0, 10000);
51 console.log(execLines.toSource());
52 linemap[script.functionName] = execLines;
53 startlines[script.functionName] = script.baseLineNumber;
55 execLines = script.getExecutableLines(jsdIScript.PCMAP_SOURCETEXT, 0, 1);
56 firsts[script.functionName] = execLines;
57 execLines = script.getExecutableLines(jsdIScript.PCMAP_SOURCETEXT, execLines[0]+1, 10000);
58 rests[script.functionName] = execLines;
59 }
60 }
61 });
63 var checklines = function (funcname, linemap, rellines) {
64 var base = startlines[funcname];
65 var b = [];
66 for (var i = 0; i < rellines.length; ++i) {
67 b[i] = rellines[i] + base;
68 }
69 is(linemap[funcname].toSource(), b.toSource(), funcname + " lines");
70 };
72 checklines('f1', linemap, [ 1 ]);
73 checklines('f2', linemap, [ 3 ]);
74 checklines('f3', linemap, [ 3, 5, 6 ]);
76 checklines('f1', firsts, [ 1 ]);
77 checklines('f1', rests, []);
78 checklines('f3', firsts, [ 3 ]);
79 checklines('f3', rests, [ 5, 6 ]);
81 jsd.functionHook = null;
83 if (!jsdOnAtStart) {
84 // turn JSD off if it wasn't on when this test started
85 jsd.off();
86 ok(!jsd.isOn, "JSD shouldn't be running at the end of this test.");
87 }
89 SimpleTest.finish();
90 }
92 testJSD(jsd);