Commit 98b3b582 authored by joepeck@webkit.org's avatar joepeck@webkit.org
Browse files

ApplicationCache update should not immediately fail when reaching per-origin quota

https://bugs.webkit.org/show_bug.cgi?id=64177

Reviewed by Alexey Proskuryakov.

2011-07-12  Joseph Pecoraro  <joepeck@webkit.org>

        Include spaceNeeded information in the output dumped for appcache quota delegates.
        Add and update tests related to handling of per-origin quotas.

        * http/tests/appcache/origin-quota-continued-download-expected.txt: Added.
        * http/tests/appcache/origin-quota-continued-download.html: Added.
        * http/tests/appcache/resources/quota-origin-continued-download.html: Added.
        * http/tests/appcache/resources/quota-origin-continued-download.manifest: Added.
        New test which checks that there will still be a successful cache
        when the per-origin quota is reached and increased at the end of downloading.

        * http/tests/appcache/origin-quota-continued-download-multiple-manifests-expected.txt: Added.
        * http/tests/appcache/origin-quota-continued-download-multiple-manifests.html: Added.
        * http/tests/appcache/resources/quota-origin-continued-download-multiple-manifests-1.html: Added.
        * http/tests/appcache/resources/quota-origin-continued-download-multiple-manifests-1.manifest: Added.
        * http/tests/appcache/resources/quota-origin-continued-download-multiple-manifests-2.html: Added.
        * http/tests/appcache/resources/quota-origin-continued-download-multiple-manifests-2.manifest: Added.
        * http/tests/appcache/resources/quota-origin-continued-download.html: Added.
        * http/tests/appcache/resources/quota-origin-continued-download.manifest: Added.
        New test which checks that the spaceNeeded appropriately lists enough space for
        multiple manifests across multiple frames for the same origin.

        * http/tests/appcache/resources/quota-origin-iframe-3.manifest: Fix a typo.
        * http/tests/appcache/origin-quota.html:
        Update the old test to disallow automatic increase of the quota,
        which is the default handling of DRT when reaching the quota.

        * platform/chromium/test_expectations.txt:
        * platform/gtk/Skipped:
        * platform/qt/Skipped:
        * platform/win/Skipped:
        * platform/wk2/Skipped:
        Skip the test on ports that don't implement ApplicationCache per-origin quotas.

2011-07-12  Joseph Pecoraro  <joepeck@webkit.org>

        New behavior of handling ApplicationCache per-origin quotas. Previously,
        if the quota was reached while downloading we would fail the download
        and then prompt the user for a storage increase. This required a refresh,
        a redownload of resources, and the total storage was not known so the
        process could be repeated multiple times before an acceptable quota
        was found or the user disallowed an increase.

        The new behavior is to complete the download of the entire appcache.
        When the cache completes downloading and it is greater than the origin
        quota, prompt the user to allow a quota increase with the known space
        needed. If the quota is increased, the cache will succeed, otherwise
        it will fail with the normal failure steps.

        An alternative behavior is prompting while downloading immediately
        when the origin quota is reached, however at that point the entire
        space needed is unknown and so quota increases might not be enough
        and could result in multiple prompts to the user.

        Tests: http/tests/appcache/origin-quota-continued-download-multiple-manifests.html
               http/tests/appcache/origin-quota-continued-download.html

        * loader/appcache/ApplicationCacheGroup.h:
        * loader/appcache/ApplicationCacheGroup.cpp:
        (WebCore::ApplicationCacheGroup::ApplicationCacheGroup):
        Rename instance variable to be more clear on its intent.

        (WebCore::ApplicationCacheGroup::didFinishLoading):
        Check the quota limit while downloading so we can fail early
        if the user already denied a quota increase.

        (WebCore::ApplicationCacheGroup::didReachOriginQuota):
        Pass the space needed information to the chrome client.

        (WebCore::ApplicationCacheGroup::cacheUpdateFailedDueToOriginQuota):
        Removed. Instead convert the callers to update state and console
        log when the per-origin quota is reached. This allows us to follow
        the normal failure steps if the quota is reached at the end of a
        download, and the alternative short path when we fail during downloading.

        (WebCore::ApplicationCacheGroup::recalculateAvailableSpaceInQuota):
        Extract to a helper function.

        (WebCore::ApplicationCacheGroup::checkIfLoadIsComplete):
        Allow for a quota increase at the end of the download now that
        we know the space needed. Then proceed to fail or succeed
        as we normally would.

        * loader/appcache/ApplicationCacheStorage.h:
        * loader/appcache/ApplicationCacheStorage.cpp:
        (WebCore::ApplicationCacheStorage::checkOriginQuota):
        (WebCore::ApplicationCacheStorage::storeNewestCache):
        Extract checking the origin quota for when an ApplicationCacheGroup
        will be replacing an ApplicationCacheGroup into a helper function.
        The helper also provides an out parameter for the space needed
        to properly fit the new cache group if it wouldn't fit.

        * page/ChromeClient.h:
        * loader/EmptyClients.h:
        (WebCore::EmptyChromeClient::reachedApplicationCacheOriginQuota):
        Add a space needed parameter when reaching the per-origin quota.

2011-07-12  Joseph Pecoraro  <joepeck@webkit.org>

        * WebView/WebUIDelegatePrivate.h:
        * DefaultDelegates/WebDefaultUIDelegate.m:
        (-[WebDefaultUIDelegate webView:exceededApplicationCacheOriginQuotaForSecurityOrigin:spaceNeeded:]):
        Update the delegate to include a space needed parameter.

        * WebCoreSupport/WebChromeClient.h:
        * WebCoreSupport/WebChromeClient.mm:
        (WebChromeClient::reachedApplicationCacheOriginQuota):
        Call the delegate with the new space needed information.

2011-07-12  Joseph Pecoraro  <joepeck@webkit.org>

        * Api/qwebpage.cpp:
        * Api/qwebpage.h:
        * WebCoreSupport/ChromeClientQt.cpp:
        (WebCore::ChromeClientQt::reachedApplicationCacheOriginQuota):
        * WebCoreSupport/ChromeClientQt.h:
        Pass the spaceNeeded value through to the applicationCacheQuotaExceeded signal.

2011-07-12  Joseph Pecoraro  <joepeck@webkit.org>

        Add layoutTestController.disallowIncreaseForApplicationCacheQuota()
        to disable the default behavior of raising the default per-origin
        quota to 5MB when reached. This allows us to test what happens
        when the quota is reached and not increased.

        * DumpRenderTree/LayoutTestController.cpp:
        (LayoutTestController::LayoutTestController):
        (disallowIncreaseForApplicationCacheQuotaCallback):
        (LayoutTestController::staticFunctions):
        * DumpRenderTree/LayoutTestController.h:
        (LayoutTestController::disallowIncreaseForApplicationCacheQuota):
        (LayoutTestController::setDisallowIncreaseForApplicationCacheQuota):
        * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
        (LayoutTestController::reset):
        * DumpRenderTree/qt/LayoutTestControllerQt.h:
        (LayoutTestController::disallowIncreaseForApplicationCacheQuota):
        (LayoutTestController::dumpApplicationCacheDelegateCallbacks):
        Expose a function to prevent automatically increasing the per-origin
        quota when the quota is reached. This allows us to test what happens
        when a user would "disallow" a quota increase.

        * DumpRenderTree/mac/UIDelegate.mm:
        (-[UIDelegate webView:exceededApplicationCacheOriginQuotaForSecurityOrigin:spaceNeeded:]):
        * DumpRenderTree/qt/DumpRenderTreeQt.cpp:
        (WebCore::DumpRenderTree::dumpApplicationCacheQuota):
        Respect the new disallowIncrease flag and dump the spaceNeeded values
        for ports that implement application cache quotas.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@90856 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6621a3ef
2011-07-12 Joseph Pecoraro <joepeck@webkit.org>
ApplicationCache update should not immediately fail when reaching per-origin quota
https://bugs.webkit.org/show_bug.cgi?id=64177
Reviewed by Alexey Proskuryakov.
Include spaceNeeded information in the output dumped for appcache quota delegates.
Add and update tests related to handling of per-origin quotas.
* http/tests/appcache/origin-quota-continued-download-expected.txt: Added.
* http/tests/appcache/origin-quota-continued-download.html: Added.
* http/tests/appcache/resources/quota-origin-continued-download.html: Added.
* http/tests/appcache/resources/quota-origin-continued-download.manifest: Added.
New test which checks that there will still be a successful cache
when the per-origin quota is reached and increased at the end of downloading.
* http/tests/appcache/origin-quota-continued-download-multiple-manifests-expected.txt: Added.
* http/tests/appcache/origin-quota-continued-download-multiple-manifests.html: Added.
* http/tests/appcache/resources/quota-origin-continued-download-multiple-manifests-1.html: Added.
* http/tests/appcache/resources/quota-origin-continued-download-multiple-manifests-1.manifest: Added.
* http/tests/appcache/resources/quota-origin-continued-download-multiple-manifests-2.html: Added.
* http/tests/appcache/resources/quota-origin-continued-download-multiple-manifests-2.manifest: Added.
* http/tests/appcache/resources/quota-origin-continued-download.html: Added.
* http/tests/appcache/resources/quota-origin-continued-download.manifest: Added.
New test which checks that the spaceNeeded appropriately lists enough space for
multiple manifests across multiple frames for the same origin.
* http/tests/appcache/resources/quota-origin-iframe-3.manifest: Fix a typo.
* http/tests/appcache/origin-quota.html:
Update the old test to disallow automatic increase of the quota,
which is the default handling of DRT when reaching the quota.
* platform/chromium/test_expectations.txt:
* platform/gtk/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
* platform/wk2/Skipped:
Skip the test on ports that don't implement ApplicationCache per-origin quotas.
2011-07-12 Pavel Feldman <pfeldman@google.com>
 
Web Inspector: introduce UserMetrics for collecting stats in Chromium port.
UI DELEGATE APPLICATION CACHE CALLBACK: exceededApplicationCacheOriginQuotaForSecurityOrigin:{http, 127.0.0.1, 8000} totalSpaceNeeded:15918
This test checks that per-origin application cache quota don't require a refresh to complete successfully.
This test sets the quota for the origin to 1kb, and attempts to fill it up with more than 1kb of data. The download should complete successfully, with the quota being increased to the default of 5MB. The delegate should be informed for the exceeded quota, increase it to a size large enough, and the download succeed.
PASS - cached iframe
UI DELEGATE APPLICATION CACHE CALLBACK: exceededApplicationCacheOriginQuotaForSecurityOrigin:{http, 127.0.0.1, 8000} totalSpaceNeeded:32001
This test checks that per-origin application cache quota works correctly with multiple manifests/caches per-origin.
This test sets the quota for the origin to 20kb, and attempts to fill it up with 2 different application caches about 15kb each. The first frame will cache successfully and fill up about 15kb of the origin quota. The second frame will reach the quota, cause a delegate callback, dump the spaceNeeded (which should be enough for both iframe caches), and succeed due to the default DRT behavior or raising the quota.
PASS - cached iframe
PASS - cached iframe
<html>
<head>
<script>
// Helpers.
function log(message) {
document.getElementById("console").innerHTML += message + "<br>";
}
// Start and end.
function startTest() {
if (window.layoutTestController) {
layoutTestController.clearAllApplicationCaches();
layoutTestController.dumpApplicationCacheDelegateCallbacks();
layoutTestController.setApplicationCacheOriginQuota(20*1024);
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
addFirstIFrame();
}
function finishTest() {
if (window.layoutTestController)
layoutTestController.notifyDone();
}
// Stages.
function addIFrameWithContinuation(src, continuation) {
window.onmessage = continuation;
var iframe = document.createElement("iframe");
iframe.src = src;
document.body.appendChild(iframe);
}
function addFirstIFrame() {
// Expected to succeed. Will be ~15kb out of the 20kb limit.
addIFrameWithContinuation("resources/quota-origin-continued-download-multiple-manifests-1.html", function(event) {
log(event.data);
addSecondIFrame();
});
}
function addSecondIFrame() {
// Expected to succeed, due to automatically increasing the quota.
addIFrameWithContinuation("resources/quota-origin-continued-download-multiple-manifests-2.html", function(event) {
log(event.data);
finishTest();
});
}
</script>
</head>
<body onload="startTest()">
<p>This test checks that per-origin application cache quota works correctly with multiple manifests/caches per-origin.</p>
<p>
This test sets the quota for the origin to 20kb, and attempts to fill
it up with 2 different application caches about 15kb each.
The first frame will cache successfully and fill up about 15kb of
the origin quota.
The second frame will reach the quota, cause a delegate callback,
dump the spaceNeeded (which should be enough for both iframe caches),
and succeed due to the default DRT behavior or raising the quota.
</p>
<pre id="console"></pre>
</body>
</html>
<html>
<head>
<script>
// Helpers.
function log(message) {
document.getElementById("console").innerHTML += message + "<br>";
}
// Start and end.
function startTest() {
if (window.layoutTestController) {
layoutTestController.clearAllApplicationCaches();
layoutTestController.dumpApplicationCacheDelegateCallbacks();
layoutTestController.setApplicationCacheOriginQuota(1024);
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
addIFrame();
}
function finishTest() {
if (window.layoutTestController)
layoutTestController.notifyDone();
}
// Stages.
function addIFrameWithContinuation(src, continuation) {
window.onmessage = continuation;
var iframe = document.createElement("iframe");
iframe.src = src;
document.body.appendChild(iframe);
}
function addIFrame() {
// Expected to succeed. Default handling will raise the quota back up to 5MB which is enough.
addIFrameWithContinuation("resources/quota-origin-continued-download.html", function(event) {
log(event.data);
finishTest();
});
}
</script>
</head>
<body onload="startTest()">
<p>This test checks that per-origin application cache quota don't require a refresh to complete successfully.</p>
<p>
This test sets the quota for the origin to 1kb, and attempts to fill
it up with more than 1kb of data. The download should complete
successfully, with the quota being increased to the default of 5MB. The
delegate should be informed for the exceeded quota, increase it to a size
large enough, and the download succeed.
</p>
<pre id="console"></pre>
</body>
</html>
UI DELEGATE APPLICATION CACHE CALLBACK: exceededApplicationCacheOriginQuotaForSecurityOrigin:{http, 127.0.0.1, 8000}
UI DELEGATE APPLICATION CACHE CALLBACK: exceededApplicationCacheOriginQuotaForSecurityOrigin:{http, 127.0.0.1, 8000} spaceNeeded:31161
CONSOLE MESSAGE: line 0: Application Cache update failed, because size quota was exceeded.
This test checks that per-origin application cache quotas are enforced.
......
......@@ -14,6 +14,7 @@ function startTest() {
if (window.layoutTestController) {
layoutTestController.clearAllApplicationCaches();
layoutTestController.dumpApplicationCacheDelegateCallbacks();
layoutTestController.disallowIncreaseForApplicationCacheQuota();
layoutTestController.setApplicationCacheOriginQuota(20*1024);
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
......@@ -46,9 +47,9 @@ function addFirstIFrame() {
function addSecondIFrame() {
// Expected to fail, then increase the quota.
// NOTE: When this fails, the exceed callback will automatically increase it back to the default quota size.
addIFrameWithContinuation("resources/quota-origin-iframe-2.html", function(event) {
log(event.data);
layoutTestController.setApplicationCacheOriginQuota(100*1024);
addThirdIFrame();
});
}
......
<html manifest="quota-origin-continued-download-multiple-manifests-1.manifest">
<script>
// This is expected to succeed.
applicationCache.oncached = function() { parent.postMessage("PASS - cached iframe", "*"); };
applicationCache.onerror = function() { parent.postMessage("FAIL - error caching iframe, expected this to succeed by fitting in the quota", "*"); };
applicationCache.onupdateready = function() { parent.postMessage("FAIL - update ready, all caches should have been deleted before this test", "*"); };
applicationCache.onnoupdate = function() { parent.postMessage("FAIL - no update iframe, all caches should have been deleted before this test", "*"); };
</script>
</html>
CACHE MANIFEST
# This should succeed. This is ~15kb and the quota should be 20kb.
CACHE:
abe.png
<html manifest="quota-origin-continued-download-multiple-manifests-2.manifest">
<script>
// This is expected to fail with "spaceNeeded" large enough for both manifest 1 and 2.
applicationCache.oncached = function() { parent.postMessage("PASS - cached iframe", "*"); };
applicationCache.onerror = function() { parent.postMessage("FAIL - error caching iframe, expected this to succeed by fitting in the quota", "*"); };
applicationCache.onupdateready = function() { parent.postMessage("FAIL - update ready, all caches should have been deleted before this test", "*"); };
applicationCache.onnoupdate = function() { parent.postMessage("FAIL - no update iframe, all caches should have been deleted before this test", "*"); };
</script>
</html>
CACHE MANIFEST
# This should succeed. This is another ~15kb and the quota should be 20kb
# and automatically be increased.
# This should trigger a delegate callback and the spaceNeeded should be
# large enough for both caches.
CACHE:
abe.png
<html manifest="quota-origin-continued-download.manifest">
<script>
// This is expected to succeed when the quota is reached, download completes, the user is prompted, and they increase storage.
applicationCache.oncached = function() { parent.postMessage("PASS - cached iframe", "*"); };
applicationCache.onerror = function() { parent.postMessage("FAIL - error caching iframe, expected this to succeed with the quota increased automatically", "*"); };
applicationCache.onupdateready = function() { parent.postMessage("FAIL - update ready, all caches should have been deleted before this test", "*"); };
applicationCache.onnoupdate = function() { parent.postMessage("FAIL - no update iframe, all caches should have been deleted before this test", "*"); };
</script>
</html>
CACHE MANIFEST
# This should succeed. The quota will be reached, but the delegate
# will fire at the end, allowing an increase, and then successfully
# cache with the new quota.
CACHE:
abe.png
CACHE MANIFEST
# iframe-3 should succeed. The origin quota shuld have been
# iframe-3 should succeed. The origin quota should have been
# raised to 40kb, with ~13kb already cached. Caching abe.png
# and this manifest will be ~13kb, bringing us up to 26kb.
......
......@@ -2141,8 +2141,10 @@ BUGCR49970 : platform/chromium/plugins/call-as-function.html = PASS TEXT
// Flaky since WebKit r63994
BUGWK42964 WIN LINUX : tables/mozilla_expected_failures/bugs/bug89315.html = PASS FAIL
// Application Cache Quotas
BUGWK43459 : http/tests/appcache/origin-quota.html = TEXT MISSING
// Application Cache Quotas are N/A to the chromium port.
BUGWK43459 WONTFIX: http/tests/appcache/origin-quota.html = TEXT MISSING
BUGWK43459 WONTFIX: http/tests/appcache/origin-quota-continued-download.html = TEXT MISSING
BUGWK43459 WONTFIX: http/tests/appcache/origin-quota-continued-download-multiple-manifests.html = TEXT MISSING
// Need to support DeviceMotion.
BUGCR51416 : fast/dom/DeviceMotion/window-property.html = TEXT
......
......@@ -584,6 +584,8 @@ fast/js/i18n-bindings-locale.html
http/tests/appcache/crash-when-navigating-away-then-back.html
http/tests/appcache/fallback.html
http/tests/appcache/origin-quota.html
http/tests/appcache/origin-quota-continued-download.html
http/tests/appcache/origin-quota-continued-download-multiple-manifests.html
http/tests/appcache/origin-delete.html
http/tests/appcache/origins-with-appcache.html
# LayoutTestController::applicationCacheDiskUsageForOrigin isn't implemented - https://bugs.webkit.org/show_bug.cgi?id=57127
......
......@@ -29,7 +29,6 @@
# - failing editing/input tests
# - Failing SVG tests
# - failing animations tests
# - failing application cache quota tests
# - Failing CSS Tests
# - Failing dom/xhtml tests
# - Failing editing/deleting tests
......
......@@ -1144,6 +1144,8 @@ perf/
# Application Cache Quotas
# https://bugs.webkit.org/show_bug.cgi?id=43458
http/tests/appcache/origin-quota.html
http/tests/appcache/origin-quota-continued-download.html
http/tests/appcache/origin-quota-continued-download-multiple-manifests.html
# https://bugs.webkit.org/show_bug.cgi?id=43332
inspector/debugger/dom-breakpoints.html
......
......@@ -1656,6 +1656,8 @@ http/tests/appcache/update-cache.html
# WebKitTestRunner needs layoutTestController.clearAllApplicationCaches
http/tests/appcache/origin-delete.html
http/tests/appcache/origin-quota.html
http/tests/appcache/origin-quota-continued-download.html
http/tests/appcache/origin-quota-continued-download-multiple-manifests.html
http/tests/appcache/origins-with-appcache.html
# WebKitTestRunner needs layoutTestController.callShouldCloseOnWebView
......
2011-07-12 Joseph Pecoraro <joepeck@webkit.org>
ApplicationCache update should not immediately fail when reaching per-origin quota
https://bugs.webkit.org/show_bug.cgi?id=64177
Reviewed by Alexey Proskuryakov.
New behavior of handling ApplicationCache per-origin quotas. Previously,
if the quota was reached while downloading we would fail the download
and then prompt the user for a storage increase. This required a refresh,
a redownload of resources, and the total storage was not known so the
process could be repeated multiple times before an acceptable quota
was found or the user disallowed an increase.
The new behavior is to complete the download of the entire appcache.
When the cache completes downloading and it is greater than the origin
quota, prompt the user to allow a quota increase with the known space
needed. If the quota is increased, the cache will succeed, otherwise
it will fail with the normal failure steps.
An alternative behavior is prompting while downloading immediately
when the origin quota is reached, however at that point the entire
space needed is unknown and so quota increases might not be enough
and could result in multiple prompts to the user.
Tests: http/tests/appcache/origin-quota-continued-download-multiple-manifests.html
http/tests/appcache/origin-quota-continued-download.html
* loader/appcache/ApplicationCacheGroup.h:
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::ApplicationCacheGroup):
Rename instance variable to be more clear on its intent.
(WebCore::ApplicationCacheGroup::didFinishLoading):
Check the quota limit while downloading so we can fail early
if the user already denied a quota increase.
(WebCore::ApplicationCacheGroup::didReachOriginQuota):
Pass the space needed information to the chrome client.
(WebCore::ApplicationCacheGroup::cacheUpdateFailedDueToOriginQuota):
Removed. Instead convert the callers to update state and console
log when the per-origin quota is reached. This allows us to follow
the normal failure steps if the quota is reached at the end of a
download, and the alternative short path when we fail during downloading.
(WebCore::ApplicationCacheGroup::recalculateAvailableSpaceInQuota):
Extract to a helper function.
(WebCore::ApplicationCacheGroup::checkIfLoadIsComplete):
Allow for a quota increase at the end of the download now that
we know the space needed. Then proceed to fail or succeed
as we normally would.
* loader/appcache/ApplicationCacheStorage.h:
* loader/appcache/ApplicationCacheStorage.cpp:
(WebCore::ApplicationCacheStorage::checkOriginQuota):
(WebCore::ApplicationCacheStorage::storeNewestCache):
Extract checking the origin quota for when an ApplicationCacheGroup
will be replacing an ApplicationCacheGroup into a helper function.
The helper also provides an out parameter for the space needed
to properly fit the new cache group if it wouldn't fit.
* page/ChromeClient.h:
* loader/EmptyClients.h:
(WebCore::EmptyChromeClient::reachedApplicationCacheOriginQuota):
Add a space needed parameter when reaching the per-origin quota.
2011-07-12 Chris Rogers <crogers@google.com>
 
AudioDevice::Stop can close NULL handle.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment