michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: 'use strict'; michael@0: michael@0: const { id, preferencesBranch } = require('sdk/self'); michael@0: const simple = require('sdk/simple-prefs'); michael@0: const service = require('sdk/preferences/service'); michael@0: const { AddonManager } = require('chrome').Cu.import('resource://gre/modules/AddonManager.jsm'); michael@0: michael@0: exports.testPreferencesBranch = function(assert) { michael@0: assert.equal(preferencesBranch, 'human-readable', 'preferencesBranch is human-readable'); michael@0: michael@0: assert.equal(simple.prefs.test42, true, 'test42 is true'); michael@0: michael@0: simple.prefs.test43 = 'movie'; michael@0: assert.equal(service.get('extensions.human-readable.test43'), 'movie', 'test43 is a movie'); michael@0: michael@0: } michael@0: michael@0: // from `/test/test-self.js`, adapted to `sdk/test/assert` API michael@0: exports.testSelfID = function(assert, done) { michael@0: michael@0: assert.equal(typeof(id), 'string', 'self.id is a string'); michael@0: assert.ok(id.length > 0, 'self.id not empty'); michael@0: michael@0: AddonManager.getAddonByID(id, function(addon) { michael@0: assert.ok(addon, 'found addon with self.id'); michael@0: done(); michael@0: }); michael@0: michael@0: } michael@0: michael@0: require('sdk/test/runner').runTestsFromModule(module);