summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/unit/test_sourcemaps-08.js
blob: b23665e4397983c9ffddc5cdf281523e030f7f9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

/**
 * Regression test for bug 882986 regarding sourcesContent and absolute source
 * URLs.
 */

var gDebuggee;
var gClient;
var gThreadClient;

function run_test()
{
  initTestDebuggerServer();
  gDebuggee = addTestGlobal("test-source-map");
  gClient = new DebuggerClient(DebuggerServer.connectPipe());
  gClient.connect().then(function () {
    attachTestTabAndResume(gClient, "test-source-map", function (aResponse, aTabClient, aThreadClient) {
      gThreadClient = aThreadClient;
      test_source_maps();
    });
  });
  do_test_pending();
}

function test_source_maps()
{
  gThreadClient.addOneTimeListener("newSource", function (aEvent, aPacket) {
    let sourceClient = gThreadClient.source(aPacket.source);
    sourceClient.source(function ({error, source}) {
      do_check_true(!error, "should be able to grab the source");
      do_check_eq(source, "foo",
                  "Should load the source from the sourcesContent field");
      finishClient(gClient);
    });
  });

  let code = "'nothing here';\n";
  code += "//# sourceMappingURL=data:text/json," + JSON.stringify({
    version: 3,
    file: "foo.js",
    sources: ["/a"],
    names: [],
    mappings: "AACA",
    sourcesContent: ["foo"]
  });
  Components.utils.evalInSandbox(code, gDebuggee, "1.8",
                                 "http://example.com/foo.js", 1);
}