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: '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: const expected_id = 'predefined-id@test'; michael@0: michael@0: exports.testExpectedID = function(assert) { michael@0: assert.equal(id, expected_id, 'ID is as expected'); michael@0: assert.equal(preferencesBranch, expected_id, 'preferences-branch is ' + expected_id); michael@0: michael@0: assert.equal(simple.prefs.test, 5, 'test pref is 5'); michael@0: michael@0: simple.prefs.test2 = '25'; michael@0: assert.equal(service.get('extensions.'+expected_id+'.test2'), '25', 'test pref is 25'); michael@0: assert.equal(service.get('extensions.'+expected_id+'.test2'), simple.prefs.test2, 'test pref is 25'); michael@0: } michael@0: michael@0: exports.testSelfID = function(assert, done) { 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.equal(addon.id, id, 'found addon with self.id'); michael@0: done(); michael@0: }); michael@0: } michael@0: michael@0: require('sdk/test/runner').runTestsFromModule(module);