test_get-executable-lines-source-map.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. /**
  5. * Test if getExecutableLines return correct information
  6. */
  7. var gDebuggee;
  8. var gClient;
  9. var gThreadClient;
  10. const SOURCE_MAPPED_FILE = getFileUrl("sourcemapped.js");
  11. function run_test() {
  12. initTestDebuggerServer();
  13. gDebuggee = addTestGlobal("test-get-executable-lines");
  14. gClient = new DebuggerClient(DebuggerServer.connectPipe());
  15. gClient.connect().then(function _onConnect() {
  16. attachTestTabAndResume(
  17. gClient,
  18. "test-get-executable-lines",
  19. function (aResponse, aTabClient, aThreadClient) {
  20. gThreadClient = aThreadClient;
  21. test_executable_lines();
  22. }
  23. );
  24. });
  25. do_test_pending();
  26. }
  27. function test_executable_lines() {
  28. gThreadClient.addOneTimeListener("newSource", function _onNewSource(evt, packet) {
  29. do_check_eq(evt, "newSource");
  30. gThreadClient.getSources(function ({error, sources}) {
  31. do_check_true(!error);
  32. let source = gThreadClient.source(sources[0]);
  33. source.getExecutableLines(function (lines) {
  34. do_check_true(arrays_equal([1, 2, 4, 6], lines));
  35. finishClient(gClient);
  36. });
  37. });
  38. });
  39. let code = readFile("sourcemapped.js") + "\n//# sourceMappingURL=" +
  40. getFileUrl("source-map-data/sourcemapped.map");
  41. Components.utils.evalInSandbox(code, gDebuggee, "1.8",
  42. SOURCE_MAPPED_FILE, 1);
  43. }
  44. function arrays_equal(a, b) {
  45. return !(a < b || b < a);
  46. }