Bug 935379 - RemoteWebProgress should handle missing/failing progress listener methods. r=felipe

This commit is contained in:
Mark Hammond 2013-11-07 10:43:59 +11:00
parent 4bc333961e
commit 5d2aaf2137

View File

@ -109,6 +109,18 @@ RemoteWebProgressManager.prototype = {
return [deserialized, aState];
},
_callProgressListeners: function(methodName, ...args) {
for (let p of this._progressListeners) {
if (p[methodName]) {
try {
p[methodName].apply(p, args);
} catch (ex) {
Cu.reportError("RemoteWebProgress failed to call " + methodName + ": " + ex + "\n");
}
}
}
},
receiveMessage: function (aMessage) {
let json = aMessage.json;
let objects = aMessage.objects;
@ -133,9 +145,7 @@ RemoteWebProgressManager.prototype = {
switch (aMessage.name) {
case "Content:StateChange":
for (let p of this._progressListeners) {
p.onStateChange(webProgress, request, json.stateFlags, json.status);
}
this._callProgressListeners("onStateChange", webProgress, request, json.stateFlags, json.status);
break;
case "Content:LocationChange":
@ -150,9 +160,7 @@ RemoteWebProgressManager.prototype = {
this._browser._imageDocument = null;
}
for (let p of this._progressListeners) {
p.onLocationChange(webProgress, request, location);
}
this._callProgressListeners("onLocationChange", webProgress, request, location);
break;
case "Content:SecurityChange":
@ -166,15 +174,11 @@ RemoteWebProgressManager.prototype = {
this._browser._securityUI._update(status, state);
}
for (let p of this._progressListeners) {
p.onSecurityChange(webProgress, request, state);
}
this._callProgressListeners("onSecurityChange", webProgress, request, state);
break;
case "Content:StatusChange":
for (let p of this._progressListeners) {
p.onStatusChange(webProgress, request, json.status, json.message);
}
this._callProgressListeners("onStatusChange", webProgress, request, json.status, json.message);
break;
}
}