|
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 'use strict'; |
|
5 |
|
6 const simple = require('sdk/simple-prefs'); |
|
7 const service = require('sdk/preferences/service'); |
|
8 const { id, preferencesBranch } = require('sdk/self'); |
|
9 const { AddonManager } = require('chrome').Cu.import('resource://gre/modules/AddonManager.jsm'); |
|
10 |
|
11 exports.testCurlyID = function(assert) { |
|
12 assert.equal(id, '{34a1eae1-c20a-464f-9b0e-000000000000}', 'curly ID is curly'); |
|
13 |
|
14 assert.equal(simple.prefs.test13, 26, 'test13 is 26'); |
|
15 |
|
16 simple.prefs.test14 = '15'; |
|
17 assert.equal(service.get('extensions.{34a1eae1-c20a-464f-9b0e-000000000000}.test14'), '15', 'test14 is 15'); |
|
18 |
|
19 assert.equal(service.get('extensions.{34a1eae1-c20a-464f-9b0e-000000000000}.test14'), simple.prefs.test14, 'simple test14 also 15'); |
|
20 |
|
21 } |
|
22 |
|
23 exports.testInvalidPreferencesBranch = function(assert) { |
|
24 assert.notEqual(preferencesBranch, 'invalid^branch*name', 'invalid preferences-branch value ignored'); |
|
25 |
|
26 assert.equal(preferencesBranch, '{34a1eae1-c20a-464f-9b0e-000000000000}', 'preferences-branch is {34a1eae1-c20a-464f-9b0e-000000000000}'); |
|
27 |
|
28 } |
|
29 |
|
30 // from `/test/test-self.js`, adapted to `sdk/test/assert` API |
|
31 exports.testSelfID = function(assert, done) { |
|
32 |
|
33 assert.equal(typeof(id), 'string', 'self.id is a string'); |
|
34 assert.ok(id.length > 0, 'self.id not empty'); |
|
35 |
|
36 AddonManager.getAddonByID(id, function(addon) { |
|
37 assert.ok(addon, 'found addon with self.id'); |
|
38 done(); |
|
39 }); |
|
40 |
|
41 } |
|
42 |
|
43 require('sdk/test/runner').runTestsFromModule(module); |