Bug 792808 - Change js/xpconnect to import and instantiate XHRs from global properties rather than using Cc.createInstance(Ci.nsIXMLHttpRequest); r=bz
authorThomas Wisniewski <wisniewskit@gmail.com>
Sun, 21 Jan 2018 14:46:11 -0500
changeset 404225 eafbaf250b12b49985043fa61dd795878282e190
parent 404224 4d3bc187d05c62dffe50132f328b71220db3f884
child 404226 ed441df27dadbf9dab6909f1292404a0142890a6
push id99968
push userrgurzau@mozilla.com
push dateFri, 16 Feb 2018 22:14:56 +0000
treeherdermozilla-inbound@2e16779c96cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs792808
milestone60.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 792808 - Change js/xpconnect to import and instantiate XHRs from global properties rather than using Cc.createInstance(Ci.nsIXMLHttpRequest); r=bz MozReview-Commit-ID: DZZ9NUysT5I
js/xpconnect/tests/unit/test_sandbox_metadata.js
--- a/js/xpconnect/tests/unit/test_sandbox_metadata.js
+++ b/js/xpconnect/tests/unit/test_sandbox_metadata.js
@@ -6,16 +6,18 @@
 
 function run_test()
 {
   let sandbox = Components.utils.Sandbox("http://www.blah.com", {
     metadata: "test metadata",
     addonId: "12345"
   });
 
+  Components.utils.importGlobalProperties(["XMLHttpRequest"]);
+
   Assert.equal(Components.utils.getSandboxMetadata(sandbox), "test metadata");
   Assert.equal(Components.utils.getSandboxAddonId(sandbox), "12345");
 
   sandbox = Components.utils.Sandbox("http://www.blah.com", {
     metadata: { foopy: { bar: 2 }, baz: "hi" }
   });
 
   let metadata = Components.utils.getSandboxMetadata(sandbox);
@@ -28,18 +30,17 @@ function run_test()
 
   metadata = { foo: "bar" };
   Components.utils.setSandboxMetadata(sandbox, metadata);
   metadata.foo = "baz";
   metadata = Components.utils.getSandboxMetadata(sandbox);
   Assert.equal(metadata.foo, "bar");
 
   let thrown = false;
-  let reflector = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
-                    .createInstance(Components.interfaces.nsIXMLHttpRequest);
+  let reflector = new XMLHttpRequest();
 
   try {
     Components.utils.setSandboxMetadata(sandbox, { foo: reflector });
   } catch(e) {
     thrown = true;
   }
 
   Assert.equal(thrown, true);