Bug 1248550 - Part 7: Improve the test for idle maintenance to trigger interference between database maintenance and normal database operations; r=khuey
authorJan Varga <jan.varga@gmail.com>
Tue, 01 Mar 2016 10:45:17 +0100
changeset 322596 bdd20d022a20cc5927ba46ebf2167ff72fd2fca9
parent 322595 e00fd36ad4ceb1f5e5e4210af049e858fc503740
child 322597 df332ac26b527429fd56bc9d5f26876a8441eb41
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1248550
milestone47.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 1248550 - Part 7: Improve the test for idle maintenance to trigger interference between database maintenance and normal database operations; r=khuey
dom/indexedDB/test/unit/test_idle_maintenance.js
--- a/dom/indexedDB/test/unit/test_idle_maintenance.js
+++ b/dom/indexedDB/test/unit/test_idle_maintenance.js
@@ -30,16 +30,45 @@ function testSteps()
 
   do_get_idle();
 
   info("Creating databases");
 
   let quotaManagerService = Cc["@mozilla.org/dom/quota-manager-service;1"].
                             getService(Ci.nsIQuotaManagerService);
 
+  // Keep at least one database open.
+  let req = indexedDB.open("foo-a", 1);
+  req.onerror = errorHandler;
+  req.onsuccess = grabEventAndContinueHandler;
+  let event = yield undefined;
+
+  let dbA = event.target.result;
+
+  // Keep at least one factory operation alive by deleting a database that is
+  // stil open.
+  req = indexedDB.open("foo-b", 1);
+  req.onerror = errorHandler;
+  req.onsuccess = grabEventAndContinueHandler;
+  event = yield undefined;
+
+  let dbB = event.target.result;
+
+  indexedDB.deleteDatabase("foo-b");
+
+  // Create a database which we will later try to open while maintenance is
+  // performed.
+  req = indexedDB.open("foo-c", 1);
+  req.onerror = errorHandler;
+  req.onsuccess = grabEventAndContinueHandler;
+  event = yield undefined;
+
+  let dbC = event.target.result;
+  dbC.close();
+
   let dbCount = 0;
 
   for (let persistence of ["persistent", "temporary", "default"]) {
     for (let i = 1; i <= 5; i++) {
       let dbName = "foo-" + i;
       let dbPersistence = persistence;
       let req = indexedDB.openForPrincipal(principal,
                                            dbName,
@@ -99,16 +128,23 @@ function testSteps()
   });
   yield undefined;
 
   info("Sending fake 'idle-daily' notification to QuotaManager");
 
   let observer = quotaManagerService.QueryInterface(Ci.nsIObserver);
   observer.observe(null, "idle-daily", "");
 
+  info("Opening database while maintenance is performed");
+
+  req = indexedDB.open("foo-c", 1);
+  req.onerror = errorHandler;
+  req.onsuccess = grabEventAndContinueHandler;
+  yield undefined;
+
   info("Waiting for maintenance to start");
 
   // This time is totally arbitrary. Most likely directory scanning will have
   // completed, QuotaManager locks will be acquired, and  maintenance tasks will
   // be scheduled before this time has elapsed, so we will be testing the
   // maintenance code. However, if something is slow then this will test
   // shutting down in the middle of maintenance.
   setTimeout(continueToNextStep, 10000);