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.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * Tests that enteredFrame packets are sent on frame entry and |
michael@0 | 6 | * exitedFrame packets are sent on frame exit. Tests that the "name" |
michael@0 | 7 | * trace type works for function declarations. |
michael@0 | 8 | */ |
michael@0 | 9 | |
michael@0 | 10 | var gDebuggee; |
michael@0 | 11 | var gClient; |
michael@0 | 12 | var gTraceClient; |
michael@0 | 13 | |
michael@0 | 14 | function run_test() |
michael@0 | 15 | { |
michael@0 | 16 | initTestTracerServer(); |
michael@0 | 17 | gDebuggee = addTestGlobal("test-tracer-actor"); |
michael@0 | 18 | gClient = new DebuggerClient(DebuggerServer.connectPipe()); |
michael@0 | 19 | gClient.connect(function() { |
michael@0 | 20 | attachTestTab(gClient, "test-tracer-actor", function(aResponse, aTabClient) { |
michael@0 | 21 | gClient.attachTracer(aResponse.traceActor, function(aResponse, aTraceClient) { |
michael@0 | 22 | gTraceClient = aTraceClient; |
michael@0 | 23 | test_enter_exit_frame(); |
michael@0 | 24 | }); |
michael@0 | 25 | }); |
michael@0 | 26 | }); |
michael@0 | 27 | do_test_pending(); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | function test_enter_exit_frame() |
michael@0 | 31 | { |
michael@0 | 32 | let tracesSeen = 0; |
michael@0 | 33 | let traceNames = []; |
michael@0 | 34 | let traceStopped = promise.defer(); |
michael@0 | 35 | |
michael@0 | 36 | gClient.addListener("traces", function onTraces(aEvent, { traces }) { |
michael@0 | 37 | for (let t of traces) { |
michael@0 | 38 | tracesSeen++; |
michael@0 | 39 | |
michael@0 | 40 | if (t.type == "enteredFrame") { |
michael@0 | 41 | do_check_eq(t.type, "enteredFrame", |
michael@0 | 42 | 'enteredFrame response should have type "enteredFrame"'); |
michael@0 | 43 | do_check_eq(typeof t.sequence, "number", |
michael@0 | 44 | 'enteredFrame response should have sequence number'); |
michael@0 | 45 | do_check_true(!isNaN(t.sequence), |
michael@0 | 46 | 'enteredFrame sequence should be a number'); |
michael@0 | 47 | do_check_eq(typeof t.name, "string", |
michael@0 | 48 | 'enteredFrame response should have function name'); |
michael@0 | 49 | traceNames[t.sequence] = t.name; |
michael@0 | 50 | } else { |
michael@0 | 51 | do_check_eq(t.type, "exitedFrame", |
michael@0 | 52 | 'exitedFrame response should have type "exitedFrame"'); |
michael@0 | 53 | do_check_eq(typeof t.sequence, "number", |
michael@0 | 54 | 'exitedFrame response should have sequence number'); |
michael@0 | 55 | do_check_true(!isNaN(t.sequence), |
michael@0 | 56 | 'exitedFrame sequence should be a number'); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | if (tracesSeen == 10) { |
michael@0 | 60 | gClient.removeListener("traces", onTraces); |
michael@0 | 61 | traceStopped.resolve(); |
michael@0 | 62 | } |
michael@0 | 63 | } |
michael@0 | 64 | }); |
michael@0 | 65 | |
michael@0 | 66 | start_trace() |
michael@0 | 67 | .then(eval_code) |
michael@0 | 68 | .then(() => traceStopped.promise) |
michael@0 | 69 | .then(stop_trace) |
michael@0 | 70 | .then(function() { |
michael@0 | 71 | do_check_eq(traceNames[2], "baz", |
michael@0 | 72 | 'Should have entered "baz" frame in third packet'); |
michael@0 | 73 | do_check_eq(traceNames[3], "bar", |
michael@0 | 74 | 'Should have entered "bar" frame in fourth packet'); |
michael@0 | 75 | do_check_eq(traceNames[4], "foo", |
michael@0 | 76 | 'Should have entered "foo" frame in fifth packet'); |
michael@0 | 77 | finishClient(gClient); |
michael@0 | 78 | }); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | function start_trace() |
michael@0 | 82 | { |
michael@0 | 83 | let deferred = promise.defer(); |
michael@0 | 84 | gTraceClient.startTrace(["name"], null, function() { deferred.resolve(); }); |
michael@0 | 85 | return deferred.promise; |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | function eval_code() |
michael@0 | 89 | { |
michael@0 | 90 | gDebuggee.eval("(" + function() { |
michael@0 | 91 | function foo() { |
michael@0 | 92 | return; |
michael@0 | 93 | } |
michael@0 | 94 | function bar() { |
michael@0 | 95 | return foo(); |
michael@0 | 96 | } |
michael@0 | 97 | function baz() { |
michael@0 | 98 | return bar(); |
michael@0 | 99 | } |
michael@0 | 100 | baz(); |
michael@0 | 101 | } + ")()"); |
michael@0 | 102 | } |
michael@0 | 103 | |
michael@0 | 104 | function stop_trace() |
michael@0 | 105 | { |
michael@0 | 106 | let deferred = promise.defer(); |
michael@0 | 107 | gTraceClient.stopTrace(null, function() { deferred.resolve(); }); |
michael@0 | 108 | return deferred.promise; |
michael@0 | 109 | } |