mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 758357: Only show prompt after 50mb of usage for now. Plan is to soon introduce a new service which allows us to remove "old" indexedDB databases and keep a global quota, but for now we simply remove the prompt. r=sicking
This commit is contained in:
parent
32c8d105c1
commit
5eacba0467
@ -354,18 +354,23 @@
|
||||
<label class="permissionLabel" id="permIndexedDBLabel"
|
||||
value="&permIndexedDB;" control="indexedDBRadioGroup"/>
|
||||
<hbox role="group" aria-labelledby="permIndexedDBLabel">
|
||||
<checkbox id="indexedDBDef" command="cmd_indexedDBDef" label="&permAskAlways;"/>
|
||||
<checkbox id="indexedDBDef" command="cmd_indexedDBDef" label="&permUseDefault;"/>
|
||||
<spacer flex="1"/>
|
||||
<vbox pack="center">
|
||||
<label id="indexedDBStatus" control="indexedDBClear"/>
|
||||
</vbox>
|
||||
<button id="indexedDBClear" label="&permClearStorage;"
|
||||
accesskey="&permClearStorage.accesskey;" onclick="onIndexedDBClear();"/>
|
||||
<radiogroup id="indexedDBRadioGroup" orient="horizontal">
|
||||
<radio id="indexedDB#1" command="cmd_indexedDBToggle" label="&permAllow;"/>
|
||||
<!-- Ask and Allow are purposefully reversed here! -->
|
||||
<radio id="indexedDB#1" command="cmd_indexedDBToggle" label="&permAskAlways;"/>
|
||||
<radio id="indexedDB#0" command="cmd_indexedDBToggle" label="&permAllow;"/>
|
||||
<radio id="indexedDB#2" command="cmd_indexedDBToggle" label="&permBlock;"/>
|
||||
</radiogroup>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<spacer flex="1"/>
|
||||
<vbox pack="center">
|
||||
<label id="indexedDBStatus" control="indexedDBClear" hidden="true"/>
|
||||
</vbox>
|
||||
<button id="indexedDBClear" label="&permClearStorage;" hidden="true"
|
||||
accesskey="&permClearStorage.accesskey;" onclick="onIndexedDBClear();"/>
|
||||
</hbox>
|
||||
</vbox>
|
||||
<vbox class="permission" id="permPluginsRow">
|
||||
<label class="permissionLabel" id="permPluginsLabel"
|
||||
|
@ -51,7 +51,7 @@ var gPermObj = {
|
||||
},
|
||||
indexedDB: function getIndexedDBDefaultPermissions()
|
||||
{
|
||||
return BLOCK;
|
||||
return UNKNOWN;
|
||||
},
|
||||
plugins: function getPluginsDefaultPermissions()
|
||||
{
|
||||
@ -149,9 +149,6 @@ function onCheckboxClick(aPartId)
|
||||
var checkbox = document.getElementById(aPartId + "Def");
|
||||
if (checkbox.checked) {
|
||||
permissionManager.remove(gPermURI.host, aPartId);
|
||||
if (aPartId == "indexedDB") {
|
||||
permissionManager.remove(gPermURI.host, "indexedDB-unlimited");
|
||||
}
|
||||
command.setAttribute("disabled", "true");
|
||||
var perm = gPermObj[aPartId]();
|
||||
setRadioState(aPartId, perm);
|
||||
@ -171,7 +168,8 @@ function onRadioClick(aPartId)
|
||||
var id = radioGroup.selectedItem.id;
|
||||
var permission = id.split('#')[1];
|
||||
permissionManager.add(gPermURI, aPartId, permission);
|
||||
if (aPartId == "indexedDB" && permission == BLOCK) {
|
||||
if (aPartId == "indexedDB" &&
|
||||
(permission == ALLOW || permission == BLOCK)) {
|
||||
permissionManager.remove(gPermURI.host, "indexedDB-unlimited");
|
||||
}
|
||||
if (aPartId == "fullscreen" && permission == UNKNOWN) {
|
||||
@ -207,7 +205,6 @@ function onIndexedDBClear()
|
||||
|
||||
var permissionManager = Components.classes[PERMISSION_CONTRACTID]
|
||||
.getService(nsIPermissionManager);
|
||||
permissionManager.remove(gPermURI.host, "indexedDB");
|
||||
permissionManager.remove(gPermURI.host, "indexedDB-unlimited");
|
||||
initIndexedDBRow();
|
||||
}
|
||||
|
@ -29,6 +29,14 @@
|
||||
#define TOPIC_PERMISSIONS_PROMPT "indexedDB-permissions-prompt"
|
||||
#define TOPIC_PERMISSIONS_RESPONSE "indexedDB-permissions-response"
|
||||
|
||||
// This is a little confusing, but our default behavior (UNKNOWN_ACTION) is to
|
||||
// allow access without a prompt. If the "indexedDB" permission is set to
|
||||
// ALLOW_ACTION then we will issue a prompt before allowing access. Otherwise
|
||||
// (DENY_ACTION) we deny access.
|
||||
#define PERMISSION_ALLOWED nsIPermissionManager::UNKNOWN_ACTION
|
||||
#define PERMISSION_DENIED nsIPermissionManager::DENY_ACTION
|
||||
#define PERMISSION_PROMPT nsIPermissionManager::ALLOW_ACTION
|
||||
|
||||
using namespace mozilla;
|
||||
USING_INDEXEDDB_NAMESPACE
|
||||
using namespace mozilla::services;
|
||||
@ -43,40 +51,41 @@ GetIndexedDBPermissions(const nsACString& aASCIIOrigin,
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
if (!Preferences::GetBool(PREF_INDEXEDDB_ENABLED)) {
|
||||
return nsIPermissionManager::DENY_ACTION;
|
||||
return PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
// No window here means chrome access
|
||||
// No window here means chrome access.
|
||||
if (!aWindow) {
|
||||
return nsIPermissionManager::ALLOW_ACTION;
|
||||
return PERMISSION_ALLOWED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptObjectPrincipal> sop(do_QueryInterface(aWindow));
|
||||
NS_ENSURE_TRUE(sop, nsIPermissionManager::DENY_ACTION);
|
||||
|
||||
if (nsContentUtils::IsSystemPrincipal(sop->GetPrincipal())) {
|
||||
return nsIPermissionManager::ALLOW_ACTION;
|
||||
return PERMISSION_ALLOWED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
|
||||
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(webNav);
|
||||
if (loadContext && loadContext->UsePrivateBrowsing()) {
|
||||
// TODO Support private browsing indexedDB?
|
||||
return nsIPermissionManager::DENY_ACTION;
|
||||
NS_WARNING("IndexedDB may not be used while in private browsing mode!");
|
||||
return PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), aASCIIOrigin);
|
||||
NS_ENSURE_SUCCESS(rv, nsIPermissionManager::DENY_ACTION);
|
||||
NS_ENSURE_SUCCESS(rv, PERMISSION_DENIED);
|
||||
|
||||
nsCOMPtr<nsIPermissionManager> permissionManager =
|
||||
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
|
||||
NS_ENSURE_TRUE(permissionManager, nsIPermissionManager::DENY_ACTION);
|
||||
NS_ENSURE_TRUE(permissionManager, PERMISSION_DENIED);
|
||||
|
||||
PRUint32 permission;
|
||||
rv = permissionManager->TestPermission(uri, PERMISSION_INDEXEDDB,
|
||||
&permission);
|
||||
NS_ENSURE_SUCCESS(rv, nsIPermissionManager::DENY_ACTION);
|
||||
NS_ENSURE_SUCCESS(rv, PERMISSION_DENIED);
|
||||
|
||||
return permission;
|
||||
}
|
||||
@ -102,23 +111,22 @@ CheckPermissionsHelper::Run()
|
||||
// process (if we are in the child process, we have already
|
||||
// set the permission when the prompt was shown in the parent, as
|
||||
// we cannot set the permission from the child).
|
||||
if (permission != nsIPermissionManager::UNKNOWN_ACTION &&
|
||||
XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||
if (permission != PERMISSION_PROMPT &&
|
||||
IndexedDatabaseManager::IsMainProcess()) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = NS_NewURI(getter_AddRefs(uri), mASCIIOrigin);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
nsCOMPtr<nsIPermissionManager> permissionManager =
|
||||
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
|
||||
NS_ENSURE_STATE(permissionManager);
|
||||
|
||||
|
||||
rv = permissionManager->Add(uri, PERMISSION_INDEXEDDB, permission,
|
||||
nsIPermissionManager::EXPIRE_NEVER, 0);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
else if (permission == nsIPermissionManager::UNKNOWN_ACTION &&
|
||||
mPromptAllowed) {
|
||||
else if (permission == PERMISSION_PROMPT && mPromptAllowed) {
|
||||
nsCOMPtr<nsIObserverService> obs = GetObserverService();
|
||||
rv = obs->NotifyObservers(static_cast<nsIRunnable*>(this),
|
||||
TOPIC_PERMISSIONS_PROMPT, nsnull);
|
||||
@ -133,15 +141,15 @@ CheckPermissionsHelper::Run()
|
||||
nsCOMPtr<nsIDOMWindow> window;
|
||||
window.swap(mWindow);
|
||||
|
||||
if (permission == nsIPermissionManager::ALLOW_ACTION) {
|
||||
if (permission == PERMISSION_ALLOWED) {
|
||||
IndexedDatabaseManager* mgr = IndexedDatabaseManager::Get();
|
||||
NS_ASSERTION(mgr, "This should never be null!");
|
||||
|
||||
return helper->Dispatch(mgr->IOThread());
|
||||
}
|
||||
|
||||
NS_ASSERTION(permission == nsIPermissionManager::UNKNOWN_ACTION ||
|
||||
permission == nsIPermissionManager::DENY_ACTION,
|
||||
NS_ASSERTION(permission == PERMISSION_PROMPT ||
|
||||
permission == PERMISSION_DENIED,
|
||||
"Unknown permission!");
|
||||
|
||||
helper->SetError(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
|
||||
@ -178,9 +186,27 @@ CheckPermissionsHelper::Observe(nsISupports* aSubject,
|
||||
mHasPrompted = true;
|
||||
|
||||
nsresult rv;
|
||||
mPromptResult = nsDependentString(aData).ToInteger(&rv);
|
||||
PRUint32 promptResult = nsDependentString(aData).ToInteger(&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Have to convert the permission we got from the user to our weird reversed
|
||||
// permission type.
|
||||
switch (promptResult) {
|
||||
case nsIPermissionManager::ALLOW_ACTION:
|
||||
mPromptResult = PERMISSION_ALLOWED;
|
||||
break;
|
||||
case nsIPermissionManager::DENY_ACTION:
|
||||
mPromptResult = PERMISSION_DENIED;
|
||||
break;
|
||||
case nsIPermissionManager::UNKNOWN_ACTION:
|
||||
mPromptResult = PERMISSION_PROMPT;
|
||||
break;
|
||||
|
||||
default:
|
||||
NS_NOTREACHED("Unknown permission type!");
|
||||
mPromptResult = PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
rv = NS_DispatchToCurrentThread(this);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -20,8 +20,8 @@ function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
// Avoids the prompt
|
||||
setPermission(testPageURL1, "indexedDB");
|
||||
setPermission(testPageURL2, "indexedDB");
|
||||
setPermission(testPageURL1, "indexedDB", "unknown");
|
||||
setPermission(testPageURL2, "indexedDB", "unknown");
|
||||
executeSoon(test1);
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ function test3()
|
||||
Components.classes["@mozilla.org/privatebrowsing;1"]
|
||||
.getService(Components.interfaces.nsIPrivateBrowsingService)
|
||||
.removeDataFromDomain(domains[1]);
|
||||
setPermission(testPageURL4, "indexedDB");
|
||||
setPermission(testPageURL4, "indexedDB", "unknown");
|
||||
executeSoon(test4);
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,8 @@ const notificationID = "indexedDB-permissions-prompt";
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
removePermission(testPageURL, "indexedDB");
|
||||
// We want a prompt.
|
||||
setPermission(testPageURL, "indexedDB", "allow");
|
||||
executeSoon(test1);
|
||||
}
|
||||
|
||||
@ -27,7 +28,7 @@ function test1()
|
||||
"First database creation was successful");
|
||||
ok(!exception, "No exception");
|
||||
is(getPermission(testPageURL, "indexedDB"),
|
||||
Components.interfaces.nsIPermissionManager.ALLOW_ACTION,
|
||||
Components.interfaces.nsIPermissionManager.UNKNOWN_ACTION,
|
||||
"Correct permission set");
|
||||
gBrowser.removeCurrentTab();
|
||||
executeSoon(test2);
|
||||
@ -63,7 +64,7 @@ function test2()
|
||||
"First database creation was successful");
|
||||
ok(!exception, "No exception");
|
||||
is(getPermission(testPageURL, "indexedDB"),
|
||||
Components.interfaces.nsIPermissionManager.ALLOW_ACTION,
|
||||
Components.interfaces.nsIPermissionManager.UNKNOWN_ACTION,
|
||||
"Correct permission set");
|
||||
gBrowser.removeCurrentTab();
|
||||
unregisterAllPopupEventHandlers();
|
||||
|
@ -10,7 +10,8 @@ const notificationID = "indexedDB-permissions-prompt";
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
removePermission(testPageURL, "indexedDB");
|
||||
// We want the prompt.
|
||||
setPermission(testPageURL, "indexedDB", "allow");
|
||||
executeSoon(test1);
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,6 @@ const notificationID = "indexedDB-permissions-prompt";
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
// Avoids the actual prompt
|
||||
setPermission(testPageURL, "indexedDB");
|
||||
executeSoon(test1);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@ function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
requestLongerTimeout(10);
|
||||
setPermission(testPageURL, "indexedDB");
|
||||
removePermission(testPageURL, "indexedDB-unlimited");
|
||||
Services.prefs.setIntPref("dom.indexedDB.warningQuota", 2);
|
||||
executeSoon(test1);
|
||||
@ -43,7 +42,7 @@ function test1()
|
||||
"Correct permission set");
|
||||
gBrowser.removeCurrentTab();
|
||||
unregisterAllPopupEventHandlers();
|
||||
executeSoon(test2);
|
||||
executeSoon(finish);
|
||||
});
|
||||
executeSoon(function() { dispatchEvent("indexedDB-done"); });
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
requestLongerTimeout(10);
|
||||
setPermission(testPageURL, "indexedDB");
|
||||
removePermission(testPageURL, "indexedDB-unlimited");
|
||||
Services.prefs.setIntPref("dom.indexedDB.warningQuota", 2);
|
||||
executeSoon(test1);
|
||||
|
@ -12,7 +12,6 @@ function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
requestLongerTimeout(10);
|
||||
setPermission(testPageURL, "indexedDB");
|
||||
removePermission(testPageURL, "indexedDB-unlimited");
|
||||
Services.prefs.setIntPref("dom.indexedDB.warningQuota", 2);
|
||||
executeSoon(test1);
|
||||
|
@ -12,7 +12,6 @@ function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
requestLongerTimeout(10);
|
||||
setPermission(testPageURL, "indexedDB");
|
||||
removePermission(testPageURL, "indexedDB-unlimited");
|
||||
Services.prefs.setIntPref("dom.indexedDB.warningQuota", 2);
|
||||
executeSoon(test1);
|
||||
|
@ -49,8 +49,6 @@
|
||||
};
|
||||
|
||||
function testSteps() {
|
||||
window.parent.SpecialPowers.addPermission("indexedDB", true, document);
|
||||
|
||||
let request = indexedDB.open(window.location.pathname, 1);
|
||||
request.onsuccess = unexpectedSuccessHandler;
|
||||
request.onerror = grabEventAndContinueHandler;
|
||||
|
@ -87,8 +87,6 @@
|
||||
}
|
||||
|
||||
function testSteps() {
|
||||
window.parent.SpecialPowers.addPermission("indexedDB", true, document);
|
||||
|
||||
let request = indexedDB.open(window.location.pathname, 1);
|
||||
request.onerror = errorHandler;
|
||||
request.onupgradeneeded = grabEventAndContinueHandler;
|
||||
|
@ -51,8 +51,6 @@
|
||||
};
|
||||
|
||||
function testSteps() {
|
||||
window.parent.SpecialPowers.addPermission("indexedDB", true, document);
|
||||
|
||||
// Test 1: Throwing an exception in an upgradeneeded handler should
|
||||
// abort the versionchange transaction and fire an error at the request.
|
||||
let request = indexedDB.open(window.location.pathname, 1);
|
||||
|
@ -102,15 +102,30 @@ function dispatchEvent(eventName)
|
||||
gBrowser.selectedBrowser.contentWindow.dispatchEvent(event);
|
||||
}
|
||||
|
||||
function setPermission(url, permission)
|
||||
function setPermission(url, permission, value)
|
||||
{
|
||||
const nsIPermissionManager = Components.interfaces.nsIPermissionManager;
|
||||
|
||||
switch (value) {
|
||||
case "allow":
|
||||
value = nsIPermissionManager.ALLOW_ACTION;
|
||||
break;
|
||||
case "deny":
|
||||
value = nsIPermissionManager.DENY_ACTION;
|
||||
break;
|
||||
case "unknown":
|
||||
value = nsIPermissionManager.UNKNOWN_ACTION;
|
||||
break;
|
||||
default:
|
||||
throw new Error("No idea what to set here!");
|
||||
}
|
||||
|
||||
let uri = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService)
|
||||
.newURI(url, null, null);
|
||||
Components.classes["@mozilla.org/permissionmanager;1"]
|
||||
.getService(Components.interfaces.nsIPermissionManager)
|
||||
.add(uri, permission,
|
||||
Components.interfaces.nsIPermissionManager.ALLOW_ACTION);
|
||||
.add(uri, permission, value);
|
||||
}
|
||||
|
||||
function removePermission(url, permission)
|
||||
|
@ -53,7 +53,6 @@ if (!window.runTest) {
|
||||
{
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
allowIndexedDB();
|
||||
if (limitedQuota) {
|
||||
denyUnlimitedQuota();
|
||||
}
|
||||
@ -68,12 +67,10 @@ if (!window.runTest) {
|
||||
function finishTest()
|
||||
{
|
||||
resetUnlimitedQuota();
|
||||
resetIndexedDB();
|
||||
|
||||
SimpleTest.executeSoon(function() {
|
||||
testGenerator.close();
|
||||
//clearAllDatabases(function() { SimpleTest.finish(); });
|
||||
SimpleTest.finish();
|
||||
clearAllDatabases(function() { SimpleTest.finish(); });
|
||||
});
|
||||
}
|
||||
|
||||
@ -190,16 +187,6 @@ function setQuota(quota)
|
||||
SpecialPowers.setIntPref("dom.indexedDB.warningQuota", quota);
|
||||
}
|
||||
|
||||
function allowIndexedDB(url)
|
||||
{
|
||||
addPermission("indexedDB", true, url);
|
||||
}
|
||||
|
||||
function resetIndexedDB(url)
|
||||
{
|
||||
removePermission("indexedDB", url);
|
||||
}
|
||||
|
||||
function allowUnlimitedQuota(url)
|
||||
{
|
||||
addPermission("indexedDB-unlimited", true, url);
|
||||
|
@ -62,9 +62,6 @@
|
||||
|
||||
function runTest() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
SpecialPowers.addPermission("indexedDB", true, document);
|
||||
|
||||
window.addEventListener("message", messageListener, false);
|
||||
setiframe();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user