js/src/jit-test/tests/debug/Script-sourceMapURL-deprecated.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Script.prototype.sourceMapURL can be a string or null.
     3 let g = newGlobal();
     4 let dbg = new Debugger;
     5 let gw = dbg.addDebuggee(g);
     7 function getSourceMapURL() {
     8     let fw = gw.makeDebuggeeValue(g.f);
     9     return fw.script.sourceMapURL;
    10 }
    12 // Without a source map
    13 g.evaluate("function f(x) { return 2*x; }");
    14 assertEq(getSourceMapURL(), null);
    16 // With a source map
    17 g.evaluate("function f(x) { return 2*x; }", {sourceMapURL: 'file:///var/foo.js.map'});
    18 assertEq(getSourceMapURL(), 'file:///var/foo.js.map');
    20 // Nested functions
    21 let fired = false;
    22 dbg.onDebuggerStatement = function (frame) {
    23     fired = true;
    24     assertEq(frame.script.sourceMapURL, 'file:///var/bar.js.map');
    25 };
    26 g.evaluate('(function () { (function () { debugger; })(); })();',
    27            {sourceMapURL: 'file:///var/bar.js.map'});
    28 assertEq(fired, true);
    30 // Comment pragmas
    31 g.evaluate('function f() {}\n' +
    32            '//@ sourceMappingURL=file:///var/quux.js.map');
    33 assertEq(getSourceMapURL(), 'file:///var/quux.js.map');
    35 g.evaluate('function f() {}\n' +
    36            '/*//@ sourceMappingURL=file:///var/quux.js.map*/');
    37 assertEq(getSourceMapURL(), 'file:///var/quux.js.map');
    39 g.evaluate('function f() {}\n' +
    40            '/*\n' +
    41            '//@ sourceMappingURL=file:///var/quux.js.map\n' +
    42            '*/');
    43 assertEq(getSourceMapURL(), 'file:///var/quux.js.map');
    45 // Spaces are disallowed by the URL spec (they should have been
    46 // percent-encoded).
    47 g.evaluate('function f() {}\n' +
    48            '//@ sourceMappingURL=http://example.com/has illegal spaces.map');
    49 assertEq(getSourceMapURL(), 'http://example.com/has');
    51 // When the URL is missing, we don't set the sourceMapURL and we don't skip the
    52 // next line of input.
    53 g.evaluate('function f() {}\n' +
    54            '//@ sourceMappingURL=\n' +
    55            'function z() {}');
    56 assertEq(getSourceMapURL(), null);
    57 assertEq('z' in g, true);
    59 // The last comment pragma we see should be the one which sets the source map's
    60 // URL.
    61 g.evaluate('function f() {}\n' +
    62            '//@ sourceMappingURL=http://example.com/foo.js.map\n' +
    63            '//@ sourceMappingURL=http://example.com/bar.js.map');
    64 assertEq(getSourceMapURL(), 'http://example.com/bar.js.map');
    66 // With both a comment and the evaluate option.
    67 g.evaluate('function f() {}\n' +
    68            '//@ sourceMappingURL=http://example.com/foo.js.map',
    69            {sourceMapURL: 'http://example.com/bar.js.map'});
    70 assertEq(getSourceMapURL(), 'http://example.com/foo.js.map');

mercurial