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