test_listsources-02.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Check getting sources before there are any.
  5. */
  6. var gDebuggee;
  7. var gClient;
  8. var gThreadClient;
  9. var gNumTimesSourcesSent = 0;
  10. function run_test()
  11. {
  12. initTestDebuggerServer();
  13. gDebuggee = addTestGlobal("test-stack");
  14. gClient = new DebuggerClient(DebuggerServer.connectPipe());
  15. gClient.request = (function (request) {
  16. return function (aRequest, aOnResponse) {
  17. if (aRequest.type === "sources") {
  18. ++gNumTimesSourcesSent;
  19. }
  20. return request.call(this, aRequest, aOnResponse);
  21. };
  22. }(gClient.request));
  23. gClient.connect().then(function () {
  24. attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
  25. gThreadClient = aThreadClient;
  26. test_listing_zero_sources();
  27. });
  28. });
  29. do_test_pending();
  30. }
  31. function test_listing_zero_sources()
  32. {
  33. gThreadClient.getSources(function (aPacket) {
  34. do_check_true(!aPacket.error);
  35. do_check_true(!!aPacket.sources);
  36. do_check_eq(aPacket.sources.length, 0);
  37. do_check_true(gNumTimesSourcesSent <= 1,
  38. "Should only send one sources request at most, even though we"
  39. + " might have had to send one to determine feature support.");
  40. finishClient(gClient);
  41. });
  42. }