Files
firefox/devtools/shared/tests/xpcshell/head_devtools.js
T
Alexandre Poirot 0f32f335e3 Bug 1789201 - [devtools] Expose Services as a global to all DevTools modules. r=perftest-reviewers,nchevobbe,julienw,AlexandruIonescu
This will help transition to ES Modules as this symbol is exposed to them.

$ sed -ie "/require(.Services.)/d" $(git grep -l 'require("Services")' devtools/)
$ sed -ie "/loader.lazyRequireGetter(this, .Services./d" $(git grep -l 'loader.lazyRequireGetter(this, "Services"' devtools/)
+ the edition of builtin-modules.js + eslintrc.js
+ manual eslint fixes
+ removal of devtools-services in the debugger, except for jest tests

Differential Revision: https://phabricator.services.mozilla.com/D156401
2022-09-09 07:22:51 +00:00

67 lines
1.9 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* exported DevToolsUtils, DevToolsLoader */
"use strict";
const { require, DevToolsLoader } = ChromeUtils.import(
"resource://devtools/shared/loader/Loader.jsm"
);
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
Services.prefs.setBoolPref("devtools.testing", true);
registerCleanupFunction(() => {
Services.prefs.clearUserPref("devtools.testing");
});
// Register a console listener, so console messages don't just disappear
// into the ether.
// If for whatever reason the test needs to post console errors that aren't
// failures, set this to true.
var ALLOW_CONSOLE_ERRORS = false;
// XXX This listener is broken, see bug 1456634, for now turn off no-undef here,
// this needs turning back on!
/* eslint-disable no-undef */
var listener = {
observe(message) {
let string;
try {
message.QueryInterface(Ci.nsIScriptError);
dump(
message.sourceName +
":" +
message.lineNumber +
": " +
scriptErrorFlagsToKind(message.flags) +
": " +
message.errorMessage +
"\n"
);
string = message.errorMessage;
} catch (ex) {
// Be a little paranoid with message, as the whole goal here is to lose
// no information.
try {
string = "" + message.message;
} catch (e) {
string = "<error converting error message to string>";
}
}
// Make sure we exit all nested event loops so that the test can finish.
while (DevToolsServer.xpcInspector.eventLoopNestLevel > 0) {
DevToolsServer.xpcInspector.exitNestedEventLoop();
}
if (!ALLOW_CONSOLE_ERRORS) {
do_throw("head_devtools.js got console message: " + string + "\n");
}
},
};
/* eslint-enable no-undef */
Services.console.registerListener(listener);