head.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. const TEST_BASE_HTTP = "http://example.com/browser/devtools/client/commandline/test/";
  5. const TEST_BASE_HTTPS = "https://example.com/browser/devtools/client/commandline/test/";
  6. var { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
  7. var { console } = require("resource://gre/modules/Console.jsm");
  8. var flags = require("devtools/shared/flags");
  9. // Import the GCLI test helper
  10. var testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
  11. Services.scriptloader.loadSubScript(testDir + "/helpers.js", this);
  12. Services.scriptloader.loadSubScript(testDir + "/mockCommands.js", this);
  13. flags.testing = true;
  14. SimpleTest.registerCleanupFunction(() => {
  15. flags.testing = false;
  16. });
  17. function whenDelayedStartupFinished(aWindow, aCallback) {
  18. Services.obs.addObserver(function observer(aSubject, aTopic) {
  19. if (aWindow == aSubject) {
  20. Services.obs.removeObserver(observer, aTopic);
  21. executeSoon(aCallback);
  22. }
  23. }, "browser-delayed-startup-finished", false);
  24. }
  25. /**
  26. * Force GC on shutdown, because it seems that GCLI can outrun the garbage
  27. * collector in some situations, which causes test failures in later tests
  28. * Bug 774619 is an example.
  29. */
  30. registerCleanupFunction(function tearDown() {
  31. window.QueryInterface(Ci.nsIInterfaceRequestor)
  32. .getInterface(Ci.nsIDOMWindowUtils)
  33. .garbageCollect();
  34. });