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

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

mercurial