addon-sdk/source/test/test-test-utils.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.

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 const { setTimeout } = require('sdk/timers');
michael@0 8 const { waitUntil } = require('sdk/test/utils');
michael@0 9
michael@0 10 exports.testWaitUntil = function (assert, done) {
michael@0 11 let bool = false;
michael@0 12 let finished = false;
michael@0 13 waitUntil(() => {
michael@0 14 if (finished)
michael@0 15 assert.fail('interval should be cleared after predicate is truthy');
michael@0 16 return bool;
michael@0 17 }).then(function () {
michael@0 18 assert.ok(bool,
michael@0 19 'waitUntil shouldn\'t call until predicate is truthy');
michael@0 20 finished = true;
michael@0 21 done();
michael@0 22 });
michael@0 23 setTimeout(() => { bool = true; }, 20);
michael@0 24 };
michael@0 25
michael@0 26 exports.testWaitUntilInterval = function (assert, done) {
michael@0 27 let bool = false;
michael@0 28 let finished = false;
michael@0 29 let counter = 0;
michael@0 30 waitUntil(() => {
michael@0 31 if (finished)
michael@0 32 assert.fail('interval should be cleared after predicate is truthy');
michael@0 33 counter++;
michael@0 34 return bool;
michael@0 35 }, 50).then(function () {
michael@0 36 assert.ok(bool,
michael@0 37 'waitUntil shouldn\'t call until predicate is truthy');
michael@0 38 assert.equal(counter, 1,
michael@0 39 'predicate should only be called once with a higher interval');
michael@0 40 finished = true;
michael@0 41 done();
michael@0 42 });
michael@0 43 setTimeout(() => { bool = true; }, 10);
michael@0 44 };
michael@0 45
michael@0 46 require('sdk/test').run(exports);

mercurial