Bug 1248550 - Part 7: Improve the test for idle maintenance to trigger interference between database maintenance and normal database operations; r=khuey

This commit is contained in:
Jan Varga 2016-03-01 10:45:17 +01:00
parent 97b46b27da
commit 1095142f64

View File

@ -35,6 +35,35 @@ function testSteps()
let quotaManagerService = Cc["@mozilla.org/dom/quota-manager-service;1"]. let quotaManagerService = Cc["@mozilla.org/dom/quota-manager-service;1"].
getService(Ci.nsIQuotaManagerService); 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; let dbCount = 0;
for (let persistence of ["persistent", "temporary", "default"]) { for (let persistence of ["persistent", "temporary", "default"]) {
@ -104,6 +133,13 @@ function testSteps()
let observer = quotaManagerService.QueryInterface(Ci.nsIObserver); let observer = quotaManagerService.QueryInterface(Ci.nsIObserver);
observer.observe(null, "idle-daily", ""); 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"); info("Waiting for maintenance to start");
// This time is totally arbitrary. Most likely directory scanning will have // This time is totally arbitrary. Most likely directory scanning will have