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 | /** |
michael@0 | 8 | * Ensures using child_process and underlying subprocess.jsm |
michael@0 | 9 | * works within an addon |
michael@0 | 10 | */ |
michael@0 | 11 | |
michael@0 | 12 | const { exec } = require("sdk/system/child_process"); |
michael@0 | 13 | const { platform, pathFor } = require("sdk/system"); |
michael@0 | 14 | const PROFILE_DIR = pathFor("ProfD"); |
michael@0 | 15 | const isWindows = platform.toLowerCase().indexOf("win") === 0; |
michael@0 | 16 | const app = require("sdk/system/xul-app"); |
michael@0 | 17 | |
michael@0 | 18 | // Once Bug 903018 is resolved, just move the application testing to |
michael@0 | 19 | // module.metadata.engines |
michael@0 | 20 | if (app.is("Firefox")) { |
michael@0 | 21 | exports["test child_process in an addon"] = (assert, done) => { |
michael@0 | 22 | exec(isWindows ? "DIR /A-D" : "ls -al", { |
michael@0 | 23 | cwd: PROFILE_DIR |
michael@0 | 24 | }, (err, stdout, stderr) => { |
michael@0 | 25 | assert.ok(!err, "no errors"); |
michael@0 | 26 | assert.equal(stderr, "", "stderr is empty"); |
michael@0 | 27 | assert.ok(/extensions\.ini/.test(stdout), "stdout output of `ls -al` finds files"); |
michael@0 | 28 | |
michael@0 | 29 | if (isWindows) |
michael@0 | 30 | assert.ok(!/<DIR>/.test(stdout), "passing args works"); |
michael@0 | 31 | else |
michael@0 | 32 | assert.ok(/d(r[-|w][-|x]){3}/.test(stdout), "passing args works"); |
michael@0 | 33 | done(); |
michael@0 | 34 | }); |
michael@0 | 35 | }; |
michael@0 | 36 | } else { |
michael@0 | 37 | exports["test unsupported"] = (assert) => assert.pass("This application is unsupported."); |
michael@0 | 38 | } |
michael@0 | 39 | require("sdk/test/runner").runTestsFromModule(module); |