js/src/jit-test/tests/debug/Source-text-01.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/Source-text-01.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,26 @@
     1.4 +/*
     1.5 + * Debugger.Source.prototype.text should return a string. Moreover, it
     1.6 + * should be the same string for each child script sharing that
     1.7 + * Debugger.Source.
     1.8 + */
     1.9 +let g = newGlobal();
    1.10 +let dbg = new Debugger(g);
    1.11 +
    1.12 +var count = 0;
    1.13 +dbg.onNewScript = function (script) {
    1.14 +    var text = script.source.text;
    1.15 +    assertEq(typeof text, "string");
    1.16 +    function traverse(script) {
    1.17 +        ++count;
    1.18 +        script.getChildScripts().forEach(function (script) {
    1.19 +            assertEq(script.source.text, text);
    1.20 +            traverse(script);
    1.21 +        });
    1.22 +    };
    1.23 +    traverse(script);
    1.24 +}
    1.25 +
    1.26 +g.eval("2 * 3");
    1.27 +g.eval("function f() {}");
    1.28 +g.eval("function f() { function g() {} }");
    1.29 +assertEq(count, 6);

mercurial