toolkit/devtools/server/tests/unit/test_blackboxing-06.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 we can black box source mapped sources.
michael@0 6 */
michael@0 7
michael@0 8 var gDebuggee;
michael@0 9 var gClient;
michael@0 10 var gThreadClient;
michael@0 11
michael@0 12 Components.utils.import('resource:///modules/devtools/SourceMap.jsm');
michael@0 13
michael@0 14 function run_test()
michael@0 15 {
michael@0 16 initTestDebuggerServer();
michael@0 17 gDebuggee = addTestGlobal("test-black-box");
michael@0 18 gClient = new DebuggerClient(DebuggerServer.connectPipe());
michael@0 19 gClient.connect(function() {
michael@0 20 attachTestTabAndResume(gClient, "test-black-box", function(aResponse, aTabClient, aThreadClient) {
michael@0 21 gThreadClient = aThreadClient;
michael@0 22
michael@0 23 promise.resolve(setup_code())
michael@0 24 .then(black_box_code)
michael@0 25 .then(run_code)
michael@0 26 .then(test_correct_location)
michael@0 27 .then(null, function (error) {
michael@0 28 do_check_true(false, "Should not get an error, got " + error);
michael@0 29 })
michael@0 30 .then(function () {
michael@0 31 finishClient(gClient);
michael@0 32 });
michael@0 33 });
michael@0 34 });
michael@0 35 do_test_pending();
michael@0 36 }
michael@0 37
michael@0 38 function setup_code() {
michael@0 39 let { code, map } = (new SourceNode(null, null, null, [
michael@0 40 new SourceNode(1, 0, "a.js", "" + function a() {
michael@0 41 return b();
michael@0 42 }),
michael@0 43 "\n",
michael@0 44 new SourceNode(1, 0, "b.js", "" + function b() {
michael@0 45 debugger; // Don't want to stop here.
michael@0 46 return c();
michael@0 47 }),
michael@0 48 "\n",
michael@0 49 new SourceNode(1, 0, "c.js", "" + function c() {
michael@0 50 debugger; // Want to stop here.
michael@0 51 }),
michael@0 52 "\n"
michael@0 53 ])).toStringWithSourceMap({
michael@0 54 file: "abc.js",
michael@0 55 sourceRoot: "http://example.com/"
michael@0 56 });
michael@0 57
michael@0 58 code += "//# sourceMappingURL=data:text/json," + map.toString();
michael@0 59
michael@0 60 Components.utils.evalInSandbox(code,
michael@0 61 gDebuggee,
michael@0 62 "1.8",
michael@0 63 "http://example.com/abc.js");
michael@0 64 }
michael@0 65
michael@0 66 function black_box_code() {
michael@0 67 const d = promise.defer();
michael@0 68
michael@0 69 gThreadClient.getSources(function ({ sources, error }) {
michael@0 70 do_check_true(!error, "Shouldn't get an error getting sources");
michael@0 71 const source = sources.filter((s) => {
michael@0 72 return s.url.indexOf("b.js") !== -1;
michael@0 73 })[0];
michael@0 74 do_check_true(!!source, "We should have our source in the sources list");
michael@0 75
michael@0 76 gThreadClient.source(source).blackBox(function ({ error }) {
michael@0 77 do_check_true(!error, "Should not get an error black boxing");
michael@0 78 d.resolve(true);
michael@0 79 });
michael@0 80 });
michael@0 81
michael@0 82 return d.promise;
michael@0 83 }
michael@0 84
michael@0 85 function run_code() {
michael@0 86 const d = promise.defer();
michael@0 87
michael@0 88 gClient.addOneTimeListener("paused", function (aEvent, aPacket) {
michael@0 89 d.resolve(aPacket);
michael@0 90 gThreadClient.resume();
michael@0 91 });
michael@0 92 gDebuggee.a();
michael@0 93
michael@0 94 return d.promise;
michael@0 95 }
michael@0 96
michael@0 97 function test_correct_location(aPacket) {
michael@0 98 do_check_eq(aPacket.why.type, "debuggerStatement",
michael@0 99 "Should hit a debugger statement.");
michael@0 100 do_check_eq(aPacket.frame.where.url, "http://example.com/c.js",
michael@0 101 "Should have skipped over the debugger statement in the black boxed source");
michael@0 102 }

mercurial