Bug 1266840 - Define XMLHttpRequest in devtools loader. r=jryans
authorTom Tromey <tom@tromey.com>
Thu, 12 May 2016 13:51:51 -0600
changeset 336449 aeeab770eafee07e2f2b9330f5bf6e2f55552202
parent 336448 a356bf6785676f4db1cc7d25eb65f7cd84203408
child 336450 b1ff014a973c1a1d5218cf0be7034f49f2dd537c
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1266840
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1266840 - Define XMLHttpRequest in devtools loader. r=jryans MozReview-Commit-ID: 5F2UlTlzx1R
devtools/.eslintrc
devtools/client/shared/widgets/MdnDocsWidget.js
devtools/shared/builtin-modules.js
--- a/devtools/.eslintrc
+++ b/devtools/.eslintrc
@@ -12,16 +12,17 @@
     "dump": true,
     "exports": true,
     "isWorker": true,
     "loader": true,
     "module": true,
     "require": true,
     "setInterval": true,
     "setTimeout": true,
+    "XMLHttpRequest": true,
     "_Iterator": true,
   },
   "rules": {
     // These are the rules that have been configured so far to match the
     // devtools coding style.
 
     // Rules from the mozilla plugin
     "mozilla/mark-test-function-used": 1,
--- a/devtools/client/shared/widgets/MdnDocsWidget.js
+++ b/devtools/client/shared/widgets/MdnDocsWidget.js
@@ -155,17 +155,17 @@ exports.appendSyntaxHighlightedCSS = app
  * The promise is resolved with the page as an XML document.
  *
  * The promise is rejected with an error message if
  * we could not load the page.
  */
 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);
 
   xhr.open("GET", pageUrl);
   xhr.responseType = "document";
   xhr.send();
 
--- a/devtools/shared/builtin-modules.js
+++ b/devtools/shared/builtin-modules.js
@@ -239,16 +239,23 @@ const globals = exports.globals = {
   _Iterator: Iterator,
   loader: {
     lazyGetter: defineLazyGetter,
     lazyImporter: defineLazyModuleGetter,
     lazyServiceGetter: defineLazyServiceGetter,
     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
   // from a content document and can't access our usual loaders.  So, any
   // modules shared with the JSON Viewer should include a define wrapper:
   //
   //   // Make this available to both AMD and CJS environments
   //   define(function(require, exports, module) {