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 // Opening new windows in Fennec causes issues
7 module.metadata = {
8 engines: {
9 'Firefox': '*'
10 }
11 };
13 const { WindowLoader } = require('sdk/windows/loader'),
14 { Trait } = require('sdk/deprecated/traits');
16 const Loader = Trait.compose(
17 WindowLoader,
18 {
19 constructor: function Loader(options) {
20 this._onLoad = options.onLoad;
21 this._onUnload = options.onUnload;
22 if ('window' in options)
23 this._window = options.window;
24 this._load();
25 this.window = this._window;
26 },
27 window: null,
28 _onLoad: null,
29 _onUnload: null,
30 _tabOptions: []
31 }
32 );
34 exports['test compositions with missing required properties'] = function(assert) {
35 assert.throws(
36 function() WindowLoader.compose({})(),
37 /Missing required property: _onLoad/,
38 'should throw missing required property exception'
39 );
40 assert.throws(
41 function() WindowLoader.compose({ _onLoad: null, _tabOptions: null })(),
42 /Missing required property: _onUnload/,
43 'should throw missing required property `_onUnload`'
44 );
45 assert.throws(
46 function() WindowLoader.compose({ _onUnload: null, _tabOptions: null })(),
47 /Missing required property: _onLoad/,
48 'should throw missing required property `_onLoad`'
49 );
50 assert.throws(
51 function() WindowLoader.compose({ _onUnload: null, _onLoad: null })(),
52 /Missing required property: _tabOptions/,
53 'should throw missing required property `_tabOptions`'
54 );
55 };
57 exports['test `load` events'] = function(assert, done) {
58 let onLoadCalled = false;
59 Loader({
60 onLoad: function(window) {
61 onLoadCalled = true;
62 assert.equal(window, this._window, 'windows should match');
63 assert.equal(
64 window.document.readyState, 'complete', 'window must be fully loaded'
65 );
66 window.close();
67 },
68 onUnload: function(window) {
69 assert.equal(window, this._window, 'windows should match');
70 assert.equal(
71 window.document.readyState, 'complete', 'window must be fully loaded'
72 );
73 assert.ok(onLoadCalled, 'load callback is supposed to be called');
74 done();
75 }
76 });
77 };
79 exports['test removeing listeners'] = function(assert, done) {
80 Loader({
81 onLoad: function(window) {
82 assert.equal(window, this._window, 'windows should match');
83 window.close();
84 },
85 onUnload: done
86 });
87 };
89 exports['test create loader from opened window'] = function(assert, done) {
90 let onUnloadCalled = false;
91 Loader({
92 onLoad: function(window) {
93 assert.equal(window, this._window, 'windows should match');
94 assert.equal(window.document.readyState, 'complete', 'window must be fully loaded');
95 Loader({
96 window: window,
97 onLoad: function(win) {
98 assert.equal(win, window, 'windows should match');
99 window.close();
100 },
101 onUnload: function(window) {
102 assert.ok(onUnloadCalled, 'first handler should be called already');
103 done();
104 }
105 });
106 },
107 onUnload: function(window) {
108 onUnloadCalled = true;
109 }
110 });
111 };
113 require('sdk/test').run(exports);