1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/addon-sdk/source/test/addons/preferences-branch/lib/main.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,35 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +'use strict'; 1.9 + 1.10 +const { id, preferencesBranch } = require('sdk/self'); 1.11 +const simple = require('sdk/simple-prefs'); 1.12 +const service = require('sdk/preferences/service'); 1.13 +const { AddonManager } = require('chrome').Cu.import('resource://gre/modules/AddonManager.jsm'); 1.14 + 1.15 +exports.testPreferencesBranch = function(assert) { 1.16 + assert.equal(preferencesBranch, 'human-readable', 'preferencesBranch is human-readable'); 1.17 + 1.18 + assert.equal(simple.prefs.test42, true, 'test42 is true'); 1.19 + 1.20 + simple.prefs.test43 = 'movie'; 1.21 + assert.equal(service.get('extensions.human-readable.test43'), 'movie', 'test43 is a movie'); 1.22 + 1.23 +} 1.24 + 1.25 +// from `/test/test-self.js`, adapted to `sdk/test/assert` API 1.26 +exports.testSelfID = function(assert, done) { 1.27 + 1.28 + assert.equal(typeof(id), 'string', 'self.id is a string'); 1.29 + assert.ok(id.length > 0, 'self.id not empty'); 1.30 + 1.31 + AddonManager.getAddonByID(id, function(addon) { 1.32 + assert.ok(addon, 'found addon with self.id'); 1.33 + done(); 1.34 + }); 1.35 + 1.36 +} 1.37 + 1.38 +require('sdk/test/runner').runTestsFromModule(module);