mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 960619 - part 4 - explicitly return values from SpecialPowersObserverAPI._receiveMessageAPI to avoid warning spew; r=jmaher
This commit is contained in:
parent
0436e5b7cf
commit
646e9152c0
@ -165,6 +165,9 @@ SpecialPowersObserverAPI.prototype = {
|
||||
* This will get requests from our API in the window and process them in chrome for it
|
||||
**/
|
||||
_receiveMessageAPI: function(aMessage) {
|
||||
// We explicitly return values in the below code so that this function
|
||||
// doesn't trigger a flurry of warnings about "does not always return
|
||||
// a value".
|
||||
switch(aMessage.name) {
|
||||
case "SPPrefService":
|
||||
var prefs = Services.prefs;
|
||||
@ -178,7 +181,7 @@ SpecialPowersObserverAPI.prototype = {
|
||||
|
||||
// return null if the pref doesn't exist
|
||||
if (prefs.getPrefType(prefName) == prefs.PREF_INVALID)
|
||||
return;
|
||||
return null;
|
||||
} else if (aMessage.json.op == "set") {
|
||||
if (!prefName || !prefType || prefValue === null)
|
||||
throw new SpecialPowersException("Invalid parameters for set in SPPrefService");
|
||||
@ -214,10 +217,10 @@ SpecialPowersObserverAPI.prototype = {
|
||||
case "":
|
||||
if (aMessage.json.op == "clear") {
|
||||
prefs.clearUserPref(prefName);
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
break;
|
||||
return undefined; // See comment at the beginning of this function.
|
||||
|
||||
case "SPProcessCrashService":
|
||||
switch (aMessage.json.op) {
|
||||
@ -234,7 +237,7 @@ SpecialPowersObserverAPI.prototype = {
|
||||
default:
|
||||
throw new SpecialPowersException("Invalid operation for SPProcessCrashService");
|
||||
}
|
||||
break;
|
||||
return undefined; // See comment at the beginning of this function.
|
||||
|
||||
case "SPPermissionManager":
|
||||
let msg = aMessage.json;
|
||||
@ -266,7 +269,7 @@ SpecialPowersObserverAPI.prototype = {
|
||||
throw new SpecialPowersException("Invalid operation for " +
|
||||
"SPPermissionManager");
|
||||
}
|
||||
break;
|
||||
return undefined; // See comment at the beginning of this function.
|
||||
|
||||
case "SPWebAppService":
|
||||
let Webapps = {};
|
||||
@ -279,7 +282,7 @@ SpecialPowersObserverAPI.prototype = {
|
||||
default:
|
||||
throw new SpecialPowersException("Invalid operation for SPWebAppsService");
|
||||
}
|
||||
break;
|
||||
return undefined; // See comment at the beginning of this function.
|
||||
|
||||
case "SPObserverService":
|
||||
switch (aMessage.json.op) {
|
||||
@ -291,7 +294,7 @@ SpecialPowersObserverAPI.prototype = {
|
||||
default:
|
||||
throw new SpecialPowersException("Invalid operation for SPObserverervice");
|
||||
}
|
||||
break;
|
||||
return undefined; // See comment at the beginning of this function.
|
||||
|
||||
case "SPLoadChromeScript":
|
||||
var url = aMessage.json.url;
|
||||
@ -331,7 +334,7 @@ SpecialPowersObserverAPI.prototype = {
|
||||
throw new SpecialPowersException("Error while executing chrome " +
|
||||
"script '" + url + "':\n" + e);
|
||||
}
|
||||
break;
|
||||
return undefined; // See comment at the beginning of this function.
|
||||
|
||||
case "SPChromeScriptMessage":
|
||||
var id = aMessage.json.id;
|
||||
@ -340,11 +343,16 @@ SpecialPowersObserverAPI.prototype = {
|
||||
this._chromeScriptListeners
|
||||
.filter(o => (o.name == name && o.id == id))
|
||||
.forEach(o => o.listener(message));
|
||||
break;
|
||||
return undefined; // See comment at the beginning of this function.
|
||||
|
||||
default:
|
||||
throw new SpecialPowersException("Unrecognized Special Powers API");
|
||||
}
|
||||
|
||||
// We throw an exception before reaching this explicit return because
|
||||
// we should never be arriving here anyway.
|
||||
throw new SpecialPowersException("Unreached code");
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user