toolkit/devtools/server/tests/unit/test_objectgrips-13.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 // Test that ObjectClient.prototype.getDefinitionSite and the "definitionSite"
michael@0 5 // request work properly.
michael@0 6
michael@0 7 var gDebuggee;
michael@0 8 var gClient;
michael@0 9 var gThreadClient;
michael@0 10
michael@0 11 function run_test()
michael@0 12 {
michael@0 13 initTestDebuggerServer();
michael@0 14 gDebuggee = addTestGlobal("test-grips");
michael@0 15 gDebuggee.eval(function stopMe() {
michael@0 16 debugger;
michael@0 17 }.toString());
michael@0 18
michael@0 19 gClient = new DebuggerClient(DebuggerServer.connectPipe());
michael@0 20 gClient.connect(function() {
michael@0 21 attachTestTabAndResume(gClient, "test-grips", function(aResponse, aTabClient, aThreadClient) {
michael@0 22 gThreadClient = aThreadClient;
michael@0 23 add_pause_listener();
michael@0 24 });
michael@0 25 });
michael@0 26 do_test_pending();
michael@0 27 }
michael@0 28
michael@0 29 function add_pause_listener()
michael@0 30 {
michael@0 31 gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
michael@0 32 const [funcGrip, objGrip] = aPacket.frame.arguments;
michael@0 33 const func = gThreadClient.pauseGrip(funcGrip);
michael@0 34 const obj = gThreadClient.pauseGrip(objGrip);
michael@0 35 test_definition_site(func, obj);
michael@0 36 });
michael@0 37
michael@0 38 eval_code();
michael@0 39 }
michael@0 40
michael@0 41 function eval_code() {
michael@0 42 gDebuggee.eval([
michael@0 43 "this.line0 = Error().lineNumber;",
michael@0 44 "function f() {}",
michael@0 45 "stopMe(f, {});"
michael@0 46 ].join("\n"));
michael@0 47 }
michael@0 48
michael@0 49 function test_definition_site(func, obj) {
michael@0 50 func.getDefinitionSite(({ error, url, line, column }) => {
michael@0 51 do_check_true(!error);
michael@0 52 do_check_eq(url, getFilePath("test_objectgrips-13.js"));
michael@0 53 do_check_eq(line, gDebuggee.line0 + 1);
michael@0 54 do_check_eq(column, 0);
michael@0 55
michael@0 56 test_bad_definition_site(obj);
michael@0 57 });
michael@0 58 }
michael@0 59
michael@0 60 function test_bad_definition_site(obj) {
michael@0 61 try {
michael@0 62 obj._client.request("definitionSite", () => do_check_true(false));
michael@0 63 } catch (e) {
michael@0 64 gThreadClient.resume(() => finishClient(gClient));
michael@0 65 }
michael@0 66 }

mercurial