Bug 1266840 - Define XMLHttpRequest in devtools loader. r=jryans

MozReview-Commit-ID: 5F2UlTlzx1R

--HG--
extra : transplant_source : %A3%F20%C8%BE%3F%19%C1%F8%A2%A9%FFF3%BBr%8E%95%B0%F5
This commit is contained in:
Tom Tromey 2016-05-12 13:51:51 -06:00
parent 3938b1fcd9
commit 8493b659d3
3 changed files with 9 additions and 1 deletions

View File

@ -17,6 +17,7 @@
"require": true,
"setInterval": true,
"setTimeout": true,
"XMLHttpRequest": true,
"_Iterator": true,
},
"rules": {

View File

@ -160,7 +160,7 @@ exports.appendSyntaxHighlightedCSS = appendSyntaxHighlightedCSS;
function getMdnPage(pageUrl) {
let deferred = Promise.defer();
let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
let xhr = new XMLHttpRequest();
xhr.addEventListener("load", onLoaded, false);
xhr.addEventListener("error", onError, false);

View File

@ -244,6 +244,13 @@ const globals = exports.globals = {
lazyRequireGetter: lazyRequireGetter,
id: null // Defined by Loader.jsm
},
// Let new XMLHttpRequest do the right thing.
XMLHttpRequest: function () {
return Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance(Ci.nsIXMLHttpRequest);
},
// Make sure `define` function exists. This allows defining some modules
// in AMD format while retaining CommonJS compatibility through this hook.
// JSON Viewer needs modules in AMD format, as it currently uses RequireJS