3 add_task(async function test_generateQI() {
4 function checkQI(interfaces, iface) {
6 QueryInterface: ChromeUtils.generateQI(interfaces),
8 equal(obj.QueryInterface(iface), obj,
9 `Correct return value for query to ${iface}`);
12 // Test success scenarios.
13 checkQI([], Ci.nsISupports);
15 checkQI([Ci.nsIPropertyBag, "nsIPropertyBag2"], Ci.nsIPropertyBag);
16 checkQI([Ci.nsIPropertyBag, "nsIPropertyBag2"], Ci.nsIPropertyBag2);
18 checkQI([Ci.nsIPropertyBag, "nsIPropertyBag2", "nsINotARealInterface"], Ci.nsIPropertyBag2);
20 // Non-IID values get stringified, and don't cause any errors as long
21 // as there isn't a non-IID property with the same name on Ci.
22 checkQI([Ci.nsIPropertyBag, "nsIPropertyBag2", null, Object], Ci.nsIPropertyBag2);
24 ChromeUtils.generateQI([])(Ci.nsISupports);
26 // Test failure scenarios.
27 Assert.throws(() => checkQI([], Ci.nsIPropertyBag),
28 e => e.result == Cr.NS_ERROR_NO_INTERFACE);