[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

joepeck at webkit.org joepeck at webkit.org
Wed Dec 22 11:41:45 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 0539bdbd96373714d3a329cc895c2bbe5dc5df14
Author: joepeck at webkit.org <joepeck at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Aug 4 01:50:29 2010 +0000

    2010-08-03  Joseph Pecoraro  <joepeck at webkit.org>
    
    Reviewed by David Kilzer.
    
    LayoutTests:
    
        2010-08-03  Joseph Pecoraro  <joepeck at webkit.org>
    
                Limit ApplicationCache Total and Per-Origin Storage Capacity (Quotas)
                https://bugs.webkit.org/show_bug.cgi?id=40627
    
                Part 6 - LayoutTest and Cleanup
    
                * http/tests/appcache/origin-quota-expected.txt: Added.
                * http/tests/appcache/origin-quota.html: Added.
                * http/tests/appcache/resources/quota-origin-iframe-1.html: Added.
                * http/tests/appcache/resources/quota-origin-iframe-1.manifest: Added.
                * http/tests/appcache/resources/quota-origin-iframe-2.html: Added.
                * http/tests/appcache/resources/quota-origin-iframe-2.manifest: Added.
                * http/tests/appcache/resources/quota-origin-iframe-3.html: Added.
                * http/tests/appcache/resources/quota-origin-iframe-3.manifest: Added.
    
    WebCore:
    
        2010-08-03  Joseph Pecoraro  <joepeck at webkit.org>
    
                Limit ApplicationCache Total and Per-Origin Storage Capacity (Quotas)
                https://bugs.webkit.org/show_bug.cgi?id=40627
    
                Part 6 - LayoutTest and Cleanup
    
                Test: http/tests/appcache/origin-quota.html
    
                * loader/appcache/ApplicationCacheGroup.cpp:
                (WebCore::ApplicationCacheGroup::scheduleReachedOriginQuotaCallback): made synchronous, as asynchronously the cache group was deleted too soon.
                * loader/appcache/ApplicationCacheStorage.cpp:
                (WebCore::ApplicationCacheStorage::storeUpdatedQuotaForOrigin): all storing operations should force the database to be created if needed.
    
    WebKit/mac:
    
        2010-08-03  Joseph Pecoraro  <joepeck at webkit.org>
    
                Part 6 - LayoutTest and Cleanup
    
                * WebCoreSupport/WebApplicationCache.h:
                * WebCoreSupport/WebApplicationCache.mm:
                (+[WebApplicationCache setMaximumSize:]): refactor out deleting the application caches.
                (+[WebApplicationCache deleteAllApplicationCaches]): delete application caches.
    
                Limit ApplicationCache Total and Per-Origin Storage Capacity (Quotas)
                https://bugs.webkit.org/show_bug.cgi?id=40627
    
    WebKitTools:
    
        2010-08-03  Joseph Pecoraro  <joepeck at webkit.org>
    
                Part 6 - LayoutTest and Cleanup
    
                  Allow tests to delete application caches and set application cache
                  origin quotas, so they can be tested.
    
                * DumpRenderTree/LayoutTestController.cpp:
                (LayoutTestController::LayoutTestController):
                (dumpApplicationCacheDelegateCallbacksCallback): JavaScript callback, delegates to the controller.
                (clearAllApplicationCachesCallback): should delete all application caches.
                (setApplicationCacheOriginQuotaCallback): should set the origin quota for the localhost tests.
                (LayoutTestController::staticFunctions):
                * DumpRenderTree/LayoutTestController.h:
                (LayoutTestController::dumpApplicationCacheDelegateCallbacks): accessor to see if application cache callbacks should be output.
                (LayoutTestController::setDumpApplicationCacheDelegateCallbacks): enable or disable debug output when the application cache quota is reached.
    
                  Mac implementation.
    
                * DumpRenderTree/mac/LayoutTestControllerMac.mm:
                (LayoutTestController::clearAllApplicationCaches): delete application caches.
                (LayoutTestController::setApplicationCacheOriginQuota): set the quota for localhost.
                * DumpRenderTree/mac/UIDelegate.mm:
                (-[UIDelegate webView:frame:exceededDatabaseQuotaForSecurityOrigin:database:]): style fix.
                (-[UIDelegate webView:exceededApplicationCacheOriginQuotaForSecurityOrigin:]): reset the quota.
    
                  Stub implementations for other platforms.
    
                * DumpRenderTree/chromium/LayoutTestController.cpp:
                (LayoutTestController::LayoutTestController):
                (LayoutTestController::clearAllApplicationCaches):
                (LayoutTestController::setApplicationCacheOriginQuota):
                * DumpRenderTree/chromium/LayoutTestController.h:
                * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
                (LayoutTestController::clearAllApplicationCaches):
                (LayoutTestController::setApplicationCacheOriginQuota):
                * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
                (LayoutTestController::clearAllApplicationCaches):
                (LayoutTestController::setApplicationCacheOriginQuota):
                * DumpRenderTree/qt/LayoutTestControllerQt.h:
                * DumpRenderTree/win/LayoutTestControllerWin.cpp:
                (LayoutTestController::clearAllApplicationCaches):
                (LayoutTestController::setApplicationCacheOriginQuota):
                * DumpRenderTree/wx/LayoutTestControllerWx.cpp:
                (LayoutTestController::clearAllApplicationCaches):
                (LayoutTestController::setApplicationCacheOriginQuota):
    
                Limit ApplicationCache Total and Per-Origin Storage Capacity (Quotas)
                https://bugs.webkit.org/show_bug.cgi?id=40627
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64613 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 89c222e..25c3352 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,21 @@
+2010-08-03  Joseph Pecoraro  <joepeck at webkit.org>
+
+        Reviewed by David Kilzer.
+
+        Limit ApplicationCache Total and Per-Origin Storage Capacity (Quotas)
+        https://bugs.webkit.org/show_bug.cgi?id=40627
+
+        Part 6 - LayoutTest and Cleanup
+
+        * http/tests/appcache/origin-quota-expected.txt: Added.
+        * http/tests/appcache/origin-quota.html: Added.
+        * http/tests/appcache/resources/quota-origin-iframe-1.html: Added.
+        * http/tests/appcache/resources/quota-origin-iframe-1.manifest: Added.
+        * http/tests/appcache/resources/quota-origin-iframe-2.html: Added.
+        * http/tests/appcache/resources/quota-origin-iframe-2.manifest: Added.
+        * http/tests/appcache/resources/quota-origin-iframe-3.html: Added.
+        * http/tests/appcache/resources/quota-origin-iframe-3.manifest: Added.
+
 2010-08-03  Eric Seidel  <eric at webkit.org>
 
         Unreviewed.  Skipping test which fails on some Leopard installs.
diff --git a/LayoutTests/http/tests/appcache/origin-quota-expected.txt b/LayoutTests/http/tests/appcache/origin-quota-expected.txt
new file mode 100644
index 0000000..1d530bb
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/origin-quota-expected.txt
@@ -0,0 +1,9 @@
+UI DELEGATE APPLICATION CACHE CALLBACK: exceededApplicationCacheOriginQuotaForSecurityOrigin:{http, 127.0.0.1, 8000}
+This test checks that per-origin application cache quotas are enforced.
+
+This test sets the quota for the origin to 20kb, and attempts to fill it up with 2 iframes that are 13kb each. The application cache download process should fail on the 2nd iframe and the UI Delegate should be informed of the exceeded quota. Increasing the size to 40kb. A 3rd iframe is added, which should succeed.
+
+PASS - cached iframe-1
+PASS - error caching iframe-2 as expected
+PASS - cached iframe-3
+
diff --git a/LayoutTests/http/tests/appcache/origin-quota.html b/LayoutTests/http/tests/appcache/origin-quota.html
new file mode 100644
index 0000000..a7322fd
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/origin-quota.html
@@ -0,0 +1,77 @@
+<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.
+    addIFrameWithContinuation("resources/quota-origin-iframe-1.html", function(event) {
+        log(event.data);
+        addSecondIFrame();
+    });
+}
+
+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);
+        addThirdIFrame();
+    });
+}
+
+function addThirdIFrame() {
+    // Expected to succeed.
+    addIFrameWithContinuation("resources/quota-origin-iframe-3.html", function(event) {
+        log(event.data);
+        finishTest();
+    });
+}
+
+</script>
+</head>
+<body onload="startTest()">
+<p>This test checks that per-origin application cache quotas are enforced.</p>
+<p>
+    This test sets the quota for the origin to 20kb, and attempts to fill
+    it up with 2 iframes that are 13kb each. The application cache download
+    process should fail on the 2nd iframe and the UI Delegate should be
+    informed of the exceeded quota. Increasing the size to 40kb. A 3rd
+    iframe is added, which should succeed.
+</p>
+<pre id="console"></pre>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/quota-origin-iframe-1.html b/LayoutTests/http/tests/appcache/resources/quota-origin-iframe-1.html
new file mode 100644
index 0000000..c50959f
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/quota-origin-iframe-1.html
@@ -0,0 +1,8 @@
+<html manifest="quota-origin-iframe-1.manifest">
+<script>
+// iframe-1 is expected to succeed.
+applicationCache.oncached = function() { parent.postMessage("PASS - cached iframe-1", "*"); };
+applicationCache.onerror = function() { parent.postMessage("FAIL - error caching iframe-1, expected this to succeed and fit in the quota", "*"); };
+applicationCache.onnoupdate = function() { parent.postMessage("FAIL - no update iframe-1, all caches should have been deleted before this test", "*"); };
+</script>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/quota-origin-iframe-1.manifest b/LayoutTests/http/tests/appcache/resources/quota-origin-iframe-1.manifest
new file mode 100644
index 0000000..63d3784
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/quota-origin-iframe-1.manifest
@@ -0,0 +1,7 @@
+CACHE MANIFEST
+
+# iframe-1 should succeed. The origin quota has been set to
+# 20kb. Caching abe.png and this manifest will be ~13kb.
+
+CACHE:
+abe.png
diff --git a/LayoutTests/http/tests/appcache/resources/quota-origin-iframe-2.html b/LayoutTests/http/tests/appcache/resources/quota-origin-iframe-2.html
new file mode 100644
index 0000000..0f1c11b
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/quota-origin-iframe-2.html
@@ -0,0 +1,8 @@
+<html manifest="quota-origin-iframe-2.manifest">
+<script>
+// iframe-2 is expected to fail due to exceeding the origin quota.
+applicationCache.oncached = function() { parent.postMessage("FAIL - cached iframe-2, expected this this fail because it reached the quota", "*"); };
+applicationCache.onerror = function() { parent.postMessage("PASS - error caching iframe-2 as expected", "*"); };
+applicationCache.onnoupdate = function() { parent.postMessage("FAIL - no update iframe-2, all caches should have been deleted before this test", "*"); };
+</script>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/quota-origin-iframe-2.manifest b/LayoutTests/http/tests/appcache/resources/quota-origin-iframe-2.manifest
new file mode 100644
index 0000000..64292b0
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/quota-origin-iframe-2.manifest
@@ -0,0 +1,8 @@
+CACHE MANIFEST
+
+# iframe-2 should fail. The origin quota has been set to
+# 20kb, with ~13kb already cached. Caching abe.png and this
+# manifest (~13kb) should exceed the quota and fail.
+
+CACHE:
+abe.png
diff --git a/LayoutTests/http/tests/appcache/resources/quota-origin-iframe-3.html b/LayoutTests/http/tests/appcache/resources/quota-origin-iframe-3.html
new file mode 100644
index 0000000..a185e54
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/quota-origin-iframe-3.html
@@ -0,0 +1,8 @@
+<html manifest="quota-origin-iframe-3.manifest">
+<script>
+// iframe-3 is expected to succeed once the quota has been increased.
+applicationCache.oncached = function() { parent.postMessage("PASS - cached iframe-3", "*"); };
+applicationCache.onerror = function() { parent.postMessage("FAIL - error caching iframe-3, expected this to succeed with the quota increased", "*"); };
+applicationCache.onnoupdate = function() { parent.postMessage("FAIL - no update iframe-3, all caches should have been deleted before this test", "*"); };
+</script>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/quota-origin-iframe-3.manifest b/LayoutTests/http/tests/appcache/resources/quota-origin-iframe-3.manifest
new file mode 100644
index 0000000..bc29867
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/quota-origin-iframe-3.manifest
@@ -0,0 +1,8 @@
+CACHE MANIFEST
+
+# iframe-3 should succeed. The origin quota shuld have been
+# raised to 40kb, with ~13kb already cached. Caching abe.png
+# and this manifest will be ~13kb, bringing us up to 26kb.
+
+CACHE:
+abe.png
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c278138..7d7b900 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,19 @@
+2010-08-03  Joseph Pecoraro  <joepeck at webkit.org>
+
+        Reviewed by David Kilzer.
+
+        Limit ApplicationCache Total and Per-Origin Storage Capacity (Quotas)
+        https://bugs.webkit.org/show_bug.cgi?id=40627
+
+        Part 6 - LayoutTest and Cleanup
+
+        Test: http/tests/appcache/origin-quota.html
+
+        * loader/appcache/ApplicationCacheGroup.cpp:
+        (WebCore::ApplicationCacheGroup::scheduleReachedOriginQuotaCallback): made synchronous, as asynchronously the cache group was deleted too soon.
+        * loader/appcache/ApplicationCacheStorage.cpp:
+        (WebCore::ApplicationCacheStorage::storeUpdatedQuotaForOrigin): all storing operations should force the database to be created if needed.
+
 2010-08-03  Ryosuke Niwa  <rniwa at webkit.org>
 
         Reviewed by Eric Seidel.
diff --git a/WebCore/loader/appcache/ApplicationCacheGroup.cpp b/WebCore/loader/appcache/ApplicationCacheGroup.cpp
index 395d9ad..3ae8d9f 100644
--- a/WebCore/loader/appcache/ApplicationCacheGroup.cpp
+++ b/WebCore/loader/appcache/ApplicationCacheGroup.cpp
@@ -1079,25 +1079,6 @@ private:
     ApplicationCacheGroup* m_cacheGroup;
 };
 
-class OriginQuotaReachedCallbackTimer: public TimerBase {
-public:
-    OriginQuotaReachedCallbackTimer(ApplicationCacheGroup* cacheGroup, Frame* frame)
-        : m_cacheGroup(cacheGroup)
-        , m_frame(frame)
-    {
-    }
-
-private:
-    virtual void fired()
-    {
-        m_cacheGroup->didReachOriginQuota(m_frame.release());
-        delete this;
-    }
-
-    ApplicationCacheGroup* m_cacheGroup;
-    RefPtr<Frame> m_frame;
-};
-
 void ApplicationCacheGroup::scheduleReachedMaxAppCacheSizeCallback()
 {
     ASSERT(isMainThread());
@@ -1108,11 +1089,8 @@ void ApplicationCacheGroup::scheduleReachedMaxAppCacheSizeCallback()
 
 void ApplicationCacheGroup::scheduleReachedOriginQuotaCallback()
 {
-    ASSERT(isMainThread());
-    RefPtr<Frame> frameProtector = m_frame;
-    OriginQuotaReachedCallbackTimer* timer = new OriginQuotaReachedCallbackTimer(this, frameProtector.get());
-    timer->startOneShot(0);
-    // The timer will delete itself once it fires.
+    // FIXME: it might be nice to run this asynchronously, because there is no return value to wait for.
+    didReachOriginQuota(m_frame);
 }
 
 class CallCacheListenerTask : public ScriptExecutionContext::Task {
diff --git a/WebCore/loader/appcache/ApplicationCacheStorage.cpp b/WebCore/loader/appcache/ApplicationCacheStorage.cpp
index ec83911..5624809 100644
--- a/WebCore/loader/appcache/ApplicationCacheStorage.cpp
+++ b/WebCore/loader/appcache/ApplicationCacheStorage.cpp
@@ -518,7 +518,7 @@ bool ApplicationCacheStorage::remainingSizeForOriginExcludingCache(const Securit
 
 bool ApplicationCacheStorage::storeUpdatedQuotaForOrigin(const SecurityOrigin* origin, int64_t quota)
 {
-    openDatabase(false);
+    openDatabase(true);
     if (!m_database.isOpen())
         return false;
 
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index d453073..31b8a0a 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -5,6 +5,20 @@
         Limit ApplicationCache Total and Per-Origin Storage Capacity (Quotas)
         https://bugs.webkit.org/show_bug.cgi?id=40627
 
+        Part 6 - LayoutTest and Cleanup
+
+        * WebCoreSupport/WebApplicationCache.h:
+        * WebCoreSupport/WebApplicationCache.mm:
+        (+[WebApplicationCache setMaximumSize:]): refactor out deleting the application caches.
+        (+[WebApplicationCache deleteAllApplicationCaches]): delete application caches.
+
+2010-08-03  Joseph Pecoraro  <joepeck at webkit.org>
+
+        Reviewed by David Kilzer.
+
+        Limit ApplicationCache Total and Per-Origin Storage Capacity (Quotas)
+        https://bugs.webkit.org/show_bug.cgi?id=40627
+
         Part 5 - Refactor Quota Management in WebSecurityOrigin into Managers
 
         Per-Origin quotas exist for Databases and Application Caches. Clients
diff --git a/WebKit/mac/WebCoreSupport/WebApplicationCache.h b/WebKit/mac/WebCoreSupport/WebApplicationCache.h
index 78b06b7..976ce18 100644
--- a/WebKit/mac/WebCoreSupport/WebApplicationCache.h
+++ b/WebKit/mac/WebCoreSupport/WebApplicationCache.h
@@ -33,4 +33,6 @@
 + (long long)defaultOriginQuota;
 + (void)setDefaultOriginQuota:(long long)size;
 
++ (void)deleteAllApplicationCaches;
+
 @end
diff --git a/WebKit/mac/WebCoreSupport/WebApplicationCache.mm b/WebKit/mac/WebCoreSupport/WebApplicationCache.mm
index 5c2a208..45f0703 100644
--- a/WebKit/mac/WebCoreSupport/WebApplicationCache.mm
+++ b/WebKit/mac/WebCoreSupport/WebApplicationCache.mm
@@ -39,8 +39,7 @@ using namespace WebCore;
 
 + (void)setMaximumSize:(long long)size
 {
-    cacheStorage().empty();
-    cacheStorage().vacuumDatabaseFile();
+    [WebApplicationCache deleteAllApplicationCaches];
     cacheStorage().setMaximumSize(size);
 }
 
@@ -54,6 +53,12 @@ using namespace WebCore;
     cacheStorage().setDefaultOriginQuota(size);
 }
 
++ (void)deleteAllApplicationCaches
+{
+    cacheStorage().empty();
+    cacheStorage().vacuumDatabaseFile();
+}
+
 @end
 
 #endif
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 9ef1daa..ebec8ce 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -5,6 +5,58 @@
         Limit ApplicationCache Total and Per-Origin Storage Capacity (Quotas)
         https://bugs.webkit.org/show_bug.cgi?id=40627
 
+        Part 6 - LayoutTest and Cleanup
+
+          Allow tests to delete application caches and set application cache
+          origin quotas, so they can be tested.
+
+        * DumpRenderTree/LayoutTestController.cpp:
+        (LayoutTestController::LayoutTestController):
+        (dumpApplicationCacheDelegateCallbacksCallback): JavaScript callback, delegates to the controller.
+        (clearAllApplicationCachesCallback): should delete all application caches.
+        (setApplicationCacheOriginQuotaCallback): should set the origin quota for the localhost tests.
+        (LayoutTestController::staticFunctions):
+        * DumpRenderTree/LayoutTestController.h:
+        (LayoutTestController::dumpApplicationCacheDelegateCallbacks): accessor to see if application cache callbacks should be output.
+        (LayoutTestController::setDumpApplicationCacheDelegateCallbacks): enable or disable debug output when the application cache quota is reached.
+
+          Mac implementation.
+
+        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
+        (LayoutTestController::clearAllApplicationCaches): delete application caches.
+        (LayoutTestController::setApplicationCacheOriginQuota): set the quota for localhost.
+        * DumpRenderTree/mac/UIDelegate.mm:
+        (-[UIDelegate webView:frame:exceededDatabaseQuotaForSecurityOrigin:database:]): style fix.
+        (-[UIDelegate webView:exceededApplicationCacheOriginQuotaForSecurityOrigin:]): reset the quota.
+
+          Stub implementations for other platforms.
+
+        * DumpRenderTree/chromium/LayoutTestController.cpp:
+        (LayoutTestController::LayoutTestController):
+        (LayoutTestController::clearAllApplicationCaches):
+        (LayoutTestController::setApplicationCacheOriginQuota):
+        * DumpRenderTree/chromium/LayoutTestController.h:
+        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
+        (LayoutTestController::clearAllApplicationCaches):
+        (LayoutTestController::setApplicationCacheOriginQuota):
+        * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
+        (LayoutTestController::clearAllApplicationCaches):
+        (LayoutTestController::setApplicationCacheOriginQuota):
+        * DumpRenderTree/qt/LayoutTestControllerQt.h:
+        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
+        (LayoutTestController::clearAllApplicationCaches):
+        (LayoutTestController::setApplicationCacheOriginQuota):
+        * DumpRenderTree/wx/LayoutTestControllerWx.cpp:
+        (LayoutTestController::clearAllApplicationCaches):
+        (LayoutTestController::setApplicationCacheOriginQuota):
+
+2010-08-03  Joseph Pecoraro  <joepeck at webkit.org>
+
+        Reviewed by David Kilzer.
+
+        Limit ApplicationCache Total and Per-Origin Storage Capacity (Quotas)
+        https://bugs.webkit.org/show_bug.cgi?id=40627
+
         Part 5 - Refactor Quota Management in WebSecurityOrigin into Managers
 
           Change old style calls to make use of the managers.
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/LayoutTestController.cpp
index d98164b..3d91e0c 100644
--- a/WebKitTools/DumpRenderTree/LayoutTestController.cpp
+++ b/WebKitTools/DumpRenderTree/LayoutTestController.cpp
@@ -41,7 +41,8 @@
 #include <wtf/RefPtr.h>
 
 LayoutTestController::LayoutTestController(const std::string& testPathOrURL, const std::string& expectedPixelHash)
-    : m_dumpAsPDF(false)
+    : m_dumpApplicationCacheDelegateCallbacks(false)
+    , m_dumpAsPDF(false)
     , m_dumpAsText(false)
     , m_dumpBackForwardList(false)
     , m_dumpChildFrameScrollPositions(false)
@@ -92,6 +93,13 @@ PassRefPtr<LayoutTestController> LayoutTestController::create(const std::string&
 
 // Static Functions
 
+static JSValueRef dumpApplicationCacheDelegateCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->setDumpApplicationCacheDelegateCallbacks(true);
+    return JSValueMakeUndefined(context);
+}
+
 static JSValueRef dumpAsPDFCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
@@ -310,6 +318,15 @@ static JSValueRef callShouldCloseOnWebViewCallback(JSContextRef context, JSObjec
     return JSValueMakeBoolean(context, controller->callShouldCloseOnWebView());
 }
 
+static JSValueRef clearAllApplicationCachesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac implementation
+    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->clearAllApplicationCaches();
+
+    return JSValueMakeUndefined(context);
+}
+
 static JSValueRef clearAllDatabasesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     // Has mac & windows implementation
@@ -842,7 +859,21 @@ static JSValueRef setAppCacheMaximumSizeCallback(JSContextRef context, JSObjectR
         controller->setAppCacheMaximumSize(static_cast<unsigned long long>(size));
         
     return JSValueMakeUndefined(context);
+}
+
+static JSValueRef setApplicationCacheOriginQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac implementation
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
 
+    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+
+    double size = JSValueToNumber(context, arguments[0], NULL);
+    if (!isnan(size))
+        controller->setApplicationCacheOriginQuota(static_cast<unsigned long long>(size));
+
+    return JSValueMakeUndefined(context);
 }
 
 static JSValueRef setAuthenticationPasswordCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
@@ -1763,6 +1794,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
         { "apiTestNewWindowDataLoadBaseURL", apiTestNewWindowDataLoadBaseURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "apiTestGoToCurrentBackForwardItem", apiTestGoToCurrentBackForwardItemCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "callShouldCloseOnWebView", callShouldCloseOnWebViewCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "clearAllApplicationCaches", clearAllApplicationCachesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "clearAllDatabases", clearAllDatabasesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "clearBackForwardList", clearBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "clearPersistentUserStyleSheet", clearPersistentUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
@@ -1772,6 +1804,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
         { "disableImageLoading", disableImageLoadingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "dispatchPendingLoadRequests", dispatchPendingLoadRequestsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "display", displayCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "dumpApplicationCacheDelegateCallbacks", dumpApplicationCacheDelegateCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "dumpAsText", dumpAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "dumpBackForwardList", dumpBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "dumpChildFrameScrollPositions", dumpChildFrameScrollPositionsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
@@ -1826,7 +1859,8 @@ JSStaticFunction* LayoutTestController::staticFunctions()
         { "setAllowUniversalAccessFromFileURLs", setAllowUniversalAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAllowFileAccessFromFileURLs", setAllowFileAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAlwaysAcceptCookies", setAlwaysAcceptCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
-        { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 
+        { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setApplicationCacheOriginQuota", setApplicationCacheOriginQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAuthenticationPassword", setAuthenticationPasswordCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAuthenticationUsername", setAuthenticationUsernameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAuthorAndUserStylesEnabled", setAuthorAndUserStylesEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.h b/WebKitTools/DumpRenderTree/LayoutTestController.h
index 39cc3fb..9d15f4c 100644
--- a/WebKitTools/DumpRenderTree/LayoutTestController.h
+++ b/WebKitTools/DumpRenderTree/LayoutTestController.h
@@ -45,6 +45,7 @@ public:
     void makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception);
 
     void addDisallowedURL(JSStringRef url);
+    void clearAllApplicationCaches();
     void clearAllDatabases();
     void clearBackForwardList();
     void clearPersistentUserStyleSheet();
@@ -79,6 +80,7 @@ public:
     void setAllowUniversalAccessFromFileURLs(bool);
     void setAllowFileAccessFromFileURLs(bool);
     void setAppCacheMaximumSize(unsigned long long quota);
+    void setApplicationCacheOriginQuota(unsigned long long quota);
     void setAuthorAndUserStylesEnabled(bool);
     void setCacheModel(int);
     void setCustomPolicyDelegate(bool setDelegate, bool permissive);
@@ -126,6 +128,9 @@ public:
     bool generatePixelResults() const { return m_generatePixelResults; }
     void setGeneratePixelResults(bool generatePixelResults) { m_generatePixelResults = generatePixelResults; }
 
+    bool dumpApplicationCacheDelegateCallbacks() const { return m_dumpApplicationCacheDelegateCallbacks; }
+    void setDumpApplicationCacheDelegateCallbacks(bool dumpCallbacks) { m_dumpApplicationCacheDelegateCallbacks = dumpCallbacks; }
+
     bool dumpBackForwardList() const { return m_dumpBackForwardList; }
     void setDumpBackForwardList(bool dumpBackForwardList) { m_dumpBackForwardList = dumpBackForwardList; }
 
@@ -287,6 +292,7 @@ public:
 private:
     LayoutTestController(const std::string& testPathOrURL, const std::string& expectedPixelHash);
 
+    bool m_dumpApplicationCacheDelegateCallbacks;
     bool m_dumpAsPDF;
     bool m_dumpAsText;
     bool m_dumpBackForwardList;
diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp
index cd27c18..dd076ae 100644
--- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp
+++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp
@@ -154,6 +154,8 @@ LayoutTestController::LayoutTestController(TestShell* shell)
     bindMethod("setCallCloseOnWebViews", &LayoutTestController::setCallCloseOnWebViews);
     bindMethod("setPrivateBrowsingEnabled", &LayoutTestController::setPrivateBrowsingEnabled);
     bindMethod("setUseDashboardCompatibilityMode", &LayoutTestController::setUseDashboardCompatibilityMode);
+    bindMethod("clearAllApplicationCaches", &LayoutTestController::clearAllApplicationCaches);
+    bindMethod("setApplicationCacheOriginQuota", &LayoutTestController::setApplicationCacheOriginQuota);
 
     bindMethod("setJavaScriptCanAccessClipboard", &LayoutTestController::setJavaScriptCanAccessClipboard);
     bindMethod("setXSSAuditorEnabled", &LayoutTestController::setXSSAuditorEnabled);
@@ -648,6 +650,18 @@ void LayoutTestController::setUseDashboardCompatibilityMode(const CppArgumentLis
     result->setNull();
 }
 
+void LayoutTestController::clearAllApplicationCaches(const CppArgumentList&, CppVariant* result)
+{
+    // FIXME: implement to support Application Cache Quotas.
+    result->setNull();
+}
+
+void LayoutTestController::setApplicationCacheOriginQuota(const CppArgumentList&, CppVariant* result)
+{
+    // FIXME: implement to support Application Cache Quotas.
+    result->setNull();
+}
+
 void LayoutTestController::setScrollbarPolicy(const CppArgumentList&, CppVariant* result)
 {
     // FIXME: implement.
diff --git a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h
index 6748352..096d1df 100644
--- a/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h
+++ b/WebKitTools/DumpRenderTree/chromium/LayoutTestController.h
@@ -250,6 +250,11 @@ public:
     void addOriginAccessWhitelistEntry(const CppArgumentList&, CppVariant*);
     void removeOriginAccessWhitelistEntry(const CppArgumentList&, CppVariant*);
 
+    // Clears all Application Caches.
+    void clearAllApplicationCaches(const CppArgumentList&, CppVariant*);
+    // Sets the Application Quota for the localhost origin.
+    void setApplicationCacheOriginQuota(const CppArgumentList&, CppVariant*);
+
     // Clears all databases.
     void clearAllDatabases(const CppArgumentList&, CppVariant*);
     // Sets the default quota for all origins
diff --git a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
index 43ad9f4..29a96f1 100644
--- a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
+++ b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
@@ -542,6 +542,16 @@ void LayoutTestController::clearPersistentUserStyleSheet()
     // FIXME: implement
 }
 
+void LayoutTestController::clearAllApplicationCaches()
+{
+    // FIXME: implement to support Application Cache quotas.
+}
+
+void LayoutTestController::setApplicationCacheOriginQuota(unsigned long long quota)
+{
+    // FIXME: implement to support Application Cache quotas.
+}
+
 void LayoutTestController::clearAllDatabases()
 {
     webkit_remove_all_web_databases();
diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
index 7e812a0..5edf811 100644
--- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
+++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
@@ -124,6 +124,11 @@ bool LayoutTestController::callShouldCloseOnWebView()
     return [[mainFrame webView] shouldClose];
 }
 
+void LayoutTestController::clearAllApplicationCaches()
+{
+    [WebApplicationCache deleteAllApplicationCaches];
+}
+
 void LayoutTestController::clearAllDatabases()
 {
     [[WebDatabaseManager sharedWebDatabaseManager] deleteAllDatabases];
@@ -294,6 +299,13 @@ void LayoutTestController::setAppCacheMaximumSize(unsigned long long size)
     [WebApplicationCache setMaximumSize:size];
 }
 
+void LayoutTestController::setApplicationCacheOriginQuota(unsigned long long quota)
+{
+    WebSecurityOrigin *origin = [[WebSecurityOrigin alloc] initWithURL:[NSURL URLWithString:@"http://127.0.0.1:8000"]];
+    [[origin applicationCacheQuotaManager] setQuota:quota];
+    [origin release];
+}
+
 void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag)
 {
     [[[mainFrame webView] preferences] setAuthorAndUserStylesEnabled:flag];
diff --git a/WebKitTools/DumpRenderTree/mac/UIDelegate.mm b/WebKitTools/DumpRenderTree/mac/UIDelegate.mm
index cc9a5d4..5dba720 100644
--- a/WebKitTools/DumpRenderTree/mac/UIDelegate.mm
+++ b/WebKitTools/DumpRenderTree/mac/UIDelegate.mm
@@ -33,6 +33,7 @@
 #import "DumpRenderTreeDraggingInfo.h"
 #import "EventSendingController.h"
 #import "LayoutTestController.h"
+#import <WebKit/WebApplicationCache.h>
 #import <WebKit/WebFramePrivate.h>
 #import <WebKit/WebHTMLViewPrivate.h>
 #import <WebKit/WebQuotaManager.h>
@@ -156,14 +157,26 @@ DumpRenderTreeDraggingInfo *draggingInfo = nil;
 
 - (void)webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(WebSecurityOrigin *)origin database:(NSString *)databaseIdentifier
 {
-    if (!done && gLayoutTestController->dumpDatabaseCallbacks())
+    if (!done && gLayoutTestController->dumpDatabaseCallbacks()) {
         printf("UI DELEGATE DATABASE CALLBACK: exceededDatabaseQuotaForSecurityOrigin:{%s, %s, %i} database:%s\n", [[origin protocol] UTF8String], [[origin host] UTF8String], 
             [origin port], [databaseIdentifier UTF8String]);
+    }
 
     static const unsigned long long defaultQuota = 5 * 1024 * 1024;    
     [[origin databaseQuotaManager] setQuota:defaultQuota];
 }
 
+- (void)webView:(WebView *)sender exceededApplicationCacheOriginQuotaForSecurityOrigin:(WebSecurityOrigin *)origin
+{
+    if (!done && gLayoutTestController->dumpApplicationCacheDelegateCallbacks()) {
+        printf("UI DELEGATE APPLICATION CACHE CALLBACK: exceededApplicationCacheOriginQuotaForSecurityOrigin:{%s, %s, %i}\n",
+            [[origin protocol] UTF8String], [[origin host] UTF8String], [origin port]);
+    }
+
+    static const unsigned long long defaultOriginQuota = [WebApplicationCache defaultOriginQuota];
+    [[origin applicationCacheQuotaManager] setQuota:defaultOriginQuota];
+}
+
 - (void)webView:(WebView *)sender setStatusText:(NSString *)text
 {
     if (gLayoutTestController->dumpStatusCallbacks())
diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
index ca51f1b..19c4142 100644
--- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
+++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
@@ -494,6 +494,16 @@ void LayoutTestController::dispatchPendingLoadRequests()
     // FIXME: Implement for testing fix for 6727495
 }
 
+void LayoutTestController::clearAllApplicationCaches()
+{
+    // FIXME: implement to support Application Cache quotas.
+}
+
+void LayoutTestController::setApplicationCacheOriginQuota(unsigned long long quota)
+{
+    // FIXME: implement to support Application Cache quotas.
+}
+
 void LayoutTestController::setDatabaseQuota(int size)
 {
     if (!m_topLoadingFrame)
diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h
index 1dee6ce..24c0d4b 100644
--- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h
+++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h
@@ -174,6 +174,9 @@ public slots:
     void dispatchPendingLoadRequests();
     void disableImageLoading();
 
+    void clearAllApplicationCaches();
+    void setApplicationCacheOriginQuota(unsigned long long quota);
+
     void setDatabaseQuota(int size);
     void clearAllDatabases();
     void setIconDatabaseEnabled(bool enable);
diff --git a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
index 6519a97..1755ddf 100644
--- a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
+++ b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
@@ -888,6 +888,16 @@ bool LayoutTestController::isCommandEnabled(JSStringRef /*name*/)
     return false;
 }
 
+void LayoutTestController::clearAllApplicationCaches()
+{
+    // FIXME: implement to support Application Cache quotas.
+}
+
+void LayoutTestController::setApplicationCacheOriginQuota(unsigned long long quota)
+{
+    // FIXME: implement to support Application Cache quotas.
+}
+
 void LayoutTestController::clearAllDatabases()
 {
     COMPtr<IWebDatabaseManager> databaseManager;
diff --git a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp
index fd6b2d2..c844942 100644
--- a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp
+++ b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp
@@ -228,6 +228,16 @@ void LayoutTestController::clearPersistentUserStyleSheet()
     // FIXME: implement
 }
 
+void LayoutTestController::clearAllApplicationCaches()
+{
+    // FIXME: implement to support Application Cache quotas.
+}
+
+void LayoutTestController::setApplicationCacheOriginQuota(unsigned long long quota)
+{
+    // FIXME: implement to support Application Cache quotas.
+}
+
 void LayoutTestController::clearAllDatabases()
 {
     // FIXME: implement

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list