addon-sdk/source/test/test-node-os.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/. */
     4 "use strict";
     6 let os = require("node/os");
     7 let system = require("sdk/system");
     9 exports["test os"] = function (assert) {
    10   assert.equal(os.tmpdir(), system.pathFor("TmpD"), "os.tmpdir() matches temp dir");
    11   assert.ok(os.endianness() === "BE" || os.endianness() === "LE", "os.endianness is BE or LE");
    13   assert.ok(os.arch().length > 0, "os.arch() returns a value");
    14   assert.equal(typeof os.arch(), "string", "os.arch() returns a string");
    15   assert.ok(os.type().length > 0, "os.type() returns a value");
    16   assert.equal(typeof os.type(), "string", "os.type() returns a string");
    17   assert.ok(os.platform().length > 0, "os.platform() returns a value");
    18   assert.equal(typeof os.platform(), "string", "os.platform() returns a string");
    20   assert.ok(os.release().length > 0, "os.release() returns a value");
    21   assert.equal(typeof os.release(), "string", "os.release() returns a string");
    22   assert.ok(os.hostname().length > 0, "os.hostname() returns a value");
    23   assert.equal(typeof os.hostname(), "string", "os.hostname() returns a string");
    24   assert.ok(os.EOL === "\n" || os.EOL === "\r\n", "os.EOL returns a correct EOL char");
    26   assert.deepEqual(os.loadavg(), [0, 0, 0], "os.loadavg() returns an array of 0s");
    28   ["uptime", "totalmem", "freemem", "cpus"].forEach(method => {
    29     assert.throws(() => os[method](), "os." + method + " throws");
    30   });
    31 };
    33 require("test").run(exports);

mercurial