gecko-dev/dom/datastore/tests/test_readonly.html
Nikhil Marathe 5f05b80e02 Bug 918806 - Remove all mention of dom.promise.enabled from other tests. r=bz,schien
--HG--
extra : rebase_source : a07485081313d6002459bd64e3abf4ebb10b960d
2014-01-30 13:14:03 -08:00

109 lines
3.5 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for DataStore - basic operation on a readonly db</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<div id="container"></div>
<script type="application/javascript;version=1.7">
var gHostedManifestURL = 'http://test/tests/dom/datastore/tests/file_app.sjs?testToken=file_readonly.html';
var gHostedManifestURL2 = 'http://example.com/tests/dom/datastore/tests/file_app.sjs?testToken=file_readonly.html&template=file_app2.template.webapp';
var gGenerator = runTest();
SpecialPowers.pushPermissions(
[{ "type": "browser", "allow": 1, "context": document },
{ "type": "embed-apps", "allow": 1, "context": document },
{ "type": "webapps-manage", "allow": 1, "context": document }],
function() { gGenerator.next() });
function continueTest() {
try { gGenerator.next(); }
catch(e) {}
}
function cbError() {
ok(false, "Error callback invoked");
finish();
}
function runTest() {
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
SpecialPowers.autoConfirmAppInstall(continueTest);
yield undefined;
var request = navigator.mozApps.install(gHostedManifestURL);
request.onerror = cbError;
request.onsuccess = continueTest;
yield undefined;
var app = request.result;
request = navigator.mozApps.install(gHostedManifestURL2);
request.onerror = cbError;
request.onsuccess = continueTest;
yield undefined;
var app2 = request.result;
var ifr = document.createElement('iframe');
ifr.setAttribute('mozbrowser', 'true');
ifr.setAttribute('mozapp', app2.manifestURL);
ifr.setAttribute('src', app2.manifest.launch_path);
var domParent = document.getElementById('container');
// Set us up to listen for messages from the app.
var listener = function(e) {
var message = e.detail.message;
if (/^OK/.exec(message)) {
ok(true, "Message from app: " + message);
} else if (/KO/.exec(message)) {
ok(false, "Message from app: " + message);
} else if (/DONE/.exec(message)) {
ok(true, "Messaging from app complete");
ifr.removeEventListener('mozbrowsershowmodalprompt', listener);
domParent.removeChild(ifr);
// Uninstall the app.
request = navigator.mozApps.mgmt.uninstall(app);
request.onerror = cbError;
request.onsuccess = function() {
// Uninstall app2
request = navigator.mozApps.mgmt.uninstall(app2);
request.onerror = cbError;
request.onsuccess = function() {
// All done.
info("All done");
finish();
}
}
}
}
// This event is triggered when the app calls "alert".
ifr.addEventListener('mozbrowsershowmodalprompt', listener, false);
domParent.appendChild(ifr);
}
function finish() {
SpecialPowers.clearUserPref("dom.mozBrowserFramesEnabled");
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
</script>
</body>
</html>