Bug 827346 - indexedDB.open() silently fails in an Open Web App (OWA/mozApp). r=myk
authorMarco Castelluccio <mar.castelluccio@studenti.unina.it>
Wed, 17 Jul 2013 10:00:15 -0400
changeset 138914 f91d3bfa77064cbb9ed9653e3de298a229123dfb
parent 138913 352b3d608ade17416d55a7e8519bb17d537f6e07
child 138915 0791d8310519e198675e187a5bf040c70ea7cf30
push id24977
push userryanvm@gmail.com
push dateFri, 19 Jul 2013 00:35:38 +0000
treeherdermozilla-central@0d0263a58f06 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmyk
bugs827346
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 827346 - indexedDB.open() silently fails in an Open Web App (OWA/mozApp). r=myk
dom/apps/src/Webapps.js
webapprt/Startup.jsm
webapprt/prefs.js
webapprt/test/content/Makefile.in
webapprt/test/content/webapprt_indexeddb.html
--- a/dom/apps/src/Webapps.js
+++ b/dom/apps/src/Webapps.js
@@ -79,17 +79,17 @@ WebappsRegistry.prototype = {
     let res;
     try {
       uri = Services.io.newURI(aURL, null, null);
       if (uri.schemeIs("http") || uri.schemeIs("https")) {
         res = uri.spec;
       }
     } catch(e) {
       throw new Components.Exception(
-        "INVALID_URL: '" + aURL, Cr.NS_ERROR_FAILURE
+        "INVALID_URL: '" + aURL + "'", Cr.NS_ERROR_FAILURE
       );
     }
 
     // The scheme is incorrect, throw an exception.
     if (!res) {
       throw new Components.Exception(
         "INVALID_URL_SCHEME: '" + uri.scheme + "'; must be 'http' or 'https'",
         Cr.NS_ERROR_FAILURE
--- a/webapprt/Startup.jsm
+++ b/webapprt/Startup.jsm
@@ -19,26 +19,14 @@ Cu.import("resource://gre/modules/Servic
 Cu.import("resource://gre/modules/Webapps.jsm");
 
 // Initialize window-independent handling of webapps- notifications.
 Cu.import("resource://webapprt/modules/WebappsHandler.jsm");
 WebappsHandler.init();
 
 // On firstrun, set permissions to their default values.
 if (!Services.prefs.getBoolPref("webapprt.firstrun")) {
-  Cu.import("resource://webapprt/modules/WebappRT.jsm");
-  let uri = Services.io.newURI(WebappRT.config.app.origin, null, null);
-
-  // Set AppCache-related permissions.
-  Services.perms.add(uri, "pin-app",
-                     Ci.nsIPermissionManager.ALLOW_ACTION);
-  Services.perms.add(uri, "offline-app",
-                     Ci.nsIPermissionManager.ALLOW_ACTION);
-
-  Services.perms.add(uri, "indexedDB",
-                     Ci.nsIPermissionManager.ALLOW_ACTION);
-  Services.perms.add(uri, "indexedDB-unlimited",
-                     Ci.nsIPermissionManager.ALLOW_ACTION);
+  // Once we support packaged apps, set their permissions here on firstrun.
 
   // Now that we've set the appropriate permissions, twiddle the firstrun
   // flag so we don't try to do so again.
   Services.prefs.setBoolPref("webapprt.firstrun", true);
 }
--- a/webapprt/prefs.js
+++ b/webapprt/prefs.js
@@ -26,16 +26,25 @@ pref("extensions.blocklist.interval", 86
 // blocking them.
 pref("extensions.blocklist.level", 2);
 pref("extensions.blocklist.url", "https://addons.mozilla.org/blocklist/3/%APP_ID%/%APP_VERSION%/%PRODUCT%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/%PING_COUNT%/%TOTAL_PING_COUNT%/%DAYS_SINCE_LAST_PING%/");
 pref("extensions.blocklist.detailsURL", "https://www.mozilla.com/%LOCALE%/blocklist/");
 pref("extensions.blocklist.itemURL", "https://addons.mozilla.org/%LOCALE%/%APP%/blocked/%blockID%");
 
 pref("full-screen-api.enabled", true);
 
+// IndexedDB
+pref("dom.indexedDB.enabled", true);
+pref("indexedDB.feature.enabled", true);
+pref("dom.indexedDB.warningQuota", 50);
+
+// Offline cache prefs
+pref("browser.offline-apps.notify", false);
+pref("browser.cache.offline.enable", true);
+pref("offline-apps.allow_by_default", true);
 
 // Enable smooth scrolling
 pref("general.smoothScroll", true);
 
 pref("plugin.allowed_types", "application/x-shockwave-flash,application/futuresplash");
 
 // The default for this pref reflects whether the build is capable of IPC.
 // (Turning it on in a no-IPC build will have no effect.)
--- a/webapprt/test/content/Makefile.in
+++ b/webapprt/test/content/Makefile.in
@@ -8,11 +8,12 @@ srcdir         = @srcdir@
 VPATH          = @srcdir@
 relativesrcdir = @relativesrcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MOCHITEST_FILES = \
   test.webapp \
   webapprt_sample.html \
+  webapprt_indexeddb.html \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/webapprt/test/content/webapprt_indexeddb.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML>
+
+<!--
+  This is a IndexedDB WebappRT content mochitest.  Since its name is prefixed with
+  webapprt_, this file is picked up by the Mochitest harness.  It's just a plain
+  mochitest that runs in the app browser within an app window.
+-->
+
+<html>
+  <head>
+    <meta charset="utf-8">
+    <script src="/tests/SimpleTest/SimpleTest.js"></script>
+    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  </head>
+  <body>
+    <p id="display">
+      This is the IndexedDB WebappRT content mochitest.
+    </p>
+    <div id="content" style="display: none"></div>
+    <pre id="test">
+      <script>
+
+SimpleTest.waitForExplicitFinish();
+
+var request = indexedDB.open('test');
+request.onsuccess = function() {
+  ok(true, "onsuccess should be called");
+  SimpleTest.finish();
+}
+request.onerror = function() {
+  ok(false, "onerror shouldn't be called");
+  SimpleTest.finish();
+}
+
+      </script>
+    </pre>
+  </body>
+</html>