Bug 1442239 - Fix test since nsSimpleURI can't be constructed via createInstance() anymore r=Waldo
☠☠ backed out by 49d1cb161b40 ☠ ☠
authorValentin Gosu <valentin.gosu@gmail.com>
Thu, 08 Mar 2018 14:21:23 +0100
changeset 769709 513cd669aca140b8792069c05c4b5215d88bb41a
parent 769708 aef4c73f736f3e38972834dfe9826066bc9cb721
child 769710 64c5f14f196bb4e24c87601886b8fdcbb446fd4b
push id103206
push userbmo:bdahl@mozilla.com
push dateMon, 19 Mar 2018 23:33:04 +0000
reviewersWaldo
bugs1442239
milestone61.0a1
Bug 1442239 - Fix test since nsSimpleURI can't be constructed via createInstance() anymore r=Waldo * I am not entirely sure what this test is doing, but I found that replacing nsSimpleURI with CSPContext makes it work. MozReview-Commit-ID: 4ATVXVrYX56
js/xpconnect/tests/unit/test_classesByID_instanceof.js
--- a/js/xpconnect/tests/unit/test_classesByID_instanceof.js
+++ b/js/xpconnect/tests/unit/test_classesByID_instanceof.js
@@ -1,44 +1,44 @@
-function testActual(SimpleURIClassByID)
+function testActual(CSPContextClassByID)
 {
-  var simpleURI =
-    Cc["@mozilla.org/network/simple-uri;1"].createInstance();
+  var cspContext =
+    Cc["@mozilla.org/cspcontext;1"].createInstance();
 
-  Assert.equal(simpleURI instanceof SimpleURIClassByID, true);
+  Assert.equal(cspContext instanceof CSPContextClassByID, true);
 }
 
-function testInherited(SimpleURIClassByID)
+function testInherited(CSPContextClassByID)
 {
-  var simpleURI =
-    Cc["@mozilla.org/network/simple-uri;1"].createInstance();
+  var cspContext =
+    Cc["@mozilla.org/cspcontext;1"].createInstance();
 
-  var inherited = Object.create(simpleURI);
+  var inherited = Object.create(cspContext);
 
-  Assert.equal(inherited instanceof SimpleURIClassByID, true);
+  Assert.equal(inherited instanceof CSPContextClassByID, true);
 }
 
-function testInheritedCrossGlobal(SimpleURIClassByID)
+function testInheritedCrossGlobal(CSPContextClassByID)
 {
-  var simpleURI =
-    Cc["@mozilla.org/network/simple-uri;1"].createInstance();
+  var cspContext =
+    Cc["@mozilla.org/cspcontext;1"].createInstance();
 
   var sb = new Cu.Sandbox(this, { wantComponents: true });
-  var inheritedCross = sb.Object.create(simpleURI);
+  var inheritedCross = sb.Object.create(cspContext);
 
-  Assert.equal(inheritedCross instanceof SimpleURIClassByID, true);
+  Assert.equal(inheritedCross instanceof CSPContextClassByID, true);
 }
 
-function testCrossGlobalArbitraryGetPrototype(SimpleURIClassByID)
+function testCrossGlobalArbitraryGetPrototype(CSPContextClassByID)
 {
-  var simpleURI =
-    Cc["@mozilla.org/network/simple-uri;1"].createInstance();
+  var cspContext =
+    Cc["@mozilla.org/cspcontext;1"].createInstance();
 
   var sb = new Cu.Sandbox(this, { wantComponents: true });
-  var firstLevel = Object.create(simpleURI);
+  var firstLevel = Object.create(cspContext);
 
   var obj = { shouldThrow: false };
   var secondLevel =
     new sb.Proxy(Object.create(firstLevel),
                  {
                    getPrototypeOf: new sb.Function("obj", `return function(t) {
                      if (obj.shouldThrow)
                        throw 42;
@@ -48,32 +48,32 @@ function testCrossGlobalArbitraryGetProt
   var thirdLevel = Object.create(secondLevel);
 
   obj.shouldThrow = true;
 
   var threw = false;
   var err;
   try
   {
-    void (thirdLevel instanceof SimpleURIClassByID);
+    void (thirdLevel instanceof CSPContextClassByID);
   }
   catch (e)
   {
     threw = true;
     err = e;
   }
 
   Assert.equal(threw, true);
   Assert.equal(err, 42);
 
   obj.shouldThrow = false;
 
-  Assert.equal(thirdLevel instanceof SimpleURIClassByID, true);
+  Assert.equal(thirdLevel instanceof CSPContextClassByID, true);
 }
 
 function run_test() {
-  var SimpleURIClassByID = Components.classesByID["{e0da1d70-2f7b-11d3-8cd0-0060b0fc14a3}"];
+  var CSPContextClassByID = Components.classesByID["{09d9ed1a-e5d4-4004-bfe0-27ceb923d9ac}"];
 
-  testActual(SimpleURIClassByID);
-  testInherited(SimpleURIClassByID);
-  testInheritedCrossGlobal(SimpleURIClassByID);
-  testCrossGlobalArbitraryGetPrototype(SimpleURIClassByID);
+  testActual(CSPContextClassByID);
+  testInherited(CSPContextClassByID);
+  testInheritedCrossGlobal(CSPContextClassByID);
+  testCrossGlobalArbitraryGetPrototype(CSPContextClassByID);
 }