зеркало из https://github.com/mozilla/gecko-dev.git
Bug 726053 This patch removes all forms of 'obj instanceof Components.interfaces' for the new specialpowersAPI call. r=bholley
--HG-- extra : rebase_source : 8a246ed35698c4da3f8a4a5202dcce949121d722
This commit is contained in:
Родитель
21c92bd99e
Коммит
76b7667732
|
@ -29,7 +29,7 @@ function checkTypes(aNode, aNodeType, aTypeArray)
|
|||
function checkInterfaces(aNode, aNodeType, aInterfaceArray)
|
||||
{
|
||||
for (var i = 0; i < aInterfaceArray.length; ++i) {
|
||||
ok(aNode instanceof Components.interfaces[aInterfaceArray[i]],
|
||||
ok(SpecialPowers.call_Instanceof(aNode, Components.interfaces[aInterfaceArray[i]]),
|
||||
aNodeType + " interface test " + i,
|
||||
aNodeType + " should be a " + aInterfaceArray[i]);
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ function checkTypes(aNode, aNodeType, aTypeArray)
|
|||
function checkInterfaces(aNode, aNodeType, aInterfaceArray)
|
||||
{
|
||||
for (var i = 0; i < aInterfaceArray.length; ++i) {
|
||||
ok(aNode instanceof Components.interfaces[aInterfaceArray[i]],
|
||||
ok(SpecialPowers.call_Instanceof(aNode, Components.interfaces[aInterfaceArray[i]]),
|
||||
aNodeType + " interface test " + i,
|
||||
aNodeType + " should be a " + aInterfaceArray[i]);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,8 @@ function doContentTest(id) {
|
|||
}
|
||||
|
||||
function checkPrincipal() {
|
||||
is(SpecialPowers.getNodePrincipal(document) instanceof Components.interfaces.nsIPrincipal,
|
||||
is(SpecialPowers.call_Instanceof(SpecialPowers.getNodePrincipal(document),
|
||||
Components.interfaces.nsIPrincipal),
|
||||
true,
|
||||
"Should be a principal");
|
||||
}
|
||||
|
|
|
@ -37,10 +37,11 @@ for each (var i in body) {
|
|||
xhr.open("POST", url, true);
|
||||
xhr.send(i);
|
||||
var chan = SpecialPowers.unwrap(SpecialPowers.wrap(xhr).channel);
|
||||
if (!(chan instanceof Components.interfaces.nsIUploadChannel))
|
||||
if (!SpecialPowers.call_Instanceof(chan, Components.interfaces.nsIUploadChannel))
|
||||
throw "Must be an upload channel";
|
||||
var stream = chan.uploadStream;
|
||||
if (!stream || !(stream instanceof Components.interfaces.nsISeekableStream))
|
||||
if (!stream || !SpecialPowers.call_Instanceof(stream,
|
||||
Components.interfaces.nsISeekableStream))
|
||||
throw "Stream must be seekable";
|
||||
// the following is a no-op, but should not throw an exception
|
||||
stream.seek(Components.interfaces.nsISeekableStream.NS_SEEK_CUR, 0);
|
||||
|
|
|
@ -29,12 +29,12 @@ function logEvent(evt) {
|
|||
while ((currentEvents.length != i) &&
|
||||
currentEvents[i].optional &&
|
||||
((currentEvents[i].type != evt.type) ||
|
||||
!(evt.target instanceof currentEvents[i].target))) {
|
||||
!(SpecialPowers.call_Instanceof(evt.target, currentEvents[i].target)))) {
|
||||
++i;
|
||||
}
|
||||
ok(i != currentEvents.length, "Extra or wrong event?");
|
||||
is(evt.type, currentEvents[i].type, "Wrong event!")
|
||||
ok(evt.target instanceof currentEvents[i].target,
|
||||
ok(SpecialPowers.call_Instanceof(evt.target, currentEvents[i].target),
|
||||
"Wrong event target [" + evt.target + "," + evt.type + "]!");
|
||||
// If we handled non-optional event, remove all optional events before the
|
||||
// handled event and then the non-optional event from the list.
|
||||
|
|
|
@ -32,9 +32,9 @@ function testHTMLDocuments(ids, isXHTML) {
|
|||
is(docType1.ownerDocument, doc1, "docType should have ownerDocument!");
|
||||
ok(!doc1.documentElement, "Document shouldn't have document element!");
|
||||
is(doc1.body, null, "Shouldn't have .body!");
|
||||
ok(doc1 instanceof Components.interfaces.nsIDOMHTMLDocument,
|
||||
ok(SpecialPowers.call_Instanceof(doc1, Components.interfaces.nsIDOMHTMLDocument),
|
||||
"Document should be an HTML document!");
|
||||
ok(!(doc1 instanceof Components.interfaces.nsIDOMSVGDocument),
|
||||
ok(!SpecialPowers.call_Instanceof(doc1, Components.interfaces.nsIDOMSVGDocument),
|
||||
"Document shouldn't be an SVG document!");
|
||||
|
||||
var docType2 =
|
||||
|
@ -68,9 +68,9 @@ function testSVGDocument() {
|
|||
var doc1 = document.implementation.createDocument(null, null, docType1);
|
||||
is(docType1.ownerDocument, doc1, "docType should have ownerDocument!");
|
||||
ok(!doc1.documentElement, "Document shouldn't have document element!");
|
||||
ok(!(doc1 instanceof Components.interfaces.nsIDOMHTMLDocument),
|
||||
ok(!SpecialPowers.call_Instanceof(doc1, Components.interfaces.nsIDOMHTMLDocument),
|
||||
"Document shouldn't be an HTML document!");
|
||||
ok(doc1 instanceof Components.interfaces.nsIDOMSVGDocument,
|
||||
ok(SpecialPowers.call_Instanceof(doc1, Components.interfaces.nsIDOMSVGDocument),
|
||||
"Document should be an SVG document!");
|
||||
|
||||
// SVG documents have .rootElement.
|
||||
|
@ -95,9 +95,9 @@ function testFooBarDocument() {
|
|||
var doc1 = document.implementation.createDocument(null, null, docType1);
|
||||
is(docType1.ownerDocument, doc1, "docType should have ownerDocument!");
|
||||
ok(!doc1.documentElement, "Document shouldn't have document element!");
|
||||
ok(!(doc1 instanceof Components.interfaces.nsIDOMHTMLDocument),
|
||||
ok(!SpecialPowers.call_Instanceof(doc1, Components.interfaces.nsIDOMHTMLDocument),
|
||||
"Document shouldn't be an HTML document!");
|
||||
ok(!(doc1 instanceof Components.interfaces.nsIDOMSVGDocument),
|
||||
ok(!SpecialPowers.call_Instanceof(doc1, Components.interfaces.nsIDOMSVGDocument),
|
||||
"Document shouldn't be an SVG document!");
|
||||
|
||||
var docType2 =
|
||||
|
@ -112,9 +112,9 @@ function testFooBarDocument() {
|
|||
function testNullDocTypeDocument() {
|
||||
var doc1 = document.implementation.createDocument(null, null, null);
|
||||
ok(!doc1.documentElement, "Document shouldn't have document element!");
|
||||
ok(!(doc1 instanceof Components.interfaces.nsIDOMHTMLDocument),
|
||||
ok(!SpecialPowers.call_Instanceof(doc1, Components.interfaces.nsIDOMHTMLDocument),
|
||||
"Document shouldn't be an HTML document!");
|
||||
ok(!(doc1 instanceof Components.interfaces.nsIDOMSVGDocument),
|
||||
ok(!SpecialPowers.call_Instanceof(doc1, Components.interfaces.nsIDOMSVGDocument),
|
||||
"Document shouldn't be an SVG document!");
|
||||
|
||||
var doc2 = document.implementation.createDocument("FooBarNS",
|
||||
|
|
|
@ -245,14 +245,15 @@ for each (var tag in allTags) {
|
|||
tagName(tag) + " not an instance of " + classInfos[tag]);
|
||||
is(node instanceof HTMLUnknownElement, false,
|
||||
tagName(tag) + " is an instance of HTMLUnknownElement");
|
||||
is(node instanceof Components.interfaces.nsIDOMHTMLUnknownElement, false,
|
||||
is(SpecialPowers.call_Instanceof(node, Components.interfaces.nsIDOMHTMLUnknownElement),
|
||||
false,
|
||||
tagName(tag) + " is an instance of nsIDOMHTMLUnknownElement");
|
||||
|
||||
// Check that each node QIs to all the things we expect it to QI to
|
||||
for each (var iface in interfaces[tag].concat(interfacesNonClassinfo[tag])) {
|
||||
is(iface in Components.interfaces, true,
|
||||
iface + " not in Components.interfaces");
|
||||
is(node instanceof Components.interfaces[iface], true,
|
||||
is(SpecialPowers.call_Instanceof(node, Components.interfaces[iface]), true,
|
||||
tagName(tag) + " does not QI to " + iface);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,14 +82,14 @@ function verifyBuffers(buffer1, buffer2)
|
|||
|
||||
function verifyBlob(blob1, blob2, fileId, blobReadHandler)
|
||||
{
|
||||
is(blob1 instanceof Components.interfaces.nsIDOMBlob, true,
|
||||
is(SpecialPowers.call_Instanceof(blob1, Components.interfaces.nsIDOMBlob), true,
|
||||
"Instance of nsIDOMBlob");
|
||||
is(blob1 instanceof Components.interfaces.nsIDOMFile,
|
||||
blob2 instanceof Components.interfaces.nsIDOMFile,
|
||||
is(SpecialPowers.call_Instanceof(blob1, Components.interfaces.nsIDOMFile),
|
||||
SpecialPowers.call_Instanceof(blob2, Components.interfaces.nsIDOMFile),
|
||||
"Instance of nsIDOMFile");
|
||||
is(blob1.size, blob2.size, "Correct size");
|
||||
is(blob1.type, blob2.type, "Correct type");
|
||||
if (blob2 instanceof Components.interfaces.nsIDOMFile) {
|
||||
if (SpecialPowers.call_Instanceof(blob2, Components.interfaces.nsIDOMFile)) {
|
||||
is(blob1.name, blob2.name, "Correct name");
|
||||
}
|
||||
is(utils.getFileId(blob1), fileId, "Correct file id");
|
||||
|
|
|
@ -22,7 +22,7 @@ var x = new XMLHttpRequest();
|
|||
x.open("GET", document.location.href);
|
||||
x.send("");
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
is(x instanceof Components.interfaces.nsIInterfaceRequestor,
|
||||
is(SpecialPowers.call_Instanceof(x, Components.interfaces.nsIInterfaceRequestor),
|
||||
true, "Must be interface requestor");
|
||||
|
||||
var count = {};
|
||||
|
|
|
@ -67,7 +67,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=502673
|
|||
function doTest() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
var input = document.getElementById("ip");
|
||||
if (input instanceof Components.interfaces.nsIDOMNSEditableElement) {
|
||||
if (SpecialPowers.call_Instanceof(input, Components.interfaces.nsIDOMNSEditableElement)) {
|
||||
// Add multiple listeners to the same editor
|
||||
var editor = input.editor;
|
||||
var listener1 = new listener();
|
||||
|
|
|
@ -32,7 +32,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=471722
|
|||
var editor = null;
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
if (t1 instanceof Components.interfaces.nsIDOMNSEditableElement)
|
||||
if (SpecialPowers.call_Instanceof(t1, Components.interfaces.nsIDOMNSEditableElement))
|
||||
editor = t1.editor;
|
||||
ok(editor, "able to get editor for the element");
|
||||
t1.focus();
|
||||
|
|
|
@ -35,7 +35,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=483651
|
|||
var t1 = $("t1");
|
||||
var editor = null;
|
||||
|
||||
if (t1 instanceof Components.interfaces.nsIDOMNSEditableElement)
|
||||
if (SpecialPowers.call_Instanceof(t1, Components.interfaces.nsIDOMNSEditableElement))
|
||||
editor = t1.editor;
|
||||
|
||||
ok(editor, "able to get editor for the element");
|
||||
|
|
|
@ -63,7 +63,9 @@ function do_test() {
|
|||
|
||||
try {
|
||||
var res = utils.getBindingURLs(docElement);
|
||||
is(res instanceof Components.interfaces["nsIArray"], true, "getBindingURLs result type");
|
||||
is(SpecialPowers.call_Instanceof(res, Components.interfaces["nsIArray"]),
|
||||
true,
|
||||
"getBindingURLs result type");
|
||||
is(res.length, 0, "getBindingURLs array length");
|
||||
}
|
||||
catch(e) { ok(false, "got an unexpected exception:" + e); }
|
||||
|
|
|
@ -634,6 +634,12 @@ SpecialPowersAPI.prototype = {
|
|||
return obj.QueryInterface(Ci[iface]);
|
||||
},
|
||||
|
||||
call_Instanceof: function (obj1, obj2) {
|
||||
obj1=unwrapIfWrapped(obj1);
|
||||
obj2=unwrapIfWrapped(obj2);
|
||||
return obj1 instanceof obj2;
|
||||
},
|
||||
|
||||
// Mimic the get*Pref API
|
||||
getBoolPref: function(aPrefName) {
|
||||
return (this._getPref(aPrefName, 'BOOL'));
|
||||
|
|
Загрузка…
Ссылка в новой задаче