Bug 757599 - Settings API: add test for closed lock. r=sicking

This commit is contained in:
Gregor Wagner 2012-05-22 18:18:56 -07:00
Родитель 9038c5e7f0
Коммит 790e9f62b6
2 изменённых файлов: 25 добавлений и 3 удалений

Просмотреть файл

@ -117,8 +117,10 @@ SettingsLock.prototype = {
},
get: function get(aName) {
if (!this._open)
if (!this._open) {
dump("Settings lock not open!\n");
throw Components.results.NS_ERROR_ABORT;
}
if (this._settingsManager.hasReadPrivileges || this._settingsManager.hasReadWritePrivileges) {
let req = Services.DOMRequest.createRequest(this._settingsManager._window);
@ -132,8 +134,10 @@ SettingsLock.prototype = {
},
set: function set(aSettings) {
if (!this._open)
if (!this._open) {
dump("Settings lock not open!\n");
throw Components.results.NS_ERROR_ABORT;
}
if (this._settingsManager.hasReadWritePrivileges) {
let req = Services.DOMRequest.createRequest(this._settingsManager._window);
@ -148,8 +152,10 @@ SettingsLock.prototype = {
},
clear: function clear() {
if (!this._open)
if (!this._open) {
dump("Settings lock not open!\n");
throw Components.results.NS_ERROR_ABORT;
}
if (this._settingsManager.hasReadWritePrivileges) {
let req = Services.DOMRequest.createRequest(this._settingsManager._window);

Просмотреть файл

@ -476,6 +476,22 @@ var steps = [
};
req.onerror = onFailure;
},
function () {
ok(true, "Test set after lock closed");
var lockx = mozSettings.getLock();
var cb = function() {
var reqx = null;
try {
reqx = lockx.set(wifiNetworks0);
ok(false, "should have thrown");
} catch (ex) {
ok(reqx == null, "request is still null");
ok(true, "Caught Exception");
next();
}
}
SimpleTest.executeSoon(cb);
},
function() {
ok(true, "Clear DB");
var lock = mozSettings.getLock();