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 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 var gTestGlobals = [];
5 DebuggerServer.addTestGlobal = function(aGlobal) {
6 gTestGlobals.push(aGlobal);
7 };
9 // A mock tab list, for use by tests. This simply presents each global in
10 // gTestGlobals as a tab, and the list is fixed: it never calls its
11 // onListChanged handler.
12 //
13 // As implemented now, we consult gTestGlobals when we're constructed, not
14 // when we're iterated over, so tests have to add their globals before the
15 // root actor is created.
16 function TestTabList(aConnection) {
17 this.conn = aConnection;
19 // An array of actors for each global added with
20 // DebuggerServer.addTestGlobal.
21 this._tabActors = [];
23 // A pool mapping those actors' names to the actors.
24 this._tabActorPool = new ActorPool(aConnection);
26 for (let global of gTestGlobals) {
27 let actor = new TestTabActor(aConnection, global);
28 actor.selected = false;
29 this._tabActors.push(actor);
30 this._tabActorPool.addActor(actor);
31 }
32 if (this._tabActors.length > 0) {
33 this._tabActors[0].selected = true;
34 }
36 aConnection.addActorPool(this._tabActorPool);
37 }
39 TestTabList.prototype = {
40 constructor: TestTabList,
41 getList: function () {
42 return promise.resolve([tabActor for (tabActor of this._tabActors)]);
43 }
44 };
46 function createRootActor(aConnection)
47 {
48 let root = new RootActor(aConnection,
49 { tabList: new TestTabList(aConnection) });
50 root.applicationType = "xpcshell-tests";
51 return root;
52 }
54 function TestTabActor(aConnection, aGlobal)
55 {
56 this.conn = aConnection;
57 this._global = aGlobal;
58 this._global.wrappedJSObject = aGlobal;
59 this._threadActor = new ThreadActor(this, this._global);
60 this.conn.addActor(this._threadActor);
61 this._attached = false;
62 this._extraActors = {};
63 }
65 TestTabActor.prototype = {
66 constructor: TestTabActor,
67 actorPrefix: "TestTabActor",
69 get window() {
70 return { wrappedJSObject: this._global };
71 },
73 get url() {
74 return this._global.__name;
75 },
77 form: function() {
78 let response = { actor: this.actorID, title: this._global.__name };
80 // Walk over tab actors added by extensions and add them to a new ActorPool.
81 let actorPool = new ActorPool(this.conn);
82 this._createExtraActors(DebuggerServer.tabActorFactories, actorPool);
83 if (!actorPool.isEmpty()) {
84 this._tabActorPool = actorPool;
85 this.conn.addActorPool(this._tabActorPool);
86 }
88 this._appendExtraActors(response);
90 return response;
91 },
93 onAttach: function(aRequest) {
94 this._attached = true;
96 let response = { type: "tabAttached", threadActor: this._threadActor.actorID };
97 this._appendExtraActors(response);
99 return response;
100 },
102 onDetach: function(aRequest) {
103 if (!this._attached) {
104 return { "error":"wrongState" };
105 }
106 return { type: "detached" };
107 },
109 /* Support for DebuggerServer.addTabActor. */
110 _createExtraActors: createExtraActors,
111 _appendExtraActors: appendExtraActors
112 };
114 TestTabActor.prototype.requestTypes = {
115 "attach": TestTabActor.prototype.onAttach,
116 "detach": TestTabActor.prototype.onDetach
117 };