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