addon-sdk/source/test/addons/standard-id/lib/main.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial