mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 495167. Make XPCOMUtils.generateQI deal with string interface names. r+sr=bsmedberg
This commit is contained in:
parent
8ba9ed33c5
commit
eb5f032de5
@ -82,7 +82,9 @@
|
||||
* // QueryInterface implementation, e.g. using the generateQI helper
|
||||
* QueryInterface: XPCOMUtils.generateQI(
|
||||
* [Components.interfaces.nsIObserver,
|
||||
* Components.interfaces.nsIMyInterface]),
|
||||
* Components.interfaces.nsIMyInterface,
|
||||
* "nsIFoo",
|
||||
* "nsIBar" ]),
|
||||
*
|
||||
* // ...component implementation...
|
||||
* };
|
||||
@ -112,7 +114,8 @@ var XPCOMUtils = {
|
||||
* param, and if it is, returns |this| (the object it was called on).
|
||||
*/
|
||||
generateQI: function(interfaces) {
|
||||
return makeQI([i.name for each (i in interfaces) if (i)]);
|
||||
/* Note that Ci[Ci.x] == Ci.x for all x */
|
||||
return makeQI([Ci[i].name for each (i in interfaces) if (Ci[i])]);
|
||||
},
|
||||
|
||||
/**
|
||||
|
23
js/src/xpconnect/tests/unit/test_xpcomutils.js
Normal file
23
js/src/xpconnect/tests/unit/test_xpcomutils.js
Normal file
@ -0,0 +1,23 @@
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
var x = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIClassInfo,
|
||||
"nsIDOMNode"])
|
||||
};
|
||||
|
||||
function run_test() {
|
||||
try {
|
||||
x.QueryInterface(Components.interfaces.nsIClassInfo);
|
||||
} catch(e) {
|
||||
do_throw("Should QI to nsIClassInfo");
|
||||
}
|
||||
try {
|
||||
x.QueryInterface(Components.interfaces.nsIDOMNode);
|
||||
} catch(e) {
|
||||
do_throw("Should QI to nsIDOMNode");
|
||||
}
|
||||
try {
|
||||
x.QueryInterface(Components.interfaces.nsIDOMDocument);
|
||||
do_throw("QI should not have succeeded!");
|
||||
} catch(e) {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user