Skip to content

Commit

Permalink
Bug 1545831 - Use ChromeUtils.generateQI in a few more places. r=kmag
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D28241

--HG--
extra : moz-landing-system : lando
  • Loading branch information
amccreight committed Apr 19, 2019
1 parent dd528e5 commit 9c94962
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 124 deletions.
8 changes: 1 addition & 7 deletions dom/base/test/chrome/test_bug429785.xul
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=429785
const serv = Cc["@mozilla.org/consoleservice;1"]
.getService(Ci.nsIConsoleService);
var listener = {
QueryInterface : function(iid) {
if (!iid.equals(Ci.nsISupports) &&
!iid.equals(Ci.nsIConsoleListener)) {
throw Cr.NS_NOINTERFACE;
}
return this;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIConsoleListener]),
observe : function (msg) { errorLogged = true; }
};
Expand Down
10 changes: 2 additions & 8 deletions editor/composer/test/test_bug434998.xul
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=434998
this.mEditor = aEditor;
},
QueryInterface : function(aIID)
{
if (aIID.equals(Ci.nsIWebProgressListener) ||
aIID.equals(Ci.nsISupportsWeakReference) ||
aIID.equals(Ci.nsISupports))
return this;
throw Cr.NS_NOINTERFACE;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference]),
onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
{
Expand Down
30 changes: 12 additions & 18 deletions editor/libeditor/tests/test_bug607584.xul
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=607584
{
this.init(aEditor);
}
EditorContentListener.prototype = {
init : function(aEditor)
{
this.mEditor = aEditor;
},
QueryInterface : function(aIID)
{
if (aIID.equals(Ci.nsIWebProgressListener) ||
aIID.equals(Ci.nsISupportsWeakReference) ||
aIID.equals(Ci.nsISupports))
return this;
throw Cr.NS_NOINTERFACE;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference]),
onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
{
if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP)
Expand All @@ -73,32 +67,32 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=607584
SimpleTest.finish();
}
}
},
onProgressChange : function(aWebProgress, aRequest,
aCurSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aMaxTotalProgress)
{
},
onLocationChange : function(aWebProgress, aRequest, aLocation, aFlags)
{
},
onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage)
{
},
onSecurityChange : function(aWebProgress, aRequest, aState)
{
},
onContentBlockingEvent : function(aWebProgress, aRequest, aEvent)
{
},
mEditor: null
};
Expand Down
10 changes: 2 additions & 8 deletions editor/libeditor/tests/test_bug616590.xul
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=616590
this.mEditor = aEditor;
},
QueryInterface : function(aIID)
{
if (aIID.equals(Ci.nsIWebProgressListener) ||
aIID.equals(Ci.nsISupportsWeakReference) ||
aIID.equals(Ci.nsISupports))
return this;
throw Cr.NS_NOINTERFACE;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference]),
onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
{
Expand Down
16 changes: 5 additions & 11 deletions editor/libeditor/tests/test_bug780908.xul
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,16 @@ adapted from test_bug607584.xul by Kent James <[email protected]>
{
this.init(aEditor);
}
EditorContentListener.prototype = {
init : function(aEditor)
{
this.mEditor = aEditor;
},
QueryInterface : function(aIID)
{
if (aIID.equals(Ci.nsIWebProgressListener) ||
aIID.equals(Ci.nsISupportsWeakReference) ||
aIID.equals(Ci.nsISupports))
return this;
throw Cr.NS_NOINTERFACE;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference]),
onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
{
if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP)
Expand Down
10 changes: 2 additions & 8 deletions layout/tools/layout-debug/ui/content/layoutdebug.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@ nsLDBBrowserContentListener.prototype = {
this.mStopButton = document.getElementById("stop-button");
},

QueryInterface : function(aIID)
{
if (aIID.equals(Ci.nsIWebProgressListener) ||
aIID.equals(Ci.nsISupportsWeakReference) ||
aIID.equals(Ci.nsISupports))
return this;
throw Cr.NS_NOINTERFACE;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference]),

// nsIWebProgressListener implementation
onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
Expand Down
22 changes: 3 additions & 19 deletions netwerk/test/unit/test_protocolproxyservice-async-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ var prefs = Cc["@mozilla.org/preferences-service;1"]
function TestProtocolHandler() {
}
TestProtocolHandler.prototype = {
QueryInterface: function(iid) {
if (iid.equals(Ci.nsIProtocolHandler) ||
iid.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIProtocolHandler]),
scheme: "moz-test",
defaultPort: -1,
protocolFlags: Ci.nsIProtocolHandler.URI_NOAUTH |
Expand Down Expand Up @@ -106,12 +101,7 @@ TestFilter.prototype = {
_async: false,
_throwing: false,

QueryInterface: function(iid) {
if (iid.equals(Ci.nsIProtocolProxyFilter) ||
iid.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIProtocolProxyFilter]),

applyFilter: function(pps, uri, pi, cb) {
if (this._result == THROW) {
Expand All @@ -137,13 +127,7 @@ function resolveCallback() { }
resolveCallback.prototype = {
nextFunction: null,

QueryInterface : function (iid) {
const interfaces = [Ci.nsIProtocolProxyCallback,
Ci.nsISupports];
if (!interfaces.some( function(v) { return iid.equals(v) } ))
throw Cr.NS_ERROR_NO_INTERFACE;
return this;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIProtocolProxyCallback]),

onProxyAvailable : function (req, channel, pi, status) {
this.nextFunction(pi);
Expand Down
52 changes: 7 additions & 45 deletions netwerk/test/unit/test_protocolproxyservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ var prefs = Cc["@mozilla.org/preferences-service;1"]
function TestProtocolHandler() {
}
TestProtocolHandler.prototype = {
QueryInterface: function(iid) {
if (iid.equals(Ci.nsIProtocolHandler) ||
iid.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIProtocolHandler]),
scheme: "moz-test",
defaultPort: -1,
protocolFlags: Ci.nsIProtocolHandler.URI_NOAUTH |
Expand Down Expand Up @@ -109,12 +104,7 @@ TestFilter.prototype = {
_port: -1,
_flags: 0,
_timeout: 0,
QueryInterface: function(iid) {
if (iid.equals(Ci.nsIProtocolProxyFilter) ||
iid.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIProtocolProxyFilter]),
applyFilter: function(pps, uri, pi, cb) {
var pi_tail = pps.newProxyInfo(this._type, this._host, this._port,
this._flags, this._timeout, null);
Expand All @@ -128,12 +118,7 @@ TestFilter.prototype = {

function BasicFilter() {}
BasicFilter.prototype = {
QueryInterface: function(iid) {
if (iid.equals(Ci.nsIProtocolProxyFilter) ||
iid.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIProtocolProxyFilter]),
applyFilter: function(pps, uri, pi, cb) {
cb.onProxyFilterResult(
pps.newProxyInfo("http", "localhost", 8080, 0, 10,
Expand All @@ -144,12 +129,7 @@ BasicFilter.prototype = {

function BasicChannelFilter() {}
BasicChannelFilter.prototype = {
QueryInterface: function(iid) {
if (iid.equals(Ci.nsIProtocolProxyChannelFilter) ||
iid.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIProtocolProxyChannelFilter]),
applyFilter: function(pps, channel, pi, cb) {
cb.onProxyFilterResult(
pps.newProxyInfo("http", channel.URI.host, 7777, 0, 10,
Expand All @@ -162,13 +142,7 @@ function resolveCallback() { }
resolveCallback.prototype = {
nextFunction: null,

QueryInterface : function (iid) {
const interfaces = [Ci.nsIProtocolProxyCallback,
Ci.nsISupports];
if (!interfaces.some( function(v) { return iid.equals(v) } ))
throw Cr.NS_ERROR_NO_INTERFACE;
return this;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIProtocolProxyCallback]),

onProxyAvailable : function (req, channel, pi, status) {
this.nextFunction(pi);
Expand Down Expand Up @@ -491,13 +465,7 @@ function TestResolveCallback(type, nexttest) {
this.nexttest = nexttest;
}
TestResolveCallback.prototype = {
QueryInterface:
function TestResolveCallback_QueryInterface(iid) {
if (iid.equals(Ci.nsIProtocolProxyCallback) ||
iid.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIProtocolProxyCallback]),

onProxyAvailable:
function TestResolveCallback_onProxyAvailable(req, channel, pi, status) {
Expand Down Expand Up @@ -658,13 +626,7 @@ function finish_pac_test() {
function TestResolveCancelationCallback() {
}
TestResolveCancelationCallback.prototype = {
QueryInterface:
function TestResolveCallback_QueryInterface(iid) {
if (iid.equals(Ci.nsIProtocolProxyCallback) ||
iid.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
QueryInterface: ChromeUtils.generateQI([Ci.nsIProtocolProxyCallback]),

onProxyAvailable:
function TestResolveCancelationCallback_onProxyAvailable(req, channel, pi, status) {
Expand Down

0 comments on commit 9c94962

Please sign in to comment.