mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-28 04:39:07 -10:00
***
Bug 1514594: Part 3a - Change ChromeUtils.import to return an exports object; not pollute global. r=mccr8
This changes the behavior of ChromeUtils.import() to return an exports object,
rather than a module global, in all cases except when `null` is passed as a
second argument, and changes the default behavior not to pollute the global
scope with the module's exports. Thus, the following code written for the old
model:
ChromeUtils.import("resource://gre/modules/Services.jsm");
is approximately the same as the following, in the new model:
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
Since the two behaviors are mutually incompatible, this patch will land with a
scripted rewrite to update all existing callers to use the new model rather
than the old.
***
Bug 1514594: Part 3b - Mass rewrite all JS code to use the new ChromeUtils.import API. rs=Gijs
This was done using the followng script:
https://bitbucket.org/kmaglione/m-c-rewrites/src/tip/processors/cu-import-exports.jsm
***
Bug 1514594: Part 3c - Update ESLint plugin for ChromeUtils.import API changes. r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D16747
***
Bug 1514594: Part 3d - Remove/fix hundreds of duplicate imports from sync tests. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D16748
***
Bug 1514594: Part 3e - Remove no-op ChromeUtils.import() calls. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D16749
***
Bug 1514594: Part 3f.1 - Cleanup various test corner cases after mass rewrite. r=Gijs
***
Bug 1514594: Part 3f.2 - Cleanup various non-test corner cases after mass rewrite. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D16750
59 lines
1.8 KiB
JavaScript
59 lines
1.8 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.jsm");
|
|
const Services = require("Services");
|
|
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: function(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 (DebuggerServer.xpcInspector.eventLoopNestLevel > 0) {
|
|
DebuggerServer.xpcInspector.exitNestedEventLoop();
|
|
}
|
|
|
|
if (!ALLOW_CONSOLE_ERRORS) {
|
|
do_throw("head_devtools.js got console message: " + string + "\n");
|
|
}
|
|
},
|
|
};
|
|
/* eslint-enable no-undef */
|
|
|
|
Services.console.registerListener(listener);
|