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/. */
4 'use strict';
6 const { List, addListItem, removeListItem } = require('sdk/util/list');
7 const { Class } = require('sdk/core/heritage');
9 exports.testList = function(assert) {
10 let list = List();
11 addListItem(list, 1);
13 for (let key in list) {
14 assert.equal(key, 0, 'key is correct');
15 assert.equal(list[key], 1, 'value is correct');
16 }
18 let count = 0;
19 for each (let ele in list) {
20 assert.equal(ele, 1, 'ele is correct');
21 assert.equal(++count, 1, 'count is correct');
22 }
24 count = 0;
25 for (let ele of list) {
26 assert.equal(ele, 1, 'ele is correct');
27 assert.equal(++count, 1, 'count is correct');
28 }
30 removeListItem(list, 1);
31 assert.equal(list.length, 0, 'remove worked');
32 };
34 exports.testImplementsList = function(assert) {
35 let List2 = Class({
36 implements: [List],
37 initialize: function() {
38 List.prototype.initialize.apply(this, [0, 1, 2]);
39 }
40 });
41 let list2 = List2();
42 let count = 0;
44 for each (let ele in list2) {
45 assert.equal(ele, count++, 'ele is correct');
46 }
48 count = 0;
49 for (let ele of list2) {
50 assert.equal(ele, count++, 'ele is correct');
51 }
53 addListItem(list2, 3);
54 assert.equal(list2.length, 4, '3 was added');
55 assert.equal(list2[list2.length-1], 3, '3 was added');
56 }
58 require('sdk/test').run(exports);