js/src/jit-test/tests/debug/Script-getBreakpoints-01.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 // Basic Script.prototype.getBreakpoints tests.
michael@0 2
michael@0 3 var g = newGlobal();
michael@0 4 g.eval("var line0 = Error().lineNumber;\n" +
michael@0 5 "function f(x) {\n" + // line0 + 1
michael@0 6 " if (x < 0)\n" + // line0 + 2
michael@0 7 " return -x;\n" + // line0 + 3
michael@0 8 " return x;\n" +
michael@0 9 "}");
michael@0 10
michael@0 11 var s;
michael@0 12 var offsets = [];
michael@0 13 var handlers = [];
michael@0 14 var dbg = Debugger(g);
michael@0 15 dbg.onDebuggerStatement = function (frame) {
michael@0 16 s = frame.eval("f").return.script;
michael@0 17 var off;
michael@0 18
michael@0 19 for (var i = 0; i < 3; i++) {
michael@0 20 var off = s.getLineOffsets(g.line0 + 2 + i)[0];
michael@0 21 assertEq(typeof off, 'number');
michael@0 22 handlers[i] = {};
michael@0 23 s.setBreakpoint(off, handlers[i]);
michael@0 24 offsets[i] = off;
michael@0 25 }
michael@0 26 };
michael@0 27 g.eval("debugger;");
michael@0 28
michael@0 29 // getBreakpoints without an offset gets all breakpoints in the script.
michael@0 30 var bps = s.getBreakpoints();
michael@0 31 assertEq(bps.length, handlers.length);
michael@0 32 for (var i = 0; i < bps.length; i++)
michael@0 33 assertEq(bps.indexOf(handlers[i]) !== -1, true);
michael@0 34
michael@0 35 // getBreakpoints with an offset finds only breakpoints at that offset.
michael@0 36 for (var i = 0; i < offsets.length; i++) {
michael@0 37 var bps = s.getBreakpoints(offsets[i]);
michael@0 38 assertEq(bps.length, 1);
michael@0 39 assertEq(bps[0], handlers[i]);
michael@0 40 }

mercurial