Sat, 03 Jan 2015 20:18:00 +0100
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/. */
5 'use strict'
7 const { defer: async } = require('sdk/lang/functional');
8 const { before, after } = require('sdk/test/utils');
10 let AFTER_RUN = 0;
11 let BEFORE_RUN = 0;
13 /*
14 * Tests are dependent on ordering, as the before and after functions
15 * are called outside of each test, and sometimes checked in the next test
16 * (like in the `after` tests)
17 */
18 exports.testABeforeAsync = function (assert, done) {
19 assert.equal(BEFORE_RUN, 1, 'before function was called');
20 BEFORE_RUN = 0;
21 AFTER_RUN = 0;
22 async(done)();
23 };
25 exports.testABeforeNameAsync = function (assert, done) {
26 assert.equal(BEFORE_RUN, 2, 'before function was called with name');
27 BEFORE_RUN = 0;
28 AFTER_RUN = 0;
29 async(done)();
30 };
32 exports.testAfterAsync = function (assert, done) {
33 assert.equal(AFTER_RUN, 1, 'after function was called previously');
34 BEFORE_RUN = 0;
35 AFTER_RUN = 0;
36 async(done)();
37 };
39 exports.testAfterNameAsync = function (assert, done) {
40 assert.equal(AFTER_RUN, 2, 'after function was called with name');
41 BEFORE_RUN = 0;
42 AFTER_RUN = 0;
43 async(done)();
44 };
46 exports.testSyncABefore = function (assert) {
47 assert.equal(BEFORE_RUN, 1, 'before function was called for sync test');
48 BEFORE_RUN = 0;
49 AFTER_RUN = 0;
50 };
52 exports.testSyncAfter = function (assert) {
53 assert.equal(AFTER_RUN, 1, 'after function was called for sync test');
54 BEFORE_RUN = 0;
55 AFTER_RUN = 0;
56 };
58 before(exports, (name, assert, done) => {
59 if (name === 'testABeforeNameAsync')
60 BEFORE_RUN = 2;
61 else
62 BEFORE_RUN = 1;
63 assert.pass('assert passed into before function');
64 async(done)();
65 });
67 after(exports, (name, assert, done) => {
68 // testAfterName runs after testAfter, which is where this
69 // check occurs in the assertation
70 if (name === 'testAfterAsync')
71 AFTER_RUN = 2;
72 else
73 AFTER_RUN = 1;
74 assert.pass('assert passed into after function');
75 async(done)();
76 });
78 require('sdk/test').run(exports);