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

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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