test_sourcemaps-17.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Check that we properly handle frames that cannot be sourcemapped
  5. * when using sourcemaps.
  6. */
  7. var gDebuggee;
  8. var gClient;
  9. var gThreadClient;
  10. const {SourceNode} = require("source-map");
  11. function run_test() {
  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_map();
  19. });
  20. });
  21. do_test_pending();
  22. }
  23. function test_source_map() {
  24. // Set up debuggee code.
  25. const a = new SourceNode(1, 1, "a.js", "function a() { b(); }");
  26. const b = new SourceNode(null, null, null, "function b() { c(); }");
  27. const c = new SourceNode(1, 1, "c.js", "function c() { d(); }");
  28. const d = new SourceNode(null, null, null, "function d() { e(); }");
  29. const e = new SourceNode(1, 1, "e.js", "function e() { debugger; }");
  30. const { map, code } = (new SourceNode(null, null, null, [a, b, c, d, e])).toStringWithSourceMap({
  31. file: "root.js",
  32. sourceRoot: "root",
  33. });
  34. Components.utils.evalInSandbox(
  35. code + "//# sourceMappingURL=data:text/json;base64," + btoa(map.toString()),
  36. gDebuggee,
  37. "1.8",
  38. "http://example.com/www/js/abc.js",
  39. 1
  40. );
  41. gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
  42. gThreadClient.getFrames(0, 50, function ({ error, frames }) {
  43. do_check_true(!error);
  44. do_check_eq(frames.length, 4);
  45. // b.js should be skipped
  46. do_check_eq(frames[0].where.source.url, "http://example.com/www/root/e.js");
  47. do_check_eq(frames[1].where.source.url, "http://example.com/www/root/c.js");
  48. do_check_eq(frames[2].where.source.url, "http://example.com/www/root/a.js");
  49. do_check_eq(frames[3].where.source.url, null);
  50. finishClient(gClient);
  51. });
  52. });
  53. // Trigger it.
  54. gDebuggee.eval("a()");
  55. }