Bug 909684 - Add enabled and password checking. r=hsinyi

This commit is contained in:
Szu-Yu Chen [:aknow] 2013-09-03 08:50:55 -04:00
parent 9ce2d5c452
commit b16be28c24
2 changed files with 17 additions and 6 deletions

View File

@ -52,7 +52,8 @@ function testSetCallBarringOptionError(option) {
'should not fire onsuccess for invaild call barring option: '
+ JSON.stringify(option));
};
request.onerror = function() {
request.onerror = function(event) {
is(event.target.error.name, 'InvalidCallBarringOption', JSON.stringify(option));
nextTest();
};
}

View File

@ -1086,7 +1086,7 @@ RILContentHelper.prototype = {
let requestId = this.getRequestId(request);
if (DEBUG) debug("setCallBarringOption: " + JSON.stringify(option));
if (!this._isValidCallBarringOption(option)) {
if (!this._isValidCallBarringOption(option, true)) {
this.dispatchFireRequestError(requestId, "InvalidCallBarringOption");
return request;
}
@ -2072,10 +2072,20 @@ RILContentHelper.prototype = {
/**
* Helper for guarding us against invalid option for call barring.
*/
_isValidCallBarringOption: function _isValidCallBarringOption(option) {
return (option
&& option.serviceClass != null
&& this._isValidCallBarringProgram(option.program));
_isValidCallBarringOption:
function _isValidCallBarringOption(option, usedForSetting) {
if (!option ||
option.serviceClass == null ||
!this._isValidCallBarringProgram(option.program)) {
return false;
}
// For setting callbarring option, |enabled| and |password| are required.
if (usedForSetting && (option.enabled == null || option.password == null)) {
return false;
}
return true;
}
};