mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +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
|
* This will get requests from our API in the window and process them in chrome for it
|
||||||
**/
|
**/
|
||||||
_receiveMessageAPI: function(aMessage) {
|
_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) {
|
switch(aMessage.name) {
|
||||||
case "SPPrefService":
|
case "SPPrefService":
|
||||||
var prefs = Services.prefs;
|
var prefs = Services.prefs;
|
||||||
@ -178,7 +181,7 @@ SpecialPowersObserverAPI.prototype = {
|
|||||||
|
|
||||||
// return null if the pref doesn't exist
|
// return null if the pref doesn't exist
|
||||||
if (prefs.getPrefType(prefName) == prefs.PREF_INVALID)
|
if (prefs.getPrefType(prefName) == prefs.PREF_INVALID)
|
||||||
return;
|
return null;
|
||||||
} else if (aMessage.json.op == "set") {
|
} else if (aMessage.json.op == "set") {
|
||||||
if (!prefName || !prefType || prefValue === null)
|
if (!prefName || !prefType || prefValue === null)
|
||||||
throw new SpecialPowersException("Invalid parameters for set in SPPrefService");
|
throw new SpecialPowersException("Invalid parameters for set in SPPrefService");
|
||||||
@ -214,10 +217,10 @@ SpecialPowersObserverAPI.prototype = {
|
|||||||
case "":
|
case "":
|
||||||
if (aMessage.json.op == "clear") {
|
if (aMessage.json.op == "clear") {
|
||||||
prefs.clearUserPref(prefName);
|
prefs.clearUserPref(prefName);
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
return undefined; // See comment at the beginning of this function.
|
||||||
|
|
||||||
case "SPProcessCrashService":
|
case "SPProcessCrashService":
|
||||||
switch (aMessage.json.op) {
|
switch (aMessage.json.op) {
|
||||||
@ -234,7 +237,7 @@ SpecialPowersObserverAPI.prototype = {
|
|||||||
default:
|
default:
|
||||||
throw new SpecialPowersException("Invalid operation for SPProcessCrashService");
|
throw new SpecialPowersException("Invalid operation for SPProcessCrashService");
|
||||||
}
|
}
|
||||||
break;
|
return undefined; // See comment at the beginning of this function.
|
||||||
|
|
||||||
case "SPPermissionManager":
|
case "SPPermissionManager":
|
||||||
let msg = aMessage.json;
|
let msg = aMessage.json;
|
||||||
@ -266,7 +269,7 @@ SpecialPowersObserverAPI.prototype = {
|
|||||||
throw new SpecialPowersException("Invalid operation for " +
|
throw new SpecialPowersException("Invalid operation for " +
|
||||||
"SPPermissionManager");
|
"SPPermissionManager");
|
||||||
}
|
}
|
||||||
break;
|
return undefined; // See comment at the beginning of this function.
|
||||||
|
|
||||||
case "SPWebAppService":
|
case "SPWebAppService":
|
||||||
let Webapps = {};
|
let Webapps = {};
|
||||||
@ -279,7 +282,7 @@ SpecialPowersObserverAPI.prototype = {
|
|||||||
default:
|
default:
|
||||||
throw new SpecialPowersException("Invalid operation for SPWebAppsService");
|
throw new SpecialPowersException("Invalid operation for SPWebAppsService");
|
||||||
}
|
}
|
||||||
break;
|
return undefined; // See comment at the beginning of this function.
|
||||||
|
|
||||||
case "SPObserverService":
|
case "SPObserverService":
|
||||||
switch (aMessage.json.op) {
|
switch (aMessage.json.op) {
|
||||||
@ -291,7 +294,7 @@ SpecialPowersObserverAPI.prototype = {
|
|||||||
default:
|
default:
|
||||||
throw new SpecialPowersException("Invalid operation for SPObserverervice");
|
throw new SpecialPowersException("Invalid operation for SPObserverervice");
|
||||||
}
|
}
|
||||||
break;
|
return undefined; // See comment at the beginning of this function.
|
||||||
|
|
||||||
case "SPLoadChromeScript":
|
case "SPLoadChromeScript":
|
||||||
var url = aMessage.json.url;
|
var url = aMessage.json.url;
|
||||||
@ -331,7 +334,7 @@ SpecialPowersObserverAPI.prototype = {
|
|||||||
throw new SpecialPowersException("Error while executing chrome " +
|
throw new SpecialPowersException("Error while executing chrome " +
|
||||||
"script '" + url + "':\n" + e);
|
"script '" + url + "':\n" + e);
|
||||||
}
|
}
|
||||||
break;
|
return undefined; // See comment at the beginning of this function.
|
||||||
|
|
||||||
case "SPChromeScriptMessage":
|
case "SPChromeScriptMessage":
|
||||||
var id = aMessage.json.id;
|
var id = aMessage.json.id;
|
||||||
@ -340,11 +343,16 @@ SpecialPowersObserverAPI.prototype = {
|
|||||||
this._chromeScriptListeners
|
this._chromeScriptListeners
|
||||||
.filter(o => (o.name == name && o.id == id))
|
.filter(o => (o.name == name && o.id == id))
|
||||||
.forEach(o => o.listener(message));
|
.forEach(o => o.listener(message));
|
||||||
break;
|
return undefined; // See comment at the beginning of this function.
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new SpecialPowersException("Unrecognized Special Powers API");
|
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