test_nesting-03.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* -*- js-indent-level: 2; indent-tabs-mode: nil -*- */
  2. /* Any copyright is dedicated to the Public Domain.
  3. http://creativecommons.org/publicdomain/zero/1.0/ */
  4. // Test that we can detect nested event loops in tabs with the same URL.
  5. var gClient1, gClient2, gThreadClient1, gThreadClient2;
  6. function run_test() {
  7. initTestDebuggerServer();
  8. addTestGlobal("test-nesting1");
  9. addTestGlobal("test-nesting1");
  10. // Conect the first client to the first debuggee.
  11. gClient1 = new DebuggerClient(DebuggerServer.connectPipe());
  12. gClient1.connect(function () {
  13. attachTestThread(gClient1, "test-nesting1", function (aResponse, aTabClient, aThreadClient) {
  14. gThreadClient1 = aThreadClient;
  15. start_second_connection();
  16. });
  17. });
  18. do_test_pending();
  19. }
  20. function start_second_connection() {
  21. gClient2 = new DebuggerClient(DebuggerServer.connectPipe());
  22. gClient2.connect(function () {
  23. attachTestThread(gClient2, "test-nesting1", function (aResponse, aTabClient, aThreadClient) {
  24. gThreadClient2 = aThreadClient;
  25. test_nesting();
  26. });
  27. });
  28. }
  29. function test_nesting() {
  30. const { resolve, reject, promise: p } = promise.defer();
  31. gThreadClient1.resume(aResponse => {
  32. do_check_eq(aResponse.error, "wrongOrder");
  33. gThreadClient2.resume(aResponse => {
  34. do_check_true(!aResponse.error);
  35. do_check_eq(aResponse.from, gThreadClient2.actor);
  36. gThreadClient1.resume(aResponse => {
  37. do_check_true(!aResponse.error);
  38. do_check_eq(aResponse.from, gThreadClient1.actor);
  39. gClient1.close(() => finishClient(gClient2));
  40. });
  41. });
  42. });
  43. }