toolkit/devtools/server/tests/unit/test_trace_actor-09.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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 * Test that self-hosted functions aren't traced and don't add depth.
michael@0 6 */
michael@0 7
michael@0 8 var gDebuggee;
michael@0 9 var gClient;
michael@0 10 var gTraceClient;
michael@0 11
michael@0 12 function run_test()
michael@0 13 {
michael@0 14 initTestTracerServer();
michael@0 15 gDebuggee = addTestGlobal("test-tracer-actor");
michael@0 16 gClient = new DebuggerClient(DebuggerServer.connectPipe());
michael@0 17 gClient.connect(function() {
michael@0 18 attachTestTab(gClient, "test-tracer-actor", function(aResponse, aTabClient) {
michael@0 19 gClient.attachTracer(aResponse.traceActor, function(aResponse, aTraceClient) {
michael@0 20 gTraceClient = aTraceClient;
michael@0 21 test_frame_depths();
michael@0 22 });
michael@0 23 });
michael@0 24 });
michael@0 25 do_test_pending();
michael@0 26 }
michael@0 27
michael@0 28 function test_frame_depths()
michael@0 29 {
michael@0 30 const tracesStopped = promise.defer();
michael@0 31 gClient.addListener("traces", (aEvent, { traces }) => {
michael@0 32 for (let t of traces) {
michael@0 33 check_trace(t);
michael@0 34 }
michael@0 35 tracesStopped.resolve();
michael@0 36 });
michael@0 37
michael@0 38 start_trace()
michael@0 39 .then(eval_code)
michael@0 40 .then(() => tracesStopped.promise)
michael@0 41 .then(stop_trace)
michael@0 42 .then(function() {
michael@0 43 finishClient(gClient);
michael@0 44 }).then(null, error => {
michael@0 45 do_check_true(false, "Should not get an error, got: " + DevToolsUtils.safeErrorString(error));
michael@0 46 });
michael@0 47 }
michael@0 48
michael@0 49 function start_trace()
michael@0 50 {
michael@0 51 let deferred = promise.defer();
michael@0 52 gTraceClient.startTrace(["depth", "name", "location"], null, function() { deferred.resolve(); });
michael@0 53 return deferred.promise;
michael@0 54 }
michael@0 55
michael@0 56 function eval_code()
michael@0 57 {
michael@0 58 gDebuggee.eval("(" + function iife() {
michael@0 59 [1].forEach(function noop() {});
michael@0 60 for (let x of [1]) {}
michael@0 61 } + ")()");
michael@0 62 }
michael@0 63
michael@0 64 function stop_trace()
michael@0 65 {
michael@0 66 let deferred = promise.defer();
michael@0 67 gTraceClient.stopTrace(null, function() { deferred.resolve(); });
michael@0 68 return deferred.promise;
michael@0 69 }
michael@0 70
michael@0 71 function check_trace({ sequence, depth, name, location })
michael@0 72 {
michael@0 73 if (location) {
michael@0 74 do_check_true(location.url !== "self-hosted");
michael@0 75 }
michael@0 76
michael@0 77 switch(sequence) {
michael@0 78 case 0:
michael@0 79 do_check_eq(name, "(eval)");
michael@0 80 case 5:
michael@0 81 do_check_eq(depth, 0);
michael@0 82 break;
michael@0 83
michael@0 84 case 1:
michael@0 85 do_check_eq(name, "iife");
michael@0 86 case 4:
michael@0 87 do_check_eq(depth, 1);
michael@0 88 break;
michael@0 89
michael@0 90 case 2:
michael@0 91 do_check_eq(name, "noop");
michael@0 92 case 3:
michael@0 93 do_check_eq(depth, 2);
michael@0 94 break;
michael@0 95
michael@0 96 default:
michael@0 97 // Should have covered all sequences.
michael@0 98 do_check_true(false);
michael@0 99 }
michael@0 100 }

mercurial