|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 'use strict'; |
|
6 |
|
7 const { id, preferencesBranch } = require('sdk/self'); |
|
8 const simple = require('sdk/simple-prefs'); |
|
9 const service = require('sdk/preferences/service'); |
|
10 const { AddonManager } = require('chrome').Cu.import('resource://gre/modules/AddonManager.jsm'); |
|
11 |
|
12 exports.testStandardID = function(assert) { |
|
13 assert.equal(id, 'standard-id@jetpack', 'standard ID is standard'); |
|
14 |
|
15 assert.equal(simple.prefs.test13, 26, 'test13 is 26'); |
|
16 |
|
17 simple.prefs.test14 = '15'; |
|
18 assert.equal(service.get('extensions.standard-id@jetpack.test14'), '15', 'test14 is 15'); |
|
19 |
|
20 assert.equal(service.get('extensions.standard-id@jetpack.test14'), simple.prefs.test14, 'simple test14 also 15'); |
|
21 |
|
22 } |
|
23 |
|
24 exports.testInvalidPreferencesBranch = function(assert) { |
|
25 assert.notEqual(preferencesBranch, 'invalid^branch*name', 'invalid preferences-branch value ignored'); |
|
26 |
|
27 assert.equal(preferencesBranch, 'standard-id@jetpack', 'preferences-branch is standard-id@jetpack'); |
|
28 |
|
29 } |
|
30 |
|
31 // from `/test/test-self.js`, adapted to `sdk/test/assert` API |
|
32 exports.testSelfID = function(assert, done) { |
|
33 |
|
34 assert.equal(typeof(id), 'string', 'self.id is a string'); |
|
35 assert.ok(id.length > 0, 'self.id not empty'); |
|
36 |
|
37 AddonManager.getAddonByID(id, function(addon) { |
|
38 assert.ok(addon, 'found addon with self.id'); |
|
39 done(); |
|
40 }); |
|
41 |
|
42 } |
|
43 |
|
44 require('sdk/test/runner').runTestsFromModule(module); |