dom/indexedDB/test/browser_quotaPromptAllow.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.

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-1.example.com/browser/" +
michael@0 8 "dom/indexedDB/test/browser_quotaPrompt.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 executeSoon(finish);
michael@0 47 });
michael@0 48 executeSoon(function() { dispatchEvent("indexedDB-done"); });
michael@0 49 }
michael@0 50 else {
michael@0 51 ++addMoreTest1Count;
michael@0 52 executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
michael@0 53 }
michael@0 54 });
michael@0 55 ++addMoreTest1Count;
michael@0 56 executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
michael@0 57 });
michael@0 58
michael@0 59 registerPopupEventHandler("popupshowing", function () {
michael@0 60 ok(true, "prompt showing");
michael@0 61 seenPopupCount = addMoreTest1Count;
michael@0 62 });
michael@0 63 registerPopupEventHandler("popupshown", function () {
michael@0 64 ok(true, "prompt shown");
michael@0 65 triggerMainCommand(this);
michael@0 66 });
michael@0 67 registerPopupEventHandler("popuphidden", function () {
michael@0 68 ok(true, "prompt hidden");
michael@0 69 });
michael@0 70
michael@0 71 }, true);
michael@0 72
michael@0 73 info("loading test page: " + testPageURL);
michael@0 74 content.location = testPageURL + "?v=1";
michael@0 75 }
michael@0 76
michael@0 77 function test2()
michael@0 78 {
michael@0 79 gBrowser.selectedTab = gBrowser.addTab();
michael@0 80
michael@0 81 gBrowser.selectedBrowser.addEventListener("load", function () {
michael@0 82 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
michael@0 83
michael@0 84 let seenPopup;
michael@0 85 let addMoreCount = 0;
michael@0 86
michael@0 87 setFinishedCallback(function(result) {
michael@0 88 is(result, "ready", "Got 'ready' result");
michael@0 89 is(getPermission(testPageURL, "indexedDB-unlimited"),
michael@0 90 Components.interfaces.nsIPermissionManager.ALLOW_ACTION,
michael@0 91 "Correct permission set");
michael@0 92
michael@0 93 setFinishedCallback(function(result) {
michael@0 94 is(result, "complete", "Got 'complete' result");
michael@0 95 ok(!seenPopup, "No popup");
michael@0 96 is(getPermission(testPageURL, "indexedDB-unlimited"),
michael@0 97 Components.interfaces.nsIPermissionManager.ALLOW_ACTION,
michael@0 98 "Correct permission set");
michael@0 99
michael@0 100 if (addMoreCount > addMoreTest1Count + 5) {
michael@0 101 setFinishedCallback(function(result) {
michael@0 102 is(result, "finished", "Got 'finished' result");
michael@0 103 ok(!seenPopup, "No popup");
michael@0 104 is(getPermission(testPageURL, "indexedDB-unlimited"),
michael@0 105 Components.interfaces.nsIPermissionManager.ALLOW_ACTION,
michael@0 106 "Correct permission set");
michael@0 107
michael@0 108 gBrowser.removeCurrentTab();
michael@0 109 unregisterAllPopupEventHandlers();
michael@0 110 removePermission(testPageURL, "indexedDB");
michael@0 111 Services.prefs.clearUserPref("dom.indexedDB.warningQuota");
michael@0 112 PopupNotifications.transitionsEnabled = true;
michael@0 113 executeSoon(finish);
michael@0 114 });
michael@0 115 executeSoon(function() { dispatchEvent("indexedDB-done"); });
michael@0 116 }
michael@0 117 else {
michael@0 118 ++addMoreCount;
michael@0 119 executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
michael@0 120 }
michael@0 121 });
michael@0 122 ++addMoreCount;
michael@0 123 executeSoon(function() { dispatchEvent("indexedDB-addMore"); });
michael@0 124 });
michael@0 125
michael@0 126 registerPopupEventHandler("popupshowing", function () {
michael@0 127 ok(false, "Shouldn't show a popup this time");
michael@0 128 seenPopup = true;
michael@0 129 });
michael@0 130 registerPopupEventHandler("popupshown", function () {
michael@0 131 ok(false, "Shouldn't show a popup this time");
michael@0 132 });
michael@0 133 registerPopupEventHandler("popuphidden", function () {
michael@0 134 ok(false, "Shouldn't show a popup this time");
michael@0 135 });
michael@0 136
michael@0 137 }, true);
michael@0 138
michael@0 139 info("loading test page: " + testPageURL);
michael@0 140 content.location = testPageURL + "?v=3";
michael@0 141 }

mercurial