Bug 1442239 - Fix test since nsSimpleURI can't be constructed via createInstance() anymore draft
authorValentin Gosu <valentin.gosu@gmail.com>
Mon, 19 Mar 2018 20:22:36 +0100
changeset 769531 0be91a02446e47033a233481619358ea95a3be5b
parent 769530 1755494b67c9b18f363b63f7c3311efdd35a6cd3
push id103160
push uservalentin.gosu@gmail.com
push dateMon, 19 Mar 2018 19:23:02 +0000
bugs1442239
milestone61.0a1
Bug 1442239 - Fix test since nsSimpleURI can't be constructed via createInstance() anymore * 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);
 }