dom/indexedDB/test/browser_quotaPromptDelete.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /**
michael@0 2 * Any copyright is dedicated to the Public Domain.
michael@0 3 * http://creativecommons.org/publicdomain/zero/1.0/
michael@0 4 */
michael@0 5
michael@0 6 // Make sure this is a unique origin or the tests will randomly fail!
michael@0 7 const testPageURL = "http://bug702292.example.com/browser/" +
michael@0 8 "dom/indexedDB/test/browser_quotaPromptDelete.html";
michael@0 9 const notificationID = "indexedDB-quota-prompt";
michael@0 10
michael@0 11 function test()
michael@0 12 {
michael@0 13 waitForExplicitFinish();
michael@0 14 requestLongerTimeout(10);
michael@0 15 PopupNotifications.transitionsEnabled = false;
michael@0 16 removePermission(testPageURL, "indexedDB-unlimited");
michael@0 17 Services.prefs.setIntPref("dom.indexedDB.warningQuota", 2);
michael@0 18 executeSoon(test1);
michael@0 19 }
michael@0 20
michael@0 21 let addMoreTest1Count = 0;
michael@0 22 let haveReset = false;
michael@0 23 let secondTimeCount = 0;
michael@0 24
michael@0 25 function test1()
michael@0 26 {
michael@0 27 gBrowser.selectedTab = gBrowser.addTab();
michael@0 28
michael@0 29 gBrowser.selectedBrowser.addEventListener("load", function () {
michael@0 30 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
michael@0 31
michael@0 32 let seenPopupCount;
michael@0 33
michael@0 34 setFinishedCallback(function(result) {
michael@0 35 is(result, "ready", "Got 'ready' result");
michael@0 36
michael@0 37 setFinishedCallback(function(result) {
michael@0 38 if (result == "abort") {
michael@0 39 setFinishedCallback(function(result) {
michael@0 40 is(result, "resetDone", "Got 'resetDone' result");
michael@0 41
michael@0 42 function secondTimeThroughCallback(result) {
michael@0 43 is(result, "complete", "Got 'complete' result");
michael@0 44
michael@0 45 // If we hit the quota on the Nth iteration last time, we should
michael@0 46 // be able to go N-1 iterations without hitting it after
michael@0 47 // obliterating the db.
michael@0 48 if (++secondTimeCount < addMoreTest1Count - 1) {
michael@0 49 secondTimeThroughAddMore();
michael@0 50 } else {
michael@0 51 setFinishedCallback(function(result) {
michael@0 52 is(result, "finished", "Got 'finished' result");
michael@0 53 is(getPermission(testPageURL, "indexedDB-unlimited"),
michael@0 54 Components.interfaces.nsIPermissionManager.DENY_ACTION,
michael@0 55 "Correct permission set");
michael@0 56 gBrowser.removeCurrentTab();
michael@0 57 unregisterAllPopupEventHandlers();
michael@0 58 PopupNotifications.transitionsEnabled = true;
michael@0 59 executeSoon(finish);
michael@0 60 });
michael@0 61 executeSoon(function() { dispatchEvent("indexedDB-done"); });
michael@0 62 }
michael@0 63 }
michael@0 64
michael@0 65 function secondTimeThroughAddMore() {
michael@0 66 setFinishedCallback(secondTimeThroughCallback);
michael@0 67 executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
michael@0 68 }
michael@0 69
michael@0 70 haveReset = true;
michael@0 71 secondTimeThroughAddMore();
michael@0 72 });
michael@0 73 executeSoon(function() { dispatchEvent("indexedDB-reset"); });
michael@0 74 }
michael@0 75 else {
michael@0 76 ++addMoreTest1Count;
michael@0 77 executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
michael@0 78 }
michael@0 79 });
michael@0 80 ++addMoreTest1Count;
michael@0 81 executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
michael@0 82 });
michael@0 83
michael@0 84 registerPopupEventHandler("popupshowing", function () {
michael@0 85 ok(true, "prompt showing");
michael@0 86 seenPopupCount = addMoreTest1Count - 1;
michael@0 87 });
michael@0 88 registerPopupEventHandler("popupshown", function () {
michael@0 89 ok(true, "prompt shown");
michael@0 90 ok(!haveReset, "Shouldn't get here twice!");
michael@0 91 triggerSecondaryCommand(this, 0);
michael@0 92 });
michael@0 93 registerPopupEventHandler("popuphidden", function () {
michael@0 94 ok(true, "prompt hidden");
michael@0 95 });
michael@0 96
michael@0 97 }, true);
michael@0 98
michael@0 99 info("loading test page: " + testPageURL);
michael@0 100 content.location = testPageURL;
michael@0 101 }

mercurial