michael@0: /** michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Make sure this is a unique origin or the tests will randomly fail! michael@0: const testPageURL = "http://bug702292.example.com/browser/" + michael@0: "dom/indexedDB/test/browser_quotaPromptDelete.html"; michael@0: const notificationID = "indexedDB-quota-prompt"; michael@0: michael@0: function test() michael@0: { michael@0: waitForExplicitFinish(); michael@0: requestLongerTimeout(10); michael@0: PopupNotifications.transitionsEnabled = false; michael@0: removePermission(testPageURL, "indexedDB-unlimited"); michael@0: Services.prefs.setIntPref("dom.indexedDB.warningQuota", 2); michael@0: executeSoon(test1); michael@0: } michael@0: michael@0: let addMoreTest1Count = 0; michael@0: let haveReset = false; michael@0: let secondTimeCount = 0; michael@0: michael@0: function test1() michael@0: { michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: michael@0: gBrowser.selectedBrowser.addEventListener("load", function () { michael@0: gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); michael@0: michael@0: let seenPopupCount; michael@0: michael@0: setFinishedCallback(function(result) { michael@0: is(result, "ready", "Got 'ready' result"); michael@0: michael@0: setFinishedCallback(function(result) { michael@0: if (result == "abort") { michael@0: setFinishedCallback(function(result) { michael@0: is(result, "resetDone", "Got 'resetDone' result"); michael@0: michael@0: function secondTimeThroughCallback(result) { michael@0: is(result, "complete", "Got 'complete' result"); michael@0: michael@0: // If we hit the quota on the Nth iteration last time, we should michael@0: // be able to go N-1 iterations without hitting it after michael@0: // obliterating the db. michael@0: if (++secondTimeCount < addMoreTest1Count - 1) { michael@0: secondTimeThroughAddMore(); michael@0: } else { michael@0: setFinishedCallback(function(result) { michael@0: is(result, "finished", "Got 'finished' result"); michael@0: is(getPermission(testPageURL, "indexedDB-unlimited"), michael@0: Components.interfaces.nsIPermissionManager.DENY_ACTION, michael@0: "Correct permission set"); michael@0: gBrowser.removeCurrentTab(); michael@0: unregisterAllPopupEventHandlers(); michael@0: PopupNotifications.transitionsEnabled = true; michael@0: executeSoon(finish); michael@0: }); michael@0: executeSoon(function() { dispatchEvent("indexedDB-done"); }); michael@0: } michael@0: } michael@0: michael@0: function secondTimeThroughAddMore() { michael@0: setFinishedCallback(secondTimeThroughCallback); michael@0: executeSoon(function() { dispatchEvent("indexedDB-addMore"); }); michael@0: } michael@0: michael@0: haveReset = true; michael@0: secondTimeThroughAddMore(); michael@0: }); michael@0: executeSoon(function() { dispatchEvent("indexedDB-reset"); }); michael@0: } michael@0: else { michael@0: ++addMoreTest1Count; michael@0: executeSoon(function() { dispatchEvent("indexedDB-addMore"); }); michael@0: } michael@0: }); michael@0: ++addMoreTest1Count; michael@0: executeSoon(function() { dispatchEvent("indexedDB-addMore"); }); michael@0: }); michael@0: michael@0: registerPopupEventHandler("popupshowing", function () { michael@0: ok(true, "prompt showing"); michael@0: seenPopupCount = addMoreTest1Count - 1; michael@0: }); michael@0: registerPopupEventHandler("popupshown", function () { michael@0: ok(true, "prompt shown"); michael@0: ok(!haveReset, "Shouldn't get here twice!"); michael@0: triggerSecondaryCommand(this, 0); michael@0: }); michael@0: registerPopupEventHandler("popuphidden", function () { michael@0: ok(true, "prompt hidden"); michael@0: }); michael@0: michael@0: }, true); michael@0: michael@0: info("loading test page: " + testPageURL); michael@0: content.location = testPageURL; michael@0: }