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 | |
michael@0 | 5 | 'use strict'; |
michael@0 | 6 | |
michael@0 | 7 | const { env } = require('sdk/system/environment'); |
michael@0 | 8 | const { Cc, Ci } = require('chrome'); |
michael@0 | 9 | const { get, set, exists } = Cc['@mozilla.org/process/environment;1']. |
michael@0 | 10 | getService(Ci.nsIEnvironment); |
michael@0 | 11 | |
michael@0 | 12 | exports['test exists'] = function(assert) { |
michael@0 | 13 | assert.equal('PATH' in env, exists('PATH'), |
michael@0 | 14 | 'PATH environment variable is defined'); |
michael@0 | 15 | assert.equal('FOO1' in env, exists('FOO1'), |
michael@0 | 16 | 'FOO1 environment variable is not defined'); |
michael@0 | 17 | set('FOO1', 'foo'); |
michael@0 | 18 | assert.equal('FOO1' in env, true, |
michael@0 | 19 | 'FOO1 environment variable was set'); |
michael@0 | 20 | set('FOO1', null); |
michael@0 | 21 | assert.equal('FOO1' in env, false, |
michael@0 | 22 | 'FOO1 environment variable was unset'); |
michael@0 | 23 | }; |
michael@0 | 24 | |
michael@0 | 25 | exports['test get'] = function(assert) { |
michael@0 | 26 | assert.equal(env.PATH, get('PATH'), 'PATH env variable matches'); |
michael@0 | 27 | assert.equal(env.BAR2, undefined, 'BAR2 env variable is not defined'); |
michael@0 | 28 | set('BAR2', 'bar'); |
michael@0 | 29 | assert.equal(env.BAR2, 'bar', 'BAR2 env variable was set'); |
michael@0 | 30 | set('BAR2', null); |
michael@0 | 31 | assert.equal(env.BAR2, undefined, 'BAR2 env variable was unset'); |
michael@0 | 32 | }; |
michael@0 | 33 | |
michael@0 | 34 | exports['test set'] = function(assert) { |
michael@0 | 35 | assert.equal(get('BAZ3'), '', 'BAZ3 env variable is not set'); |
michael@0 | 36 | assert.equal(env.BAZ3, undefined, 'BAZ3 is not set'); |
michael@0 | 37 | env.BAZ3 = 'baz'; |
michael@0 | 38 | assert.equal(env.BAZ3, get('BAZ3'), 'BAZ3 env variable is set'); |
michael@0 | 39 | assert.equal(get('BAZ3'), 'baz', 'BAZ3 env variable was set to "baz"'); |
michael@0 | 40 | }; |
michael@0 | 41 | |
michael@0 | 42 | exports['test unset'] = function(assert) { |
michael@0 | 43 | env.BLA4 = 'bla'; |
michael@0 | 44 | assert.equal(env.BLA4, 'bla', 'BLA4 env variable is set'); |
michael@0 | 45 | assert.equal(delete env.BLA4, true, 'BLA4 env variable is removed'); |
michael@0 | 46 | assert.equal(env.BLA4, undefined, 'BLA4 env variable is unset'); |
michael@0 | 47 | assert.equal('BLA4' in env, false, 'BLA4 env variable no longer exists' ); |
michael@0 | 48 | }; |
michael@0 | 49 | |
michael@0 | 50 | require('test').run(exports); |