dom/indexedDB/test/browser_quotaPromptDatabases.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/indexedDB/test/browser_quotaPromptDatabases.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,77 @@
     1.4 +/**
     1.5 + * Any copyright is dedicated to the Public Domain.
     1.6 + * http://creativecommons.org/publicdomain/zero/1.0/
     1.7 + */
     1.8 +
     1.9 +// Make sure this is a unique origin or the tests will randomly fail!
    1.10 +const testPageURL = "http://bug704464-3.example.com/browser/" +
    1.11 +  "dom/indexedDB/test/browser_quotaPromptDatabases.html";
    1.12 +const notificationID = "indexedDB-quota-prompt";
    1.13 +
    1.14 +function test()
    1.15 +{
    1.16 +  waitForExplicitFinish();
    1.17 +  requestLongerTimeout(10);
    1.18 +  PopupNotifications.transitionsEnabled = false;
    1.19 +  removePermission(testPageURL, "indexedDB-unlimited");
    1.20 +  Services.prefs.setIntPref("dom.indexedDB.warningQuota", 2);
    1.21 +  executeSoon(test1);
    1.22 +}
    1.23 +
    1.24 +let addMoreTest1Count = 0;
    1.25 +
    1.26 +function test1()
    1.27 +{
    1.28 +  gBrowser.selectedTab = gBrowser.addTab();
    1.29 +
    1.30 +  gBrowser.selectedBrowser.addEventListener("load", function () {
    1.31 +    gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
    1.32 +
    1.33 +    let seenPopupCount;
    1.34 +
    1.35 +    setFinishedCallback(function(result) {
    1.36 +      is(result, "ready", "Got 'ready' result");
    1.37 +
    1.38 +      setFinishedCallback(function(result) {
    1.39 +        is(result, "complete", "Got 'complete' result");
    1.40 +
    1.41 +        if (addMoreTest1Count >= seenPopupCount + 5) {
    1.42 +          setFinishedCallback(function(result) {
    1.43 +            is(result, "finished", "Got 'finished' result");
    1.44 +            is(getPermission(testPageURL, "indexedDB-unlimited"),
    1.45 +               Components.interfaces.nsIPermissionManager.ALLOW_ACTION,
    1.46 +               "Correct permission set");
    1.47 +            gBrowser.removeCurrentTab();
    1.48 +            unregisterAllPopupEventHandlers();
    1.49 +            addMoreTest1Count = seenPopupCount;
    1.50 +            PopupNotifications.transitionsEnabled = true;
    1.51 +            executeSoon(finish);
    1.52 +          });
    1.53 +          executeSoon(function() { dispatchEvent("indexedDB-done"); });
    1.54 +        }
    1.55 +        else {
    1.56 +          ++addMoreTest1Count;
    1.57 +          executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
    1.58 +        }
    1.59 +      });
    1.60 +      ++addMoreTest1Count;
    1.61 +      executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
    1.62 +    });
    1.63 +
    1.64 +    registerPopupEventHandler("popupshowing", function () {
    1.65 +      ok(true, "prompt showing");
    1.66 +      seenPopupCount = addMoreTest1Count - 1;
    1.67 +    });
    1.68 +    registerPopupEventHandler("popupshown", function () {
    1.69 +      ok(true, "prompt shown");
    1.70 +      triggerMainCommand(this);
    1.71 +    });
    1.72 +    registerPopupEventHandler("popuphidden", function () {
    1.73 +      ok(true, "prompt hidden");
    1.74 +    });
    1.75 +
    1.76 +  }, true);
    1.77 +
    1.78 +  info("loading test page: " + testPageURL);
    1.79 +  content.location = testPageURL;
    1.80 +}

mercurial