js/src/jit-test/tests/debug/Debugger-findScripts-14.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/debug/Debugger-findScripts-14.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,30 @@
     1.4 +// Debugger.prototype.findScripts can find the innermost script at a given
     1.5 +// source location.
     1.6 +var g = newGlobal();
     1.7 +var dbg = new Debugger();
     1.8 +var gw = dbg.addDebuggee(g);
     1.9 +
    1.10 +function script(f) {
    1.11 +    return gw.makeDebuggeeValue(f).script;
    1.12 +}
    1.13 +
    1.14 +function arrayIsOnly(array, element) {
    1.15 +    return array.length == 1 && array[0] === element;
    1.16 +}
    1.17 +
    1.18 +url = scriptdir + 'Debugger-findScripts-14.script1';
    1.19 +g.load(url);
    1.20 +
    1.21 +var scripts;
    1.22 +
    1.23 +// When we're doing 'innermost' queries, we don't have to worry about finding
    1.24 +// random eval scripts: we should get exactly one script, for the function
    1.25 +// covering that line.
    1.26 +scripts = dbg.findScripts({url:url, line:4, innermost:true});
    1.27 +assertEq(arrayIsOnly(scripts, script(g.f)), true);
    1.28 +
    1.29 +scripts = dbg.findScripts({url:url, line:6, innermost:true});
    1.30 +assertEq(arrayIsOnly(scripts, script(g.f())), true);
    1.31 +
    1.32 +scripts = dbg.findScripts({url:url, line:8, innermost:true});
    1.33 +assertEq(arrayIsOnly(scripts, script(g.f()())), true);

mercurial