From f7fcb8e61d0ca46a04f77f492e0d69803d3b855c Mon Sep 17 00:00:00 2001 From: David Keeler Date: Thu, 7 Feb 2013 17:11:46 -0800 Subject: [PATCH] bug 839193 - test for corresponding bug r=bent --- dom/indexedDB/test/Makefile.in | 3 +++ dom/indexedDB/test/browser_bug839193.js | 35 +++++++++++++++++++++++++ dom/indexedDB/test/bug839193.js | 28 ++++++++++++++++++++ dom/indexedDB/test/bug839193.xul | 17 ++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 dom/indexedDB/test/browser_bug839193.js create mode 100644 dom/indexedDB/test/bug839193.js create mode 100644 dom/indexedDB/test/bug839193.xul diff --git a/dom/indexedDB/test/Makefile.in b/dom/indexedDB/test/Makefile.in index 7d49b55609ea..a5befe946c28 100644 --- a/dom/indexedDB/test/Makefile.in +++ b/dom/indexedDB/test/Makefile.in @@ -138,6 +138,9 @@ MOCHITEST_BROWSER_FILES = \ browser_quotaPromptDatabases.js \ browser_quotaPromptDelete.html \ browser_quotaPromptDelete.js \ + browser_bug839193.js \ + bug839193.js \ + bug839193.xul \ head.js \ $(NULL) diff --git a/dom/indexedDB/test/browser_bug839193.js b/dom/indexedDB/test/browser_bug839193.js new file mode 100644 index 000000000000..36bd7b809c10 --- /dev/null +++ b/dom/indexedDB/test/browser_bug839193.js @@ -0,0 +1,35 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +let gTestRoot = getRootDirectory(gTestPath); +let gBugWindow = null; +let gIterations = 5; + +function onLoad() { + gBugWindow.close(); +} + +function onUnload() { + if (!gIterations) { + finish(); + } else { + gBugWindow = window.openDialog(gTestRoot + "bug839193.xul"); + gIterations--; + } +} + +// This test is about leaks, which are handled by the test harness, so +// there are no actual checks here. Whether or not this test passes or fails +// will be apparent by the checks the harness performs. +function test() { + waitForExplicitFinish(); + Components.classes["@mozilla.org/observer-service;1"] + .getService(Components.interfaces.nsIObserverService) + .addObserver(onLoad, "bug839193-loaded", false); + Components.classes["@mozilla.org/observer-service;1"] + .getService(Components.interfaces.nsIObserverService) + .addObserver(onUnload, "bug839193-unloaded", false); + + gBugWindow = window.openDialog(gTestRoot + "bug839193.xul"); +} diff --git a/dom/indexedDB/test/bug839193.js b/dom/indexedDB/test/bug839193.js new file mode 100644 index 000000000000..343607483f76 --- /dev/null +++ b/dom/indexedDB/test/bug839193.js @@ -0,0 +1,28 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const nsIIndexedDatabaseManager = + Components.interfaces.nsIIndexedDatabaseManager; + +let gURI = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).newURI("http://localhost", null, null); + +function onIndexedDBUsageCallback(uri, usage, fileUsage) {} + +function onLoad() +{ + var dbManager = Components.classes["@mozilla.org/dom/indexeddb/manager;1"] + .getService(nsIIndexedDatabaseManager); + dbManager.getUsageForURI(gURI, onIndexedDBUsageCallback); + dbManager.cancelGetUsageForURI(gURI, onIndexedDBUsageCallback); + Components.classes["@mozilla.org/observer-service;1"] + .getService(Components.interfaces.nsIObserverService) + .notifyObservers(window, "bug839193-loaded", null); +} + +function onUnload() +{ + Components.classes["@mozilla.org/observer-service;1"] + .getService(Components.interfaces.nsIObserverService) + .notifyObservers(window, "bug839193-unloaded", null); +} diff --git a/dom/indexedDB/test/bug839193.xul b/dom/indexedDB/test/bug839193.xul new file mode 100644 index 000000000000..ccda48f95167 --- /dev/null +++ b/dom/indexedDB/test/bug839193.xul @@ -0,0 +1,17 @@ + + + + + +