WebSQL: User cannot grant quota increase if the JS provides an expected usage value...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Sep 2018 19:59:40 +0000 (19:59 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Sep 2018 19:59:40 +0000 (19:59 +0000)
commitb1b77d34fcc65901e5fc64da54e911ceee3d7e92
treed350d00f0f425e134aece2af29f30dbdbc15dd84
parent65718d3aaf61724b10d067b6a4ea5e6daa50ce14
WebSQL: User cannot grant quota increase if the JS provides an expected usage value that is too low
https://bugs.webkit.org/show_bug.cgi?id=189801
<rdar://problem/43592498>

Reviewed by Youenn Fablet.

Source/WebCore:

User was unable to grant a quota increase for WebSQL if the JS provided an expected usage value that
is too low. This is because WebKit was passing this provided expectedUsage value to the client for
the purpose of quota increase, even when this expectedUsage value does not make any sense (i.e. it
is lower than the current database size). As a result, the client would grant a quota that is equal
to the previous quota and the JS would not be able to insert any data.

In order to address the issue, when the current quota is exceeded and Database::didExceedQuota()
is called, we now make sure that the expectedUsage value is greater than the current quota. If it
is not, we provide `current quota + 5MB` as expected usage to the client. This way, the client will
grant a quota that is actually increased (provided that the user accepts).

Test: storage/websql/transaction-database-expand-quota.html

* Modules/webdatabase/Database.cpp:
(WebCore::Database::setEstimatedSize):
(WebCore::Database::didExceedQuota):
* Modules/webdatabase/Database.h:

LayoutTests:

Add layout test coverage.

* storage/websql/transaction-database-expand-quota-expected.txt: Added.
* storage/websql/transaction-database-expand-quota.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236348 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/storage/websql/transaction-database-expand-quota-expected.txt [new file with mode: 0644]
LayoutTests/storage/websql/transaction-database-expand-quota.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/webdatabase/Database.cpp
Source/WebCore/Modules/webdatabase/Database.h
Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp
Source/WebCore/Modules/webdatabase/DatabaseTracker.h