dom/indexedDB/test/browser_quotaPromptDatabases.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://bug704464-3.example.com/browser/" +
michael@0 8 "dom/indexedDB/test/browser_quotaPromptDatabases.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
michael@0 23 function test1()
michael@0 24 {
michael@0 25 gBrowser.selectedTab = gBrowser.addTab();
michael@0 26
michael@0 27 gBrowser.selectedBrowser.addEventListener("load", function () {
michael@0 28 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
michael@0 29
michael@0 30 let seenPopupCount;
michael@0 31
michael@0 32 setFinishedCallback(function(result) {
michael@0 33 is(result, "ready", "Got 'ready' result");
michael@0 34
michael@0 35 setFinishedCallback(function(result) {
michael@0 36 is(result, "complete", "Got 'complete' result");
michael@0 37
michael@0 38 if (addMoreTest1Count >= seenPopupCount + 5) {
michael@0 39 setFinishedCallback(function(result) {
michael@0 40 is(result, "finished", "Got 'finished' result");
michael@0 41 is(getPermission(testPageURL, "indexedDB-unlimited"),
michael@0 42 Components.interfaces.nsIPermissionManager.ALLOW_ACTION,
michael@0 43 "Correct permission set");
michael@0 44 gBrowser.removeCurrentTab();
michael@0 45 unregisterAllPopupEventHandlers();
michael@0 46 addMoreTest1Count = seenPopupCount;
michael@0 47 PopupNotifications.transitionsEnabled = true;
michael@0 48 executeSoon(finish);
michael@0 49 });
michael@0 50 executeSoon(function() { dispatchEvent("indexedDB-done"); });
michael@0 51 }
michael@0 52 else {
michael@0 53 ++addMoreTest1Count;
michael@0 54 executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
michael@0 55 }
michael@0 56 });
michael@0 57 ++addMoreTest1Count;
michael@0 58 executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
michael@0 59 });
michael@0 60
michael@0 61 registerPopupEventHandler("popupshowing", function () {
michael@0 62 ok(true, "prompt showing");
michael@0 63 seenPopupCount = addMoreTest1Count - 1;
michael@0 64 });
michael@0 65 registerPopupEventHandler("popupshown", function () {
michael@0 66 ok(true, "prompt shown");
michael@0 67 triggerMainCommand(this);
michael@0 68 });
michael@0 69 registerPopupEventHandler("popuphidden", function () {
michael@0 70 ok(true, "prompt hidden");
michael@0 71 });
michael@0 72
michael@0 73 }, true);
michael@0 74
michael@0 75 info("loading test page: " + testPageURL);
michael@0 76 content.location = testPageURL;
michael@0 77 }

mercurial