addon-sdk/source/test/test-node-os.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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