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