Bug 1445718 - Use a dedicated devtools loader instance for DAMP tests
MozReview-Commit-ID: H29AsFRFnzq
--- a/testing/talos/talos/tests/devtools/addon/content/damp.js
+++ b/testing/talos/talos/tests/devtools/addon/content/damp.js
@@ -2,20 +2,30 @@ const { Services } = ChromeUtils.import(
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", {});
const env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
XPCOMUtils.defineLazyGetter(this, "require", function() {
let { require } =
ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
return require;
});
+
+XPCOMUtils.defineLazyGetter(this, "testRequire", function() {
+ let { DevToolsLoader } =
+ ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
+ let testLoader = new DevToolsLoader();
+ testLoader.invisibleToDebugger = true;
+ return testLoader.require;
+});
+
XPCOMUtils.defineLazyGetter(this, "gDevTools", function() {
let { gDevTools } = require("devtools/client/framework/devtools");
return gDevTools;
});
+
XPCOMUtils.defineLazyGetter(this, "TargetFactory", function() {
let { TargetFactory } = require("devtools/client/framework/target");
return TargetFactory;
});
// Record allocation count in new subtests if DEBUG_DEVTOOLS_ALLOCATIONS is set to
// "normal". Print allocation sites to stdout if DEBUG_DEVTOOLS_ALLOCATIONS is set to
// "verbose".
@@ -76,16 +86,19 @@ function awaitBrowserLoaded(browser, inc
/* globals res:true */
function Damp() {
Services.prefs.setBoolPref("devtools.webconsole.new-frontend-enabled", true);
}
Damp.prototype = {
+ getDefaultRequire() {
+ return require;
+ },
async garbageCollect() {
dump("Garbage collect\n");
// Minimize memory usage
// mimic miminizeMemoryUsage, by only flushing JS objects via GC.
// We don't want to flush all the cache like minimizeMemoryUsage,
// as it slow down next executions almost like a cold start.
@@ -206,17 +219,17 @@ Damp.prototype = {
if (this._nextTestIndex >= this._tests.length) {
this._onSequenceComplete();
return;
}
let test = this._tests[this._nextTestIndex++];
dump("Loading test : " + test + "\n");
- let testMethod = require("chrome://damp/content/tests/" + test);
+ let testMethod = testRequire("chrome://damp/content/tests/" + test);
dump("Executing test : " + test + "\n");
testMethod();
},
// Each command at the array a function which must call nextCommand once it's done
_doSequence(tests, onComplete) {
this._tests = tests;
this._onSequenceComplete = onComplete;
@@ -279,17 +292,17 @@ Damp.prototype = {
startAllocationTracker() {
const { allocationTracker } = require("devtools/shared/test-helpers/allocation-tracker");
return allocationTracker();
},
startTest(doneCallback, config) {
dump("Initialize the head file with a reference to this DAMP instance\n");
- let head = require("chrome://damp/content/tests/head.js");
+ let head = testRequire("chrome://damp/content/tests/head.js");
head.initialize(this);
this._onTestComplete = function(results) {
TalosParentProfiler.pause("DAMP - end");
doneCallback(results);
};
this._config = config;
--- a/testing/talos/talos/tests/devtools/addon/content/tests/head.js
+++ b/testing/talos/talos/tests/devtools/addon/content/tests/head.js
@@ -6,33 +6,34 @@
/**
* This helper contains the public API that can be used by DAMP tests.
*/
// eslint-disable-next-line mozilla/no-define-cc-etc
const { Ci } = require("chrome");
const Services = require("Services");
-const { gDevTools } = require("devtools/client/framework/devtools");
-const { TargetFactory } = require("devtools/client/framework/target");
+let gDevTools, TargetFactory;
const webserver = Services.prefs.getCharPref("addon.test.damp.webserver");
const PAGES_BASE_URL = webserver + "/tests/devtools/addon/content/pages/";
exports.PAGES_BASE_URL = PAGES_BASE_URL;
exports.SIMPLE_URL = PAGES_BASE_URL + "simple.html";
exports.COMPLICATED_URL = webserver + "/tests/tp5n/bild.de/www.bild.de/index.html";
let damp = null;
/*
* This method should be called by js before starting the tests.
*/
exports.initialize = function(_damp) {
damp = _damp;
+ ({ gDevTools } = damp.getDefaultRequire()("devtools/client/framework/devtools"));
+ ({ TargetFactory } = damp.getDefaultRequire()("devtools/client/framework/target"));
};
function garbageCollect() {
return damp.garbageCollect();
}
exports.garbageCollect = garbageCollect;
function runTest(label) {