mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-24 01:17:34 +09:00
Issue #2653 - Part 2: Update tests
This commit is contained in:
parent
7b6e3a2d4a
commit
0e6fa95840
13 changed files with 2 additions and 531 deletions
|
|
@ -1,88 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
foobar!
|
||||
</body>
|
||||
<script>
|
||||
var data = [
|
||||
{ id: "0", name: "foo" },
|
||||
];
|
||||
|
||||
var action = window.location.search.substring(1);
|
||||
var finished = false;
|
||||
var created = false; // We use that for 'read-no' action.
|
||||
|
||||
function finish(value) {
|
||||
value ? alert('success') : alert('failure');
|
||||
finished = true;
|
||||
}
|
||||
|
||||
var request = window.indexedDB.open('AppIsolationTest');
|
||||
|
||||
request.onupgradeneeded = function(event) {
|
||||
if (finished) {
|
||||
finish(false);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case 'read-no':
|
||||
created = true;
|
||||
break;
|
||||
case 'read-yes':
|
||||
finish(false);
|
||||
break;
|
||||
case 'write':
|
||||
created = true;
|
||||
|
||||
var db = event.target.result;
|
||||
|
||||
var objectStore = db.createObjectStore("test", { keyPath: "id" });
|
||||
for (var i in data) {
|
||||
objectStore.add(data[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
request.onsuccess = function(event) {
|
||||
if (finished) {
|
||||
finish(false);
|
||||
return;
|
||||
}
|
||||
|
||||
var db = event.target.result;
|
||||
|
||||
// Think about close the db!
|
||||
switch (action) {
|
||||
case 'read-no':
|
||||
db.close();
|
||||
|
||||
if (created) { // That means we have created it.
|
||||
indexedDB.deleteDatabase('AppIsolationTest').onsuccess = function() {
|
||||
finish(true);
|
||||
};
|
||||
} else {
|
||||
finish(false);
|
||||
}
|
||||
break;
|
||||
case 'read-yes':
|
||||
db.transaction("test").objectStore("test").get("0").onsuccess = function(event) {
|
||||
var name = event.target.result.name;
|
||||
db.close();
|
||||
|
||||
indexedDB.deleteDatabase('AppIsolationTest').onsuccess = function() {
|
||||
finish(name == 'foo');
|
||||
};
|
||||
};
|
||||
break;
|
||||
case 'write':
|
||||
db.close();
|
||||
|
||||
// Success only if the db was actually created.
|
||||
finish(created);
|
||||
break;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</html>
|
||||
|
|
@ -1,161 +0,0 @@
|
|||
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);
|
||||
|
|
@ -11,8 +11,6 @@ support-files =
|
|||
event_propagation_iframe.html
|
||||
exceptions_in_events_iframe.html
|
||||
file.js
|
||||
file_app_isolation.html
|
||||
file_app_isolation.js
|
||||
helpers.js
|
||||
leaving_page_iframe.html
|
||||
service_worker.js
|
||||
|
|
@ -125,12 +123,6 @@ support-files =
|
|||
[test_add_put.html]
|
||||
[test_add_twice_failure.html]
|
||||
[test_advance.html]
|
||||
[test_app_isolation_inproc.html]
|
||||
# The app isolation tests are only supposed to run in the main process.
|
||||
skip-if = e10s
|
||||
[test_app_isolation_oop.html]
|
||||
# The app isolation tests are only supposed to run in the main process.
|
||||
skip-if = e10s
|
||||
[test_autoIncrement.html]
|
||||
[test_autoIncrement_indexes.html]
|
||||
[test_bfcache.html]
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=756645
|
||||
-->
|
||||
<head>
|
||||
<title>Test for IndexedDB app isolation (unique process)</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=756645">Mozilla Bug 756645</a>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript;version=1.7" src="file_app_isolation.js">
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=756645
|
||||
-->
|
||||
<head>
|
||||
<title>Test for IndexedDB app isolation (unique process)</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=756645">Mozilla Bug 756645</a>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript;version=1.7" src="file_app_isolation.js">
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue