mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
149 lines
4.4 KiB
HTML
149 lines
4.4 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Test for DataStore - bug 986056</title>
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
</head>
|
|
<body>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
<pre id="test">
|
|
<script type="application/javascript;version=1.7">
|
|
|
|
var gHostedManifestURL = 'http://test/tests/dom/datastore/tests/file_app.sjs?testToken=file_bug986056.html&template=file_bug986056.template.webapp';
|
|
var gHostedManifestURL2 = 'http://example.com/tests/dom/datastore/tests/file_app.sjs?testToken=file_bug986056.html&template=file_bug986056.template.webapp';
|
|
var gApps = [];
|
|
|
|
function cbError() {
|
|
ok(false, "Error callback invoked");
|
|
finish();
|
|
}
|
|
|
|
function installApp(aApp) {
|
|
var request = navigator.mozApps.install(aApp);
|
|
request.onerror = cbError;
|
|
request.onsuccess = function() {
|
|
gApps.push(request.result);
|
|
runTest();
|
|
}
|
|
}
|
|
|
|
function uninstallApp(aApp) {
|
|
var request = navigator.mozApps.mgmt.uninstall(aApp);
|
|
request.onerror = cbError;
|
|
request.onsuccess = runTest;
|
|
}
|
|
|
|
function testApp(aCount) {
|
|
var ifr = document.createElement('iframe');
|
|
ifr.setAttribute('mozbrowser', 'true');
|
|
ifr.setAttribute('mozapp', gApps[0].manifestURL);
|
|
ifr.setAttribute('src', gApps[0].manifest.launch_path);
|
|
var domParent = document.getElementById('content');
|
|
|
|
// Set us up to listen for messages from the app.
|
|
var listener = function(e) {
|
|
var message = e.detail.message;
|
|
if (/KO/.exec(message)) {
|
|
ok(false, "Message from app: " + message);
|
|
} else if (/^OK/.exec(message)) {
|
|
is(message, "OK " + aCount, "Number of dataStore matches");
|
|
ifr.removeEventListener('mozbrowsershowmodalprompt', listener);
|
|
domParent.removeChild(ifr);
|
|
runTest();
|
|
}
|
|
}
|
|
|
|
// This event is triggered when the app calls "alert".
|
|
ifr.addEventListener('mozbrowsershowmodalprompt', listener, false);
|
|
domParent.appendChild(ifr);
|
|
}
|
|
|
|
var tests = [
|
|
// Permissions
|
|
function() {
|
|
SpecialPowers.pushPermissions(
|
|
[{ "type": "browser", "allow": 1, "context": document },
|
|
{ "type": "embed-apps", "allow": 1, "context": document },
|
|
{ "type": "webapps-manage", "allow": 1, "context": document }], runTest);
|
|
},
|
|
|
|
// Preferences
|
|
function() {
|
|
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
|
|
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
|
|
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
|
|
["dom.testing.ignore_ipc_principal", true],
|
|
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
|
|
},
|
|
|
|
function() {
|
|
if (SpecialPowers.isMainProcess()) {
|
|
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
|
|
}
|
|
|
|
SpecialPowers.setAllAppsLaunchable(true);
|
|
SpecialPowers.pushPrefEnv({"set": [["dom.mozBrowserFramesEnabled", true]]}, runTest);
|
|
},
|
|
|
|
// No confirmation needed when an app is installed
|
|
function() {
|
|
SpecialPowers.autoConfirmAppInstall(() =>
|
|
SpecialPowers.autoConfirmAppUninstall(runTest));
|
|
},
|
|
|
|
// Installing the app1
|
|
function() { installApp(gHostedManifestURL); },
|
|
|
|
// Installing the app2
|
|
function() { installApp(gHostedManifestURL2); },
|
|
|
|
// Run tests in app. 2 apps are installed so we want to have 2 'foo'
|
|
// dataStore.
|
|
function() { testApp(2); },
|
|
|
|
// Uninstall the first app
|
|
function() { uninstallApp(gApps.shift()); },
|
|
|
|
// Run tests in app. 1 single apps is installed so we want to have 1 'foo'
|
|
// dataStore.
|
|
function() { testApp(1); },
|
|
|
|
// Installing the app1
|
|
function() { installApp(gHostedManifestURL); },
|
|
|
|
// Run tests in app. Back to 2 apps, 2 datastores.
|
|
function() { testApp(2); },
|
|
|
|
// Uninstall the first app
|
|
function() { uninstallApp(gApps.shift()); },
|
|
|
|
// Uninstall the second app
|
|
function() { uninstallApp(gApps.shift()); }
|
|
];
|
|
|
|
function runTest() {
|
|
if (!tests.length) {
|
|
finish();
|
|
return;
|
|
}
|
|
|
|
var test = tests.shift();
|
|
test();
|
|
}
|
|
|
|
function finish() {
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
runTest();
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|