mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1026782 Implements MozLoopService.setLoopCharPref. r=ttaubert
This commit is contained in:
parent
1e0b491583
commit
468ae04ba0
@ -132,6 +132,24 @@ function injectLoopAPI(targetWindow) {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Set any character preference under "loop."
|
||||
*
|
||||
* @param {String} prefName The name of the pref without the preceding "loop."
|
||||
* @param {String} stringValue The value to set.
|
||||
*
|
||||
* Any errors thrown by the Mozilla pref API are logged to the console
|
||||
* and cause false to be returned.
|
||||
*/
|
||||
setLoopCharPref: {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: function(prefName, value) {
|
||||
MozLoopService.setLoopCharPref(prefName, value);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Return any preference under "loop." that's coercible to a character
|
||||
* preference.
|
||||
|
@ -443,6 +443,23 @@ this.MozLoopService = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Set any character preference under "loop.".
|
||||
*
|
||||
* @param {String} prefName The name of the pref without the preceding "loop."
|
||||
* @param {String} value The value to set.
|
||||
*
|
||||
* Any errors thrown by the Mozilla pref API are logged to the console.
|
||||
*/
|
||||
setLoopCharPref: function(prefName, value) {
|
||||
try {
|
||||
Services.prefs.setCharPref("loop." + prefName, value);
|
||||
} catch (ex) {
|
||||
console.log("setLoopCharPref had trouble setting " + prefName +
|
||||
"; exception: " + ex);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Return any preference under "loop." that's coercible to a character
|
||||
* preference.
|
||||
|
@ -0,0 +1,49 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
/*global XPCOMUtils, Services, Assert */
|
||||
|
||||
var fakePrefName = "color";
|
||||
var fakePrefValue = "green";
|
||||
|
||||
function test_setLoopCharPref()
|
||||
{
|
||||
Services.prefs.setCharPref("loop." + fakePrefName, "red");
|
||||
MozLoopService.setLoopCharPref(fakePrefName, fakePrefValue);
|
||||
|
||||
var returnedPref = Services.prefs.getCharPref("loop." + fakePrefName);
|
||||
|
||||
Assert.equal(returnedPref, fakePrefValue,
|
||||
"Should set a char pref under the loop. branch");
|
||||
Services.prefs.clearUserPref("loop." + fakePrefName);
|
||||
}
|
||||
|
||||
function test_setLoopCharPref_new()
|
||||
{
|
||||
Services.prefs.clearUserPref("loop." + fakePrefName);
|
||||
MozLoopService.setLoopCharPref(fakePrefName, fakePrefValue);
|
||||
|
||||
var returnedPref = Services.prefs.getCharPref("loop." + fakePrefName);
|
||||
|
||||
Assert.equal(returnedPref, fakePrefValue,
|
||||
"Should set a new char pref under the loop. branch");
|
||||
Services.prefs.clearUserPref("loop." + fakePrefName);
|
||||
}
|
||||
|
||||
function test_setLoopCharPref_non_coercible_type()
|
||||
{
|
||||
MozLoopService.setLoopCharPref(fakePrefName, true);
|
||||
|
||||
ok(true, "Setting non-coercible type should not fail");
|
||||
}
|
||||
|
||||
|
||||
function run_test()
|
||||
{
|
||||
test_setLoopCharPref();
|
||||
test_setLoopCharPref_new();
|
||||
test_setLoopCharPref_non_coercible_type();
|
||||
|
||||
do_register_cleanup(function() {
|
||||
Services.prefs.clearUserPref("loop." + fakePrefName);
|
||||
});
|
||||
}
|
@ -7,6 +7,7 @@ firefox-appdir = browser
|
||||
[test_loopservice_dnd.js]
|
||||
[test_loopservice_expiry.js]
|
||||
[test_loopservice_get_loop_char_pref.js]
|
||||
[test_loopservice_set_loop_char_pref.js]
|
||||
[test_loopservice_initialize.js]
|
||||
[test_loopservice_locales.js]
|
||||
[test_loopservice_registration.js]
|
||||
|
Loading…
Reference in New Issue
Block a user