5 <title>Test for DataStore - basic operation on a readonly db
</title>
6 <script type=
"application/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
10 <div id=
"container"></div>
11 <script type=
"application/javascript;version=1.7">
13 var gHostedManifestURL = 'http://test/tests/dom/datastore/tests/file_app.sjs?testToken=file_basic.html';
17 ok(false,
"Error callback invoked");
21 function installApp() {
22 var request = navigator.mozApps.install(gHostedManifestURL);
23 request.onerror = cbError;
24 request.onsuccess = function() {
25 gApp = request.result;
30 function uninstallApp() {
32 var request = navigator.mozApps.mgmt.uninstall(gApp);
33 request.onerror = cbError;
34 request.onsuccess = function() {
42 var ifr = document.createElement('iframe');
43 ifr.setAttribute('mozbrowser', 'true');
44 ifr.setAttribute('mozapp', gApp.manifestURL);
45 ifr.setAttribute('src', gApp.manifest.launch_path);
46 var domParent = document.getElementById('container');
48 // Set us up to listen for messages from the app.
49 var listener = function(e) {
50 var message = e.detail.message;
51 if (/^OK/.exec(message)) {
52 ok(true,
"Message from app: " + message);
53 } else if (/KO/.exec(message)) {
54 ok(false,
"Message from app: " + message);
55 } else if (/DONE/.exec(message)) {
56 ok(true,
"Messaging from app complete");
57 ifr.removeEventListener('mozbrowsershowmodalprompt', listener);
58 domParent.removeChild(ifr);
63 // This event is triggered when the app calls
"alert".
64 ifr.addEventListener('mozbrowsershowmodalprompt', listener, false);
65 domParent.appendChild(ifr);
71 SpecialPowers.pushPermissions(
72 [{
"type":
"browser",
"allow":
1,
"context": document },
73 {
"type":
"embed-apps",
"allow":
1,
"context": document },
74 {
"type":
"webapps-manage",
"allow":
1,
"context": document }], runTest);
79 SpecialPowers.pushPrefEnv({
"set": [[
"dom.datastore.enabled", true],
80 [
"dom.datastore.sysMsgOnChangeShortTimeoutSec",
1],
81 [
"dom.datastore.sysMsgOnChangeLongTimeoutSec",
3],
82 [
"dom.testing.ignore_ipc_principal", true],
83 [
"dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
87 if (SpecialPowers.isMainProcess()) {
88 SpecialPowers.Cu.import(
"resource://gre/modules/DataStoreChangeNotifier.jsm");
91 SpecialPowers.setAllAppsLaunchable(true);
92 SpecialPowers.pushPrefEnv({
"set":[[
"dom.mozBrowserFramesEnabled", true]]}, runTest);
95 // No confirmation needed when an app is installed
97 SpecialPowers.autoConfirmAppInstall(() =
>
98 SpecialPowers.autoConfirmAppUninstall(runTest));
101 // Installing the app
117 var test = tests.shift();
125 SimpleTest.waitForExplicitFinish();