toolkit/devtools/server/tests/unit/test_sourcemaps-08.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/devtools/server/tests/unit/test_sourcemaps-08.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,52 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * Regression test for bug 882986 regarding sourcesContent and absolute source
     1.9 + * URLs.
    1.10 + */
    1.11 +
    1.12 +var gDebuggee;
    1.13 +var gClient;
    1.14 +var gThreadClient;
    1.15 +
    1.16 +Components.utils.import("resource:///modules/devtools/SourceMap.jsm");
    1.17 +
    1.18 +function run_test()
    1.19 +{
    1.20 +  initTestDebuggerServer();
    1.21 +  gDebuggee = addTestGlobal("test-source-map");
    1.22 +  gClient = new DebuggerClient(DebuggerServer.connectPipe());
    1.23 +  gClient.connect(function() {
    1.24 +    attachTestTabAndResume(gClient, "test-source-map", function(aResponse, aTabClient, aThreadClient) {
    1.25 +      gThreadClient = aThreadClient;
    1.26 +      test_source_maps();
    1.27 +    });
    1.28 +  });
    1.29 +  do_test_pending();
    1.30 +}
    1.31 +
    1.32 +function test_source_maps()
    1.33 +{
    1.34 +  gClient.addOneTimeListener("newSource", function (aEvent, aPacket) {
    1.35 +    let sourceClient = gThreadClient.source(aPacket.source);
    1.36 +    sourceClient.source(function ({error, source}) {
    1.37 +      do_check_true(!error, "should be able to grab the source");
    1.38 +      do_check_eq(source, "foo",
    1.39 +                  "Should load the source from the sourcesContent field");
    1.40 +      finishClient(gClient);
    1.41 +    });
    1.42 +  });
    1.43 +
    1.44 +  let code = "'nothing here';\n";
    1.45 +  code += "//# sourceMappingURL=data:text/json," + JSON.stringify({
    1.46 +    version: 3,
    1.47 +    file: "foo.js",
    1.48 +    sources: ["/a"],
    1.49 +    names: [],
    1.50 +    mappings: "AACA",
    1.51 +    sourcesContent: ["foo"]
    1.52 +  });
    1.53 +  Components.utils.evalInSandbox(code, gDebuggee, "1.8",
    1.54 +                                 "http://example.com/foo.js", 1);
    1.55 +}

mercurial