зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1453869 part 9. Stop creating DOMParser by contract in devtools. r=tromey
There are some extra hoops here because devtools has a lint to prevent Cu.importGlobalProperties, which is the normal way one would import a WebIDL constructor. MozReview-Commit-ID: 2mdNI6N1z5B
This commit is contained in:
Родитель
2d76710322
Коммит
17995a441f
|
@ -31,6 +31,7 @@ var { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {}
|
|||
|
||||
var { gDevTools } = require("devtools/client/framework/devtools");
|
||||
var Services = require("Services");
|
||||
var { globals } = require("devtools/shared/builtin-modules");
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["AppCacheUtils"];
|
||||
|
||||
|
@ -617,5 +618,5 @@ XPCOMUtils.defineLazyGetter(this, "appcacheservice", function() {
|
|||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "_DOMParser", function() {
|
||||
return Cc["@mozilla.org/xmlextras/domparser;1"].createInstance(Ci.nsIDOMParser);
|
||||
return globals.DOMParser();
|
||||
});
|
||||
|
|
|
@ -7,11 +7,13 @@
|
|||
|
||||
// Test that VariablesView._doSearch() works even without an attached
|
||||
// VariablesViewController (bug 1196341).
|
||||
|
||||
const DOMParser = Cc["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Ci.nsIDOMParser);
|
||||
const { VariablesView } =
|
||||
ChromeUtils.import("resource://devtools/client/shared/widgets/VariablesView.jsm", {});
|
||||
const { require } =
|
||||
ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
|
||||
const { globals } = require("devtools/shared/builtin-modules");
|
||||
|
||||
const DOMParser = new globals.DOMParser();
|
||||
|
||||
function run_test() {
|
||||
let doc = DOMParser.parseFromString("<div>", "text/html");
|
||||
|
|
|
@ -34,9 +34,6 @@ loader.lazyRequireGetter(this, "WalkerSearch", "devtools/server/actors/utils/wal
|
|||
loader.lazyServiceGetter(this, "eventListenerService",
|
||||
"@mozilla.org/eventlistenerservice;1", "nsIEventListenerService");
|
||||
|
||||
loader.lazyServiceGetter(this, "DOMParser",
|
||||
"@mozilla.org/xmlextras/domparser;1", "nsIDOMParser");
|
||||
|
||||
// Minimum delay between two "new-mutations" events.
|
||||
const MUTATIONS_THROTTLING_DELAY = 100;
|
||||
// List of mutation types that should -not- be throttled.
|
||||
|
@ -1259,7 +1256,7 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, {
|
|||
return;
|
||||
}
|
||||
|
||||
let parsedDOM = DOMParser.parseFromString(value, "text/html");
|
||||
let parsedDOM = new DOMParser().parseFromString(value, "text/html");
|
||||
let rawNode = node.rawNode;
|
||||
let parentNode = rawNode.parentNode;
|
||||
|
||||
|
|
|
@ -20,12 +20,14 @@ function run_test() {
|
|||
|
||||
let g2 = testGlobal("test2");
|
||||
g2.g = g;
|
||||
g2.eval("(" + function createBadEvent() {
|
||||
let parser = Cc["@mozilla.org/xmlextras/domparser;1"]
|
||||
.createInstance(Ci.nsIDOMParser);
|
||||
// Not using the "stringify a function" trick because that runs afoul of the
|
||||
// Cu.importGlobalProperties lint and we don't need it here anyway.
|
||||
g2.eval(`(function createBadEvent() {
|
||||
Cu.importGlobalProperties(["DOMParser"]);
|
||||
let parser = new DOMParser();
|
||||
let doc = parser.parseFromString("<foo></foo>", "text/xml");
|
||||
g.stopMe(doc.createEvent("MouseEvent"));
|
||||
} + ")()");
|
||||
} )()`);
|
||||
|
||||
dbg.enabled = false;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ const {
|
|||
ChromeUtils,
|
||||
CSS,
|
||||
CSSRule,
|
||||
DOMParser,
|
||||
Event,
|
||||
FileReader,
|
||||
FormData,
|
||||
|
@ -48,6 +49,7 @@ const {
|
|||
"ChromeUtils",
|
||||
"CSS",
|
||||
"CSSRule",
|
||||
"DOMParser",
|
||||
"Event",
|
||||
"FileReader",
|
||||
"FormData",
|
||||
|
@ -264,6 +266,7 @@ exports.globals = {
|
|||
define(factory) {
|
||||
factory(this.require, this.exports, this.module);
|
||||
},
|
||||
DOMParser,
|
||||
Element: Ci.nsIDOMElement,
|
||||
Event,
|
||||
FormData,
|
||||
|
@ -315,9 +318,6 @@ lazyGlobal("clearInterval", () => {
|
|||
lazyGlobal("setInterval", () => {
|
||||
return require("resource://gre/modules/Timer.jsm").setInterval;
|
||||
});
|
||||
lazyGlobal("DOMParser", () => {
|
||||
return CC("@mozilla.org/xmlextras/domparser;1", "nsIDOMParser");
|
||||
});
|
||||
lazyGlobal("WebSocket", () => {
|
||||
return Services.appShell.hiddenDOMWindow.WebSocket;
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче