Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/js/src/jit-test/tests/debug/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  Source-sourceMapURL.js

  Sprache: JAVA
 

// Source.prototype.sourceMapURL can be a string or null.

let g = newGlobal({newCompartment: true});
let dbg = new Debugger;
let gw = dbg.addDebuggee(g);

function getSourceMapURL() {
    let fw = gw.makeDebuggeeValue(g.f);
    return fw.script.source.sourceMapURL;
}

function setSourceMapURL(url) {
    let fw = gw.makeDebuggeeValue(g.f);
    fw.script.source.sourceMapURL = url;
}

// Without a source map
g.evaluate("function f(x) { return 2*x; }");
assertEq(getSourceMapURL(), null);

// With a source map
g.evaluate("function f(x) { return 2*x; }", {sourceMapURL: 'file:///var/foo.js.map'});
assertEq(getSourceMapURL(), 'file:///var/foo.js.map');

// Nested functions
let fired = false;
dbg.onDebuggerStatement = function (frame) {
    fired = true;
    assertEq(frame.script.source.sourceMapURL, 'file:///var/bar.js.map');
};
g.evaluate('(function () { (function () { debugger; })(); })();',
           {sourceMapURL: 'file:///var/bar.js.map'});
assertEq(fired, true);

// Comment pragmas
g.evaluate('function f() {}\n' +
           '//# sourceMappingURL=file:///var/quux.js.map');
assertEq(getSourceMapURL(), 'file:///var/quux.js.map');

g.evaluate('function f() {}\n' +
           '/*//# sourceMappingURL=file:///var/quux.js.map*/');
assertEq(getSourceMapURL(), 'file:///var/quux.js.map');

g.evaluate('function f() {}\n' +
           '/*\n' +
           '//# sourceMappingURL=file:///var/quux.js.map\n' +
           '*/');
assertEq(getSourceMapURL(), 'file:///var/quux.js.map');

// Spaces are disallowed by the URL spec (they should have been
// percent-encoded).
g.evaluate('function f() {}\n' +
           '//# sourceMappingURL=http://example.com/has illegal spaces.map');
assertEq(getSourceMapURL(), 'http://example.com/has');

// When the URL is missing, we don't set the sourceMapURL and we don't skip the
// next line of input.
g.evaluate('function f() {}\n' +
           '//# sourceMappingURL=\n' +
           'function z() {}');
assertEq(getSourceMapURL(), null);
assertEq('z' in g, true);

// The last comment pragma we see should be the one which sets the source map's
// URL.
g.evaluate('function f() {}\n' +
           '//# sourceMappingURL=http://example.com/foo.js.map\n' +
           '//# sourceMappingURL=http://example.com/bar.js.map');
assertEq(getSourceMapURL(), 'http://example.com/bar.js.map');

// With both a comment and the evaluate option.
g.evaluate('function f() {}\n' +
           '//# sourceMappingURL=http://example.com/foo.js.map',
           {sourceMapURL: 'http://example.com/bar.js.map'});
assertEq(getSourceMapURL(), 'http://example.com/foo.js.map');

// Make sure setting the sourceMapURL manually works
setSourceMapURL('baz.js.map');
assertEq(getSourceMapURL(), 'baz.js.map');

setSourceMapURL('');
assertEq(getSourceMapURL(), 'baz.js.map');

Messung V0.5 in Prozent
C=95 H=91 G=92

¤ Dauer der Verarbeitung: 0.25 Sekunden  (vorverarbeitet am  2026-06-06) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.