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
--- 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);
}