test_sourcemaps-08.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Regression test for bug 882986 regarding sourcesContent and absolute source
  5. * URLs.
  6. */
  7. var gDebuggee;
  8. var gClient;
  9. var gThreadClient;
  10. function run_test()
  11. {
  12. initTestDebuggerServer();
  13. gDebuggee = addTestGlobal("test-source-map");
  14. gClient = new DebuggerClient(DebuggerServer.connectPipe());
  15. gClient.connect().then(function () {
  16. attachTestTabAndResume(gClient, "test-source-map", function (aResponse, aTabClient, aThreadClient) {
  17. gThreadClient = aThreadClient;
  18. test_source_maps();
  19. });
  20. });
  21. do_test_pending();
  22. }
  23. function test_source_maps()
  24. {
  25. gThreadClient.addOneTimeListener("newSource", function (aEvent, aPacket) {
  26. let sourceClient = gThreadClient.source(aPacket.source);
  27. sourceClient.source(function ({error, source}) {
  28. do_check_true(!error, "should be able to grab the source");
  29. do_check_eq(source, "foo",
  30. "Should load the source from the sourcesContent field");
  31. finishClient(gClient);
  32. });
  33. });
  34. let code = "'nothing here';\n";
  35. code += "//# sourceMappingURL=data:text/json," + JSON.stringify({
  36. version: 3,
  37. file: "foo.js",
  38. sources: ["/a"],
  39. names: [],
  40. mappings: "AACA",
  41. sourcesContent: ["foo"]
  42. });
  43. Components.utils.evalInSandbox(code, gDebuggee, "1.8",
  44. "http://example.com/foo.js", 1);
  45. }