addon-sdk/source/test/addons/child_process/index.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial