VulpesOS/gaia/tests/jsmarionette/plugins/marionette-settings-api/index.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

56 lines
1 KiB
JavaScript
Executable file

'use strict';
var fs = require('fs');
/**
* @constructor
* @param {Marionette.Client} client Marionette client to use.
*/
function SettingsApi(client) {
this._client = client;
}
/**
* Get a setting
*
* @param {String} name of the setting.
* @return {String} value of the setting.
*/
SettingsApi.prototype.get = function(name) {
var script = fs.readFileSync(
__dirname + '/lib/scripts/getsetting.js',
'utf8'
);
var result = this._client.executeAsyncScript(script, [name]);
if (result.error) {
throw new Error(result.error);
}
return result.value;
};
/**
* Set a setting
*
* @param {String} name of the setting.
* @param {String} value of the setting.
*/
SettingsApi.prototype.set = function(name, value) {
var script = fs.readFileSync(
__dirname + '/lib/scripts/setsetting.js',
'utf8'
);
var result = this._client.executeAsyncScript(script, [name, value]);
if (result.error) {
throw new Error(result.error);
}
};
module.exports = function(client) {
return new SettingsApi(client);
};