dom/indexedDB/test/browser_quotaPromptDeny.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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://bug704464-2.example.com/browser/" +
     8   "dom/indexedDB/test/browser_quotaPrompt.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;
    23 function test1()
    24 {
    25   gBrowser.selectedTab = gBrowser.addTab();
    27   gBrowser.selectedBrowser.addEventListener("load", function () {
    28     gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
    30     let seenPopupCount;
    32     setFinishedCallback(function(result) {
    33       is(result, "ready", "Got 'ready' result");
    35       setFinishedCallback(function(result) {
    36         if (!seenPopupCount) {
    37           is(result, "complete", "Got 'complete' result");
    38         }
    39         else {
    40           is(result, "abort QuotaExceededError", "Got 'abort' result");
    41         }
    43         if (addMoreTest1Count >= seenPopupCount + 5) {
    44           setFinishedCallback(function(result) {
    45             is(result, "finished", "Got 'finished' result");
    46             is(getPermission(testPageURL, "indexedDB-unlimited"),
    47                Components.interfaces.nsIPermissionManager.DENY_ACTION,
    48                "Correct permission set");
    49             gBrowser.removeCurrentTab();
    50             unregisterAllPopupEventHandlers();
    51             addMoreTest1Count = seenPopupCount;
    52             PopupNotifications.transitionsEnabled = true;
    53             executeSoon(test2);
    54           });
    55           executeSoon(function() { dispatchEvent("indexedDB-done"); });
    56         }
    57         else {
    58           ++addMoreTest1Count;
    59           executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
    60         }
    61       });
    62       ++addMoreTest1Count;
    63       executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
    64     });
    66     registerPopupEventHandler("popupshowing", function () {
    67       ok(true, "prompt showing");
    68       seenPopupCount = addMoreTest1Count - 1;
    69     });
    70     registerPopupEventHandler("popupshown", function () {
    71       ok(true, "prompt shown");
    72       triggerSecondaryCommand(this, 0);
    73     });
    74     registerPopupEventHandler("popuphidden", function () {
    75       ok(true, "prompt hidden");
    76     });
    78   }, true);
    80   info("loading test page: " + testPageURL);
    81   content.location = testPageURL + "?v=5";
    82 }
    84 function test2()
    85 {
    86   gBrowser.selectedTab = gBrowser.addTab();
    88   gBrowser.selectedBrowser.addEventListener("load", function () {
    89     gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
    91     let seenPopup;
    92     let addMoreCount = 0;
    93     let lastResult;
    95     setFinishedCallback(function(result) {
    96       is(result, "ready", "Got 'ready' result");
    97       is(getPermission(testPageURL, "indexedDB-unlimited"),
    98          Components.interfaces.nsIPermissionManager.DENY_ACTION,
    99          "Correct permission set");
   101       setFinishedCallback(function(result) {
   102         info("Got '" + result + "' result");
   103         lastResult = result;
   104         ok(!seenPopup, "No popup");
   105         is(getPermission(testPageURL, "indexedDB-unlimited"),
   106            Components.interfaces.nsIPermissionManager.DENY_ACTION,
   107            "Correct permission set");
   109         if (addMoreCount > addMoreTest1Count + 5) {
   110           setFinishedCallback(function(result) {
   111             is(result, "finished", "Got 'finished' result");
   112             is(lastResult, "abort QuotaExceededError", "Aborted as expected");
   113             ok(!seenPopup, "No popup");
   114             is(getPermission(testPageURL, "indexedDB-unlimited"),
   115                Components.interfaces.nsIPermissionManager.DENY_ACTION,
   116                "Correct permission set");
   118             gBrowser.removeCurrentTab();
   119             unregisterAllPopupEventHandlers();
   120             removePermission(testPageURL, "indexedDB");
   121             Services.prefs.clearUserPref("dom.indexedDB.warningQuota");
   122             executeSoon(finish);
   123           });
   124           executeSoon(function() { dispatchEvent("indexedDB-done"); });
   125         }
   126         else {
   127           ++addMoreCount;
   128           executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
   129         }
   130       });
   131       ++addMoreCount;
   132       executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
   133     });
   135     registerPopupEventHandler("popupshowing", function () {
   136       ok(false, "Shouldn't show a popup this time");
   137       seenPopup = true;
   138     });
   139     registerPopupEventHandler("popupshown", function () {
   140       ok(false, "Shouldn't show a popup this time");
   141     });
   142     registerPopupEventHandler("popuphidden", function () {
   143       ok(false, "Shouldn't show a popup this time");
   144     });
   146   }, true);
   148   info("loading test page: " + testPageURL);
   149   content.location = testPageURL + "?v=7";
   150 }

mercurial