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 SimpleTest.waitForExplicitFinish();
3 var fileTestOnCurrentOrigin = (location.protocol + '//' + location.host + location.pathname)
4 .replace('test_', 'file_')
5 .replace('_inproc', '').replace('_oop', '');
7 var previousPrefs = {
8 mozBrowserFramesEnabled: undefined,
9 oop_by_default: undefined,
10 };
12 try {
13 previousPrefs.mozBrowserFramesEnabled = SpecialPowers.getBoolPref('dom.mozBrowserFramesEnabled');
14 } catch(e)
15 {
16 }
18 try {
19 previousPrefs.oop_by_default = SpecialPowers.getBoolPref('dom.ipc.browser_frames.oop_by_default');
20 } catch(e) {
21 }
23 SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', true);
24 SpecialPowers.setBoolPref("dom.ipc.browser_frames.oop_by_default", location.pathname.indexOf('_inproc') == -1);
26 SpecialPowers.addPermission("browser", true, window.document);
28 var gData = [
29 // APP 1
30 {
31 app: 'http://example.org/manifest.webapp',
32 action: 'read-no',
33 src: fileTestOnCurrentOrigin,
34 },
35 {
36 app: 'http://example.org/manifest.webapp',
37 action: 'write',
38 src: fileTestOnCurrentOrigin,
39 },
40 {
41 app: 'http://example.org/manifest.webapp',
42 action: 'read-yes',
43 src: fileTestOnCurrentOrigin,
44 },
45 // APP 2
46 {
47 app: 'https://example.com/manifest.webapp',
48 action: 'read-no',
49 src: fileTestOnCurrentOrigin,
50 },
51 {
52 app: 'https://example.com/manifest.webapp',
53 action: 'write',
54 src: fileTestOnCurrentOrigin,
55 },
56 {
57 app: 'https://example.com/manifest.webapp',
58 action: 'read-yes',
59 src: fileTestOnCurrentOrigin,
60 },
61 // Browser
62 {
63 browser: true,
64 action: 'read-no',
65 src: fileTestOnCurrentOrigin,
66 },
67 {
68 browser: true,
69 action: 'write',
70 src: fileTestOnCurrentOrigin,
71 },
72 {
73 browser: true,
74 action: 'read-yes',
75 src: fileTestOnCurrentOrigin,
76 },
77 ];
79 function runTest() {
80 for (var i in gData) {
81 var iframe = document.createElement('iframe');
82 var data = gData[i];
84 if (data.app) {
85 iframe.setAttribute('mozbrowser', '');
86 iframe.setAttribute('mozapp', data.app);
87 } else if (data.browser) {
88 iframe.setAttribute('mozbrowser', '');
89 }
91 if (data.app || data.browser) {
92 iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
93 is(e.detail.message, 'success', 'test number ' + i);
95 // document.getElementById('content').removeChild(iframe);
97 i++;
98 if (i >= gData.length) {
99 if (previousPrefs.mozBrowserFramesEnabled !== undefined) {
100 SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', previousPrefs.mozBrowserFramesEnabled);
101 }
102 if (previousPrefs.oop_by_default !== undefined) {
103 SpecialPowers.setBoolPref("dom.ipc.browser_frames.oop_by_default", previousPrefs.oop_by_default);
104 }
106 SpecialPowers.removePermission("browser", window.document);
108 indexedDB.deleteDatabase('AppIsolationTest').onsuccess = function() {
109 SimpleTest.finish();
110 };
111 } else {
112 gTestRunner.next();
113 }
114 });
115 }
117 iframe.src = data.src + '?' + data.action;
119 document.getElementById('content').appendChild(iframe);
121 yield undefined;
122 }
123 }
125 var gTestRunner = runTest();
127 function startTest() {
128 var request = window.indexedDB.open('AppIsolationTest');
129 var created = false;
131 request.onupgradeneeded = function(event) {
132 created = true;
133 var db = event.target.result;
134 var data = [
135 { id: "0", name: "foo" },
136 ];
137 var objectStore = db.createObjectStore("test", { keyPath: "id" });
138 for (var i in data) {
139 objectStore.add(data[i]);
140 }
141 }
143 request.onsuccess = function(event) {
144 var db = event.target.result;
145 is(created, true, "we should have created the db");
147 db.transaction("test").objectStore("test").get("0").onsuccess = function(event) {
148 is(event.target.result.name, 'foo', 'data have been written');
149 db.close();
151 gTestRunner.next();
152 };
153 }
154 }
156 // test_ipc.html executes all the tests in this directory in content process.
157 // It will fail on this one for the moment.
158 if (!SpecialPowers.isMainProcess()) {
159 todo(false, "We should make this work on content process");
160 SimpleTest.finish();
161 } else {
162 // TODO: remove unsetting network.disable.ipc.security as part of bug 820712
163 SpecialPowers.pushPrefEnv({
164 "set": [
165 ["network.disable.ipc.security", true],
166 ]
167 }, startTest);
168 }