Bug 806168 - Test for bugs 802366 and 806127. r=bent
authorJustin Lebar <justin.lebar@gmail.com>
Sat, 10 Nov 2012 10:32:38 -0800
changeset 112947 7bd8f1301fceada03cb796bf7de47ecbd663afc8
parent 112946 9b762aa96799981407bfec57a09d84828c72bb7f
child 112948 8ed3ac815205e23aae4bfbce1a8f1daf1b10c2dc
push id23841
push userryanvm@gmail.com
push dateSat, 10 Nov 2012 21:53:54 +0000
treeherdermozilla-central@8dab31701ed1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs806168, 802366, 806127
milestone19.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 806168 - Test for bugs 802366 and 806127. r=bent These new tests are disabled on Android because the test they're replacing, test_webapp_clearBrowserData.html, was also disabled on Android, and the new tests fail in the same way as the original test.
dom/indexedDB/test/Makefile.in
dom/indexedDB/test/test_webapp_clearBrowserData.html
dom/indexedDB/test/test_webapp_clearBrowserData_inproc_inproc.html
dom/indexedDB/test/test_webapp_clearBrowserData_inproc_oop.html
dom/indexedDB/test/test_webapp_clearBrowserData_oop_inproc.html
dom/indexedDB/test/webapp_clearBrowserData.js
dom/indexedDB/test/webapp_clearBrowserData_appFrame.html
dom/indexedDB/test/webapp_clearBrowserData_browserFrame.html
testing/mochitest/android.json
--- a/dom/indexedDB/test/Makefile.in
+++ b/dom/indexedDB/test/Makefile.in
@@ -99,21 +99,24 @@ MOCHITEST_FILES = \
   test_transaction_lifetimes.html \
   test_transaction_lifetimes_nested.html \
   test_transaction_ordering.html \
   test_setVersion.html \
   test_setVersion_abort.html \
   test_setVersion_events.html \
   test_setVersion_exclusion.html \
   test_unique_index_update.html \
-  test_webapp_clearBrowserData.html \
+  test_webapp_clearBrowserData_inproc_oop.html \
+  test_webapp_clearBrowserData_oop_inproc.html \
+  test_webapp_clearBrowserData_inproc_inproc.html \
   third_party_iframe1.html \
   third_party_iframe2.html \
   test_app_isolation_inproc.html \
   test_app_isolation_oop.html \
+  webapp_clearBrowserData.js \
   webapp_clearBrowserData_appFrame.html \
   webapp_clearBrowserData_browserFrame.html \
   $(NULL)
 
 #   test_writer_starvation.html  disabled for infinite loops, bug 595368
 
 ifeq (browser,$(MOZ_BUILD_APP))
 MOCHITEST_BROWSER_FILES = \
new file mode 100644
--- /dev/null
+++ b/dom/indexedDB/test/test_webapp_clearBrowserData_inproc_inproc.html
@@ -0,0 +1,33 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+
+<!--
+  We have three similar tests here which each check that indexedDB data for a
+  browser inside an app is cleared upon request:
+
+    1) test_webapp_clearBrowserData_inproc_oop.html,
+    2) test_webapp_clearBrowserData_oop_inproc.html, and
+    3) test_webapp_clearBrowserData_inproc_inproc.html.
+
+  The only difference between these is that the first constructs an in-process
+  app frame which contains an out-of-process browser frame, the second
+  constructs an out-of-process app frame which contains an in-process browser
+  frame, and the third has both frames in process.
+
+  The tests share all their JS code.  webapp_clearBrowserData.js determines
+  which frames are in- and out-of-process by looking at the test's filename.
+-->
+
+<html>
+<head>
+  <title>Indexed Database Clear Browser Data Test inproc/inproc</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="text/javascript;version=1.7" src="webapp_clearBrowserData.js"></script>
+  <script type="text/javascript;version=1.7" src="helpers.js"></script>
+</head>
+<body onload="start();">
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/indexedDB/test/test_webapp_clearBrowserData_inproc_oop.html
@@ -0,0 +1,21 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+
+<!--
+  See comment in test_webapp_clearBrowserData_inproc_inproc.html for an
+  explanation of what's going on here.
+-->
+
+<html>
+<head>
+  <title>Indexed Database Clear Browser Data Test inproc/oop</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript;version=1.7" src="webapp_clearBrowserData.js"></script>
+  <script type="text/javascript;version=1.7" src="helpers.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body onload="start();">
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/indexedDB/test/test_webapp_clearBrowserData_oop_inproc.html
@@ -0,0 +1,21 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+
+<!--
+  See comment in test_webapp_clearBrowserData_inproc_inproc.html for an
+  explanation of what's going on here.
+-->
+
+<html>
+<head>
+  <title>Indexed Database Clear Browser Data Test oop/inproc</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript;version=1.7" src="webapp_clearBrowserData.js"></script>
+  <script type="text/javascript;version=1.7" src="helpers.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body onload="start();">
+</body>
+</html>
rename from dom/indexedDB/test/test_webapp_clearBrowserData.html
rename to dom/indexedDB/test/webapp_clearBrowserData.js
--- a/dom/indexedDB/test/test_webapp_clearBrowserData.html
+++ b/dom/indexedDB/test/webapp_clearBrowserData.js
@@ -1,32 +1,47 @@
-<!--
-  Any copyright is dedicated to the Public Domain.
-  http://creativecommons.org/publicdomain/zero/1.0/
--->
-<html>
-<head>
-  <title>Indexed Database Clear Browser Data Test</title>
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+// This file has 4 leading spaces so that hg/git can tell that it's copied
+// from test_webapp_clearBrowserData.html.  We'll fix the indentation in
+// the next commit.
 
-  <script type="text/javascript;version=1.7">
     "use strict";
 
     const appDomain = "example.org";
     const manifestURL =
       location.protocol + "//" + appDomain + "/manifest.webapp";
 
     function testSteps()
     {
       const objectStoreName = "foo";
       const testKey = 1;
       const testValue = objectStoreName;
 
+      // Determine whether the app and browser frames should be in or
+      // out-of-process.
+      let remote_app, remote_browser;
+      if (window.location.href.indexOf("inproc_oop") != -1) {
+        remote_app = false;
+        remote_browser = true;
+      }
+      else if (window.location.href.indexOf("oop_inproc") != -1) {
+        remote_app = true;
+        remote_browser = false;
+      }
+      else if (window.location.href.indexOf("inproc_inproc") != -1) {
+        remote_app = false;
+        remote_browser = false;
+      }
+      else {
+        ok(false, "Bad test filename!");
+        return;
+      }
+
       let request = indexedDB.open(window.location.pathname, 1);
       request.onerror = errorHandler;
       request.onupgradeneeded = grabEventAndContinueHandler;
       request.onsuccess = unexpectedSuccessHandler;
       let event = yield;
 
       let db = event.target.result;
       db.onerror = errorHandler;
@@ -35,26 +50,33 @@
       }
 
       let objectStore = db.createObjectStore(objectStoreName);
       objectStore.add(testValue, testKey);
 
       request.onsuccess = grabEventAndContinueHandler;
       event = yield;
 
-      let srcURL =
-        location.protocol + "//" + appDomain +
-        location.pathname.replace("test_webapp_clearBrowserData.html",
-                                  "webapp_clearBrowserData_appFrame.html");
+      // We need to send both remote_browser and remote_app in the querystring
+      // because webapp_clearBrowserData_appFrame uses the path + querystring to
+      // create and open a database which it checks no other test has touched.  If
+      // we sent only remote_browser, then we wouldn't be able to test both
+      // (remote_app==false, remote_browser==false) and (remote_app==true,
+      // remote_browser==false).
+      let srcURL = location.protocol + "//" + appDomain +
+        location.pathname.substring(0, location.pathname.lastIndexOf('/')) +
+        "/webapp_clearBrowserData_appFrame.html?" +
+        "remote_browser=" + remote_browser + "&" +
+        "remote_app=" + remote_app;
 
       let iframe = document.createElement("iframe");
       iframe.setAttribute("mozbrowser", "");
       iframe.setAttribute("mozapp", manifestURL);
       iframe.setAttribute("src", srcURL);
-      iframe.setAttribute("remote", "true");
+      iframe.setAttribute("remote", remote_app);
       iframe.addEventListener("mozbrowsershowmodalprompt", function(event) {
         let message = JSON.parse(event.detail.message);
         switch (message.type) {
           case "info":
           case "ok":
             window[message.type].apply(window, message.args);
             break;
           case "done":
@@ -122,16 +144,8 @@
           appRegistry.allAppsLaunchable = originalAllAppsLaunchable;
         }
       }, false);
 
       SpecialPowers.pushPrefEnv({
         "set": [["dom.mozBrowserFramesEnabled", true]]
       }, runTest);
     }
-  </script>
-
-  <script type="text/javascript;version=1.7" src="helpers.js"></script>
-</head>
-
-<body onload="start();"></body>
-
-</html>
--- a/dom/indexedDB/test/webapp_clearBrowserData_appFrame.html
+++ b/dom/indexedDB/test/webapp_clearBrowserData_appFrame.html
@@ -28,18 +28,33 @@
 
     window.onerror = ok.bind(window, false);
 
     function testSteps()
     {
       const objectStoreName = "foo";
       const testKey = 1;
       const testValue = objectStoreName;
+      const dbName = location.pathname + location.search;
 
-      let request = indexedDB.open(window.location.pathname, 1);
+      // Determine whether our parent iframe asked us to create a remote
+      // browser frame here.
+      let remote_browser;
+      if (location.search.indexOf("remote_browser=true") != -1) {
+        remote_browser = true;
+      }
+      else if (location.search.indexOf("remote_browser=false") != -1) {
+        remote_browser = false;
+      }
+      else {
+        ok(false, "Expected remote_browser={true,false} in query string.");
+        return;
+      }
+
+      let request = indexedDB.open(dbName, 1);
       request.onerror = errorHandler;
       request.onupgradeneeded = grabEventAndContinueHandler;
       request.onsuccess = unexpectedSuccessHandler;
       let event = yield;
 
       let db = event.target.result;
       db.onerror = errorHandler;
       db.onversionchange = function(event) {
@@ -58,17 +73,21 @@
         db.transaction(objectStoreName).objectStore(objectStoreName);
       objectStore.get(testKey).onsuccess = grabEventAndContinueHandler;
       event = yield;
 
       ok(testValue == event.target.result, "data exists");
 
       let iframe = document.createElement("iframe");
       iframe.setAttribute("mozbrowser", "");
-      iframe.setAttribute("src", "webapp_clearBrowserData_browserFrame.html");
+      // Send our querystring to the subframe because
+      // webapp_clearBrowserData_browserFrame uses its pathname + querystring to
+      // open a database which it assumes hasn't been touched by another test.
+      iframe.setAttribute("src", "webapp_clearBrowserData_browserFrame.html" + location.search);
+      iframe.setAttribute("remote", remote_browser);
       iframe.addEventListener("mozbrowsershowmodalprompt", function(event) {
         let message = JSON.parse(event.detail.message);
         switch (message.type) {
           case "block":
             info("blocking browserFrame");
             event.preventDefault();
 
             let request = navigator.mozApps.getSelf();
@@ -91,17 +110,17 @@
         }
       });
 
       info("loading browser frame");
 
       document.body.appendChild(iframe);
       yield;
 
-      request = indexedDB.open(window.location.pathname, 1);
+      request = indexedDB.open(dbName, 1);
       request.onerror = errorHandler;
       request.onupgradeneeded = unexpectedSuccessHandler;
       request.onsuccess = grabEventAndContinueHandler;
       event = yield;
 
       db = event.target.result;
       db.onerror = errorHandler;
 
--- a/dom/indexedDB/test/webapp_clearBrowserData_browserFrame.html
+++ b/dom/indexedDB/test/webapp_clearBrowserData_browserFrame.html
@@ -38,18 +38,19 @@
 
     window.onerror = ok.bind(window, false);
 
     function testSteps()
     {
       const objectStoreName = "foo";
       const testKey = 1;
       const testValue = objectStoreName;
+      const dbName = window.location.pathname + window.location.search;
 
-      let request = indexedDB.open(window.location.pathname, 1);
+      let request = indexedDB.open(dbName, 1);
       request.onerror = errorHandler;
       request.onupgradeneeded = grabEventAndContinueHandler;
       request.onsuccess = unexpectedSuccessHandler;
       let event = yield;
 
       let db = event.target.result;
       db.onerror = errorHandler;
       db.onversionchange = function(event) {
@@ -68,17 +69,17 @@
         db.transaction(objectStoreName).objectStore(objectStoreName);
       objectStore.get(testKey).onsuccess = grabEventAndContinueHandler;
       event = yield;
 
       ok(testValue == event.target.result, "data exists");
 
       block();
 
-      request = indexedDB.open(window.location.pathname, 1);
+      request = indexedDB.open(dbName, 1);
       request.onerror = errorHandler;
       request.onupgradeneeded = grabEventAndContinueHandler;
       request.onsuccess = unexpectedSuccessHandler;
       event = yield;
 
       ok(event.type == "upgradeneeded", "db doesn't exist");
 
       request.onsuccess = grabEventAndContinueHandler;
--- a/testing/mochitest/android.json
+++ b/testing/mochitest/android.json
@@ -147,17 +147,19 @@
  "dom/imptests/webapps/DOMCore/tests/approved/test_Range-set.html": "bug 775227",
  "dom/imptests/webapps/DOMCore/tests/approved/test_Range-surroundContents.html": "bug 775227",
  "dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_storage_local_key.html": "bug 775227",
  "dom/indexedDB/ipc/test_ipc.html": "bug 783513",
  "dom/indexedDB/test/test_third_party.html": "TIMED_OUT",
  "dom/indexedDB/test/test_event_propagation.html": "TIMED_OUT, bug 780855",
  "dom/indexedDB/test/test_app_isolation_inproc.html": "TIMED_OUT",
  "dom/indexedDB/test/test_app_isolation_oop.html": "TIMED_OUT",
- "dom/indexedDB/test/test_webapp_clearBrowserData.html": "No test app installed",
+ "dom/indexedDB/test/test_webapp_clearBrowserData_inproc_inproc.html": "No test app installed",
+ "dom/indexedDB/test/test_webapp_clearBrowserData_inproc_oop.html": "No test app installed",
+ "dom/indexedDB/test/test_webapp_clearBrowserData_oop_inproc.html": "No test app installed",
  "dom/network/tests/test_network_basics.html": "",
  "dom/permission/tests/test_permission_basics.html": "",
  "dom/sms/tests/test_sms_basics.html": "",
  "dom/tests/mochitest/ajax/jquery/test_jQuery.html": "bug 775227",
  "dom/tests/mochitest/ajax/offline/test_simpleManifest.html": "TIMED_OUT",
  "dom/tests/mochitest/ajax/offline/test_updatingManifest.html": "TIMED_OUT",
  "dom/tests/mochitest/ajax/offline/test_xhtmlManifest.xhtml": "TIMED_OUT",
  "dom/tests/mochitest/ajax/prototype/test_Prototype.html": "",