[WK2][WKTR] TestRunner needs to implement dumpApplicationCacheDelegateCallbacks
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Sep 2012 09:17:25 +0000 (09:17 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Sep 2012 09:17:25 +0000 (09:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=96374

Patch by Christophe Dumez <christophe.dumez@intel.com> on 2012-09-12
Reviewed by Kenneth Rohde Christiansen.

Source/WebKit2:

Add Bundle C API to reset the application cache quota
for a given origin.

Add new reachedApplicationCacheOriginQuota callback
to WKBundlePageUIClient which is called from
WebChromeClient::reachedApplicationCacheOriginQuota().

Those are needed by WebKitTestRunner to dump
information about the application cache callbacks
if instructed to.

* Shared/APIClientTraits.cpp:
(WebKit):
* Shared/APIClientTraits.h:
* WebProcess/InjectedBundle/API/c/WKBundle.cpp:
(WKBundleSetApplicationCacheOriginQuota):
(WKBundleResetApplicationCacheOriginQuota):
* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
* WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::resetApplicationCacheOriginQuota):
(WebKit):
* WebProcess/InjectedBundle/InjectedBundle.h:
(InjectedBundle):
* WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp:
(WebKit::InjectedBundlePageUIClient::didReachApplicationCacheOriginQuota):
(WebKit):
* WebProcess/InjectedBundle/InjectedBundlePageUIClient.h:
(WebKit):
(InjectedBundlePageUIClient):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::reachedApplicationCacheOriginQuota):

Tools:

Implement support for dumpApplicationCacheDelegateCallbacks
and disallowIncreaseForApplicationCacheQuota in
WebKitTestRunner and properly dump the information
expected by the tests.

If the application cache quota is reached for a given
security origin, WebKitTestRunner will reset the quota
to its default value, unless intructed not to via
disallowIncreaseForApplicationCacheQuota().

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::InjectedBundlePage):
(WTR::InjectedBundlePage::didReachApplicationCacheOriginQuota):
(WTR):
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.h:
(InjectedBundlePage):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::TestRunner):
(WTR::TestRunner::disallowIncreaseForApplicationCacheQuota):
(WTR):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
(WTR::TestRunner::dumpApplicationCacheDelegateCallbacks):
(TestRunner):
(WTR::TestRunner::shouldDisallowIncreaseForApplicationCacheQuota):
(WTR::TestRunner::shouldDumpApplicationCacheDelegateCallbacks):

LayoutTests:

Unskip test cases that are passing now that WebKitTestRunner
implements dumpApplicationCacheDelegateCallbacks and
disallowIncreaseForApplicationCacheQuota.

* platform/efl-wk1/TestExpectations:
* platform/efl/Skipped:
* platform/wk2/Skipped:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@128280 268f45cc-cd09-0410-ab3c-d52691b4dbfc

21 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/efl-wk1/TestExpectations
LayoutTests/platform/efl/Skipped
LayoutTests/platform/wk2/Skipped
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/APIClientTraits.cpp
Source/WebKit2/Shared/APIClientTraits.h
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageUIClient.h
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

index 06306a5..4f6519f 100644 (file)
@@ -1,3 +1,18 @@
+2012-09-12  Christophe Dumez  <christophe.dumez@intel.com>
+
+        [WK2][WKTR] TestRunner needs to implement dumpApplicationCacheDelegateCallbacks
+        https://bugs.webkit.org/show_bug.cgi?id=96374
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Unskip test cases that are passing now that WebKitTestRunner
+        implements dumpApplicationCacheDelegateCallbacks and
+        disallowIncreaseForApplicationCacheQuota.
+
+        * platform/efl-wk1/TestExpectations:
+        * platform/efl/Skipped:
+        * platform/wk2/Skipped:
+
 2012-09-12  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
 
         [WK2] [WTR] WebKitTestRunner needs TestRunner.workerThreadCount
 2012-09-12  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
 
         [WK2] [WTR] WebKitTestRunner needs TestRunner.workerThreadCount
index fc6864a..745fcdd 100644 (file)
@@ -47,6 +47,12 @@ BUGWK84835 : editing/execCommand/indent-paragraphs.html = TEXT
 // Custom font loading delaying text drawing on Canvas
 BUGWK87355 : canvas/philip/tests/2d.text.draw.fontface.notinpage.html = TEXT
 
 // Custom font loading delaying text drawing on Canvas
 BUGWK87355 : canvas/philip/tests/2d.text.draw.fontface.notinpage.html = TEXT
 
+// EFL's TestRunner does not implement applicationCacheDiskUsageForOrigin
+BUGWK86460 : http/tests/appcache/origin-usage.html = TEXT
+
+// EFL's TestRunner does not implement originsWithApplicationCache
+BUGWK86498 : http/tests/appcache/origins-with-appcache.html = TEXT
+
 // Missing showModalDialog implementation
 BUGWK84589 : fast/animation/request-animation-frame-during-modal.html = TEXT
 BUGWK84589 : http/tests/security/cross-frame-access-call.html = TEXT
 // Missing showModalDialog implementation
 BUGWK84589 : fast/animation/request-animation-frame-during-modal.html = TEXT
 BUGWK84589 : http/tests/security/cross-frame-access-call.html = TEXT
index 35a43e4..d912663 100644 (file)
@@ -103,12 +103,6 @@ fast/parser/pre-html5-parser-quirks.html
 # Fallback resource wasn't used for a redirect to a resource with another origin
 http/tests/appcache/fallback.html
 
 # Fallback resource wasn't used for a redirect to a resource with another origin
 http/tests/appcache/fallback.html
 
-# EFL's LayoutTestController does not implement applicationCacheDiskUsageForOrigin
-http/tests/appcache/origin-usage.html
-
-# EFL's LayoutTestController does not implement originsWithApplicationCache
-http/tests/appcache/origins-with-appcache.html
-
 # EFL's LayoutTestController does not implement shadowPseudoId
 media/video-controls-transformed.html
 media/video-controls-visible-audio-only.html
 # EFL's LayoutTestController does not implement shadowPseudoId
 media/video-controls-transformed.html
 media/video-controls-visible-audio-only.html
index 281a1e0..1f23296 100644 (file)
@@ -202,12 +202,7 @@ fast/harness/override-preferences-2.html
 fast/images/animated-gif-restored-from-bfcache.html
 fast/text/zero-font-size.html
 
 fast/images/animated-gif-restored-from-bfcache.html
 fast/text/zero-font-size.html
 
-# WTR needs an implementation of dumpApplicationCacheDelegateCallbacks
-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/origin-usage.html
+# WTR needs an implementation of originsWithApplicationCache
 http/tests/appcache/origins-with-appcache.html
 
 # WebKitTestRunner needs to support layoutTestController.dumpDOMAsWebArchive
 http/tests/appcache/origins-with-appcache.html
 
 # WebKitTestRunner needs to support layoutTestController.dumpDOMAsWebArchive
index 6978b94..768a89f 100644 (file)
@@ -1,3 +1,43 @@
+2012-09-12  Christophe Dumez  <christophe.dumez@intel.com>
+
+        [WK2][WKTR] TestRunner needs to implement dumpApplicationCacheDelegateCallbacks
+        https://bugs.webkit.org/show_bug.cgi?id=96374
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Add Bundle C API to reset the application cache quota
+        for a given origin.
+
+        Add new reachedApplicationCacheOriginQuota callback
+        to WKBundlePageUIClient which is called from
+        WebChromeClient::reachedApplicationCacheOriginQuota().
+
+        Those are needed by WebKitTestRunner to dump
+        information about the application cache callbacks
+        if instructed to.
+
+        * Shared/APIClientTraits.cpp:
+        (WebKit):
+        * Shared/APIClientTraits.h:
+        * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
+        (WKBundleSetApplicationCacheOriginQuota):
+        (WKBundleResetApplicationCacheOriginQuota):
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
+        * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
+        * WebProcess/InjectedBundle/InjectedBundle.cpp:
+        (WebKit::InjectedBundle::resetApplicationCacheOriginQuota):
+        (WebKit):
+        * WebProcess/InjectedBundle/InjectedBundle.h:
+        (InjectedBundle):
+        * WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp:
+        (WebKit::InjectedBundlePageUIClient::didReachApplicationCacheOriginQuota):
+        (WebKit):
+        * WebProcess/InjectedBundle/InjectedBundlePageUIClient.h:
+        (WebKit):
+        (InjectedBundlePageUIClient):
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::reachedApplicationCacheOriginQuota):
+
 2012-09-12  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
 
         [WK2] [WTR] WebKitTestRunner needs TestRunner.workerThreadCount
 2012-09-12  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
 
         [WK2] [WTR] WebKitTestRunner needs TestRunner.workerThreadCount
index ae10a5f..3f90952 100644 (file)
@@ -75,6 +75,11 @@ const size_t APIClientTraits<WKBundlePageFormClient>::interfaceSizesByVersion[]
     sizeof(WKBundlePageFormClient)
 };
 
     sizeof(WKBundlePageFormClient)
 };
 
+const size_t APIClientTraits<WKBundlePageUIClient>::interfaceSizesByVersion[] = {
+    offsetof(WKBundlePageUIClient, didReachApplicationCacheOriginQuota),
+    sizeof(WKBundlePageUIClient)
+};
+
 const size_t APIClientTraits<WKContextInjectedBundleClient>::interfaceSizesByVersion[] = {
     offsetof(WKContextInjectedBundleClient, getInjectedBundleInitializationUserData),
     sizeof(WKContextInjectedBundleClient)
 const size_t APIClientTraits<WKContextInjectedBundleClient>::interfaceSizesByVersion[] = {
     offsetof(WKContextInjectedBundleClient, getInjectedBundleInitializationUserData),
     sizeof(WKContextInjectedBundleClient)
index 7352b56..cbca9b2 100644 (file)
@@ -54,6 +54,10 @@ template<> struct APIClientTraits<WKBundlePageFullScreenClient> {
     static const size_t interfaceSizesByVersion[2];
 };
 
     static const size_t interfaceSizesByVersion[2];
 };
 
+template<> struct APIClientTraits<WKBundlePageUIClient> {
+    static const size_t interfaceSizesByVersion[2];
+};
+
 template<> struct APIClientTraits<WKPageContextMenuClient> {
     static const size_t interfaceSizesByVersion[3];
 };
 template<> struct APIClientTraits<WKPageContextMenuClient> {
     static const size_t interfaceSizesByVersion[3];
 };
index 4e37f93..151c961 100644 (file)
@@ -248,7 +248,12 @@ uint64_t WKBundleGetAppCacheUsageForOrigin(WKBundleRef bundleRef, WKStringRef or
 
 void WKBundleSetApplicationCacheOriginQuota(WKBundleRef bundleRef, WKStringRef origin, uint64_t bytes)
 {
 
 void WKBundleSetApplicationCacheOriginQuota(WKBundleRef bundleRef, WKStringRef origin, uint64_t bytes)
 {
-    return toImpl(bundleRef)->setApplicationCacheOriginQuota(toImpl(origin)->string(), bytes);
+    toImpl(bundleRef)->setApplicationCacheOriginQuota(toImpl(origin)->string(), bytes);
+}
+
+void WKBundleResetApplicationCacheOriginQuota(WKBundleRef bundleRef, WKStringRef origin)
+{
+    toImpl(bundleRef)->resetApplicationCacheOriginQuota(toImpl(origin)->string());
 }
 
 void WKBundleSetMinimumTimerInterval(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, double seconds)
 }
 
 void WKBundleSetMinimumTimerInterval(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, double seconds)
index 8bc7670..206e1e9 100644 (file)
@@ -236,6 +236,7 @@ typedef bool (*WKBundlePageShouldRubberBandInDirectionCallback)(WKBundlePageRef
 typedef WKBundlePageUIElementVisibility (*WKBundlePageStatusBarIsVisibleCallback)(WKBundlePageRef page, const void *clientInfo);
 typedef WKBundlePageUIElementVisibility (*WKBundlePageMenuBarIsVisibleCallback)(WKBundlePageRef page, const void *clientInfo);
 typedef WKBundlePageUIElementVisibility (*WKBundlePageToolbarsAreVisibleCallback)(WKBundlePageRef page, const void *clientInfo);
 typedef WKBundlePageUIElementVisibility (*WKBundlePageStatusBarIsVisibleCallback)(WKBundlePageRef page, const void *clientInfo);
 typedef WKBundlePageUIElementVisibility (*WKBundlePageMenuBarIsVisibleCallback)(WKBundlePageRef page, const void *clientInfo);
 typedef WKBundlePageUIElementVisibility (*WKBundlePageToolbarsAreVisibleCallback)(WKBundlePageRef page, const void *clientInfo);
+typedef void (*WKBundlePageReachedAppCacheOriginQuotaCallback)(WKBundlePageRef page, WKSecurityOriginRef origin, int64_t totalBytesNeeded, const void *clientInfo);
 
 struct WKBundlePageUIClient {
     int                                                                 version;
 
 struct WKBundlePageUIClient {
     int                                                                 version;
@@ -254,10 +255,13 @@ struct WKBundlePageUIClient {
     WKBundlePageStatusBarIsVisibleCallback                              statusBarIsVisible;
     WKBundlePageMenuBarIsVisibleCallback                                menuBarIsVisible;
     WKBundlePageToolbarsAreVisibleCallback                              toolbarsAreVisible;
     WKBundlePageStatusBarIsVisibleCallback                              statusBarIsVisible;
     WKBundlePageMenuBarIsVisibleCallback                                menuBarIsVisible;
     WKBundlePageToolbarsAreVisibleCallback                              toolbarsAreVisible;
+
+    // Version 1.
+    WKBundlePageReachedAppCacheOriginQuotaCallback                      didReachApplicationCacheOriginQuota;
 };
 typedef struct WKBundlePageUIClient WKBundlePageUIClient;
 
 };
 typedef struct WKBundlePageUIClient WKBundlePageUIClient;
 
-enum { kWKBundlePageUIClientCurrentVersion = 0 };
+enum { kWKBundlePageUIClientCurrentVersion = 1 };
 
 // Editor client
 typedef bool (*WKBundlePageShouldBeginEditingCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo);
 
 // Editor client
 typedef bool (*WKBundlePageShouldBeginEditingCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo);
index 4ec4cf9..256b283 100644 (file)
@@ -99,6 +99,7 @@ WK_EXPORT void WKBundleClearApplicationCacheForOrigin(WKBundleRef bundle, WKStri
 WK_EXPORT void WKBundleSetAppCacheMaximumSize(WKBundleRef bundle, uint64_t size);
 WK_EXPORT uint64_t WKBundleGetAppCacheUsageForOrigin(WKBundleRef bundle, WKStringRef origin);
 WK_EXPORT void WKBundleSetApplicationCacheOriginQuota(WKBundleRef bundle, WKStringRef origin, uint64_t bytes);
 WK_EXPORT void WKBundleSetAppCacheMaximumSize(WKBundleRef bundle, uint64_t size);
 WK_EXPORT uint64_t WKBundleGetAppCacheUsageForOrigin(WKBundleRef bundle, WKStringRef origin);
 WK_EXPORT void WKBundleSetApplicationCacheOriginQuota(WKBundleRef bundle, WKStringRef origin, uint64_t bytes);
+WK_EXPORT void WKBundleResetApplicationCacheOriginQuota(WKBundleRef bundle, WKStringRef origin);
 
 // Garbage collection API
 WK_EXPORT void WKBundleGarbageCollectJavaScriptObjects(WKBundleRef bundle);
 
 // Garbage collection API
 WK_EXPORT void WKBundleGarbageCollectJavaScriptObjects(WKBundleRef bundle);
index 27dcd99..549b2bd 100644 (file)
@@ -359,6 +359,12 @@ void InjectedBundle::setApplicationCacheOriginQuota(const String& originString,
     cacheStorage().storeUpdatedQuotaForOrigin(origin.get(), bytes);
 }
 
     cacheStorage().storeUpdatedQuotaForOrigin(origin.get(), bytes);
 }
 
+void InjectedBundle::resetApplicationCacheOriginQuota(const String& originString)
+{
+    RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString(originString);
+    cacheStorage().storeUpdatedQuotaForOrigin(origin.get(), cacheStorage().defaultOriginQuota());
+}
+
 int InjectedBundle::numberOfPages(WebFrame* frame, double pageWidthInPixels, double pageHeightInPixels)
 {
     Frame* coreFrame = frame ? frame->coreFrame() : 0;
 int InjectedBundle::numberOfPages(WebFrame* frame, double pageWidthInPixels, double pageHeightInPixels)
 {
     Frame* coreFrame = frame ? frame->coreFrame() : 0;
index 85d8260..d59ee0a 100644 (file)
@@ -150,6 +150,7 @@ public:
     void setAppCacheMaximumSize(uint64_t);
     uint64_t appCacheUsageForOrigin(const String& origin);
     void setApplicationCacheOriginQuota(const String& origin, uint64_t);
     void setAppCacheMaximumSize(uint64_t);
     uint64_t appCacheUsageForOrigin(const String& origin);
     void setApplicationCacheOriginQuota(const String& origin, uint64_t);
+    void resetApplicationCacheOriginQuota(const String& origin);
 
     // Garbage collection API
     void garbageCollectJavaScriptObjects();
 
     // Garbage collection API
     void garbageCollectJavaScriptObjects();
index b8c9c62..2ef9ca7 100644 (file)
@@ -28,8 +28,9 @@
 
 #include "InjectedBundleHitTestResult.h"
 #include "WKAPICast.h"
 
 #include "InjectedBundleHitTestResult.h"
 #include "WKAPICast.h"
-#include "WebGraphicsContext.h"
 #include "WKBundleAPICast.h"
 #include "WKBundleAPICast.h"
+#include "WebGraphicsContext.h"
+#include "WebSecurityOrigin.h"
 #include <wtf/text/WTFString.h>
 
 using namespace WebCore;
 #include <wtf/text/WTFString.h>
 
 using namespace WebCore;
@@ -146,4 +147,12 @@ WKBundlePageUIElementVisibility InjectedBundlePageUIClient::toolbarsAreVisible(W
     return m_client.toolbarsAreVisible(toAPI(page), m_client.clientInfo);
 }
 
     return m_client.toolbarsAreVisible(toAPI(page), m_client.clientInfo);
 }
 
+void InjectedBundlePageUIClient::didReachApplicationCacheOriginQuota(WebPage* page, WebSecurityOrigin* origin, int64_t totalBytesNeeded)
+{
+    if (!m_client.didReachApplicationCacheOriginQuota)
+        return;
+
+    m_client.didReachApplicationCacheOriginQuota(toAPI(page), toAPI(origin), totalBytesNeeded, m_client.clientInfo);
+}
+
 } // namespace WebKit
 } // namespace WebKit
index de2928a..b8a4827 100644 (file)
@@ -42,6 +42,7 @@ namespace WebKit {
 class APIObject;
 class WebFrame;
 class WebPage;
 class APIObject;
 class WebFrame;
 class WebPage;
+class WebSecurityOrigin;
 
 class InjectedBundlePageUIClient : public APIClient<WKBundlePageUIClient, kWKBundlePageUIClientCurrentVersion> {
 public:
 
 class InjectedBundlePageUIClient : public APIClient<WKBundlePageUIClient, kWKBundlePageUIClientCurrentVersion> {
 public:
@@ -64,6 +65,8 @@ public:
     WKBundlePageUIElementVisibility statusBarIsVisible(WebPage*);
     WKBundlePageUIElementVisibility menuBarIsVisible(WebPage*);
     WKBundlePageUIElementVisibility toolbarsAreVisible(WebPage*);
     WKBundlePageUIElementVisibility statusBarIsVisible(WebPage*);
     WKBundlePageUIElementVisibility menuBarIsVisible(WebPage*);
     WKBundlePageUIElementVisibility toolbarsAreVisible(WebPage*);
+
+    void didReachApplicationCacheOriginQuota(WebPage*, WebSecurityOrigin*, int64_t totalBytesNeeded);
 };
 
 } // namespace WebKit
 };
 
 } // namespace WebKit
index c7fc9a7..4fb65be 100644 (file)
@@ -45,6 +45,7 @@
 #include "WebPreferencesStore.h"
 #include "WebProcess.h"
 #include "WebSearchPopupMenu.h"
 #include "WebPreferencesStore.h"
 #include "WebProcess.h"
 #include "WebSearchPopupMenu.h"
+#include "WebSecurityOrigin.h"
 #include <WebCore/AXObjectCache.h>
 #include <WebCore/ColorChooser.h>
 #include <WebCore/DatabaseTracker.h>
 #include <WebCore/AXObjectCache.h>
 #include <WebCore/ColorChooser.h>
 #include <WebCore/DatabaseTracker.h>
@@ -549,9 +550,10 @@ void WebChromeClient::reachedMaxAppCacheSize(int64_t)
     notImplemented();
 }
 
     notImplemented();
 }
 
-void WebChromeClient::reachedApplicationCacheOriginQuota(SecurityOrigin*, int64_t)
+void WebChromeClient::reachedApplicationCacheOriginQuota(SecurityOrigin* origin, int64_t totalBytesNeeded)
 {
 {
-    notImplemented();
+    RefPtr<WebSecurityOrigin> webSecurityOrigin = WebSecurityOrigin::createFromString(origin->toString());
+    m_page->injectedBundleUIClient().didReachApplicationCacheOriginQuota(m_page, webSecurityOrigin.get(), totalBytesNeeded);
 }
 
 #if ENABLE(DASHBOARD_SUPPORT)
 }
 
 #if ENABLE(DASHBOARD_SUPPORT)
index 64f3a3d..186f20a 100644 (file)
@@ -1,3 +1,37 @@
+2012-09-12  Christophe Dumez  <christophe.dumez@intel.com>
+
+        [WK2][WKTR] TestRunner needs to implement dumpApplicationCacheDelegateCallbacks
+        https://bugs.webkit.org/show_bug.cgi?id=96374
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Implement support for dumpApplicationCacheDelegateCallbacks
+        and disallowIncreaseForApplicationCacheQuota in
+        WebKitTestRunner and properly dump the information
+        expected by the tests.
+
+        If the application cache quota is reached for a given
+        security origin, WebKitTestRunner will reset the quota
+        to its default value, unless intructed not to via
+        disallowIncreaseForApplicationCacheQuota().
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::InjectedBundlePage::InjectedBundlePage):
+        (WTR::InjectedBundlePage::didReachApplicationCacheOriginQuota):
+        (WTR):
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.h:
+        (InjectedBundlePage):
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::TestRunner):
+        (WTR::TestRunner::disallowIncreaseForApplicationCacheQuota):
+        (WTR):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        (WTR::TestRunner::dumpApplicationCacheDelegateCallbacks):
+        (TestRunner):
+        (WTR::TestRunner::shouldDisallowIncreaseForApplicationCacheQuota):
+        (WTR::TestRunner::shouldDumpApplicationCacheDelegateCallbacks):
+
 2012-09-12  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
 
         [WK2] [WTR] WebKitTestRunner needs TestRunner.workerThreadCount
 2012-09-12  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
 
         [WK2] [WTR] WebKitTestRunner needs TestRunner.workerThreadCount
index 362555f..ca3565c 100644 (file)
@@ -47,6 +47,7 @@ module WTR {
         void dumpResourceLoadCallbacks();
         void dumpResourceResponseMIMETypes();
         void dumpWillCacheResponse();
         void dumpResourceLoadCallbacks();
         void dumpResourceResponseMIMETypes();
         void dumpWillCacheResponse();
+        void dumpApplicationCacheDelegateCallbacks();
 
         // Special options.
         void keepWebHistory();
 
         // Special options.
         void keepWebHistory();
@@ -113,6 +114,7 @@ module WTR {
         long long applicationCacheDiskUsageForOrigin(in DOMString origin);
         void clearApplicationCacheForOrigin(in DOMString name);
         void setApplicationCacheOriginQuota(in unsigned long long bytes);
         long long applicationCacheDiskUsageForOrigin(in DOMString origin);
         void clearApplicationCacheForOrigin(in DOMString name);
         void setApplicationCacheOriginQuota(in unsigned long long bytes);
+        void disallowIncreaseForApplicationCacheQuota();
 
         // Compositing testing.
         DOMString layerTreeAsText();
 
         // Compositing testing.
         DOMString layerTreeAsText();
index 6746a70..7fa7b41 100644 (file)
@@ -41,6 +41,8 @@
 #include <WebKit2/WKBundleNavigationAction.h>
 #include <WebKit2/WKBundleNodeHandlePrivate.h>
 #include <WebKit2/WKBundlePagePrivate.h>
 #include <WebKit2/WKBundleNavigationAction.h>
 #include <WebKit2/WKBundleNodeHandlePrivate.h>
 #include <WebKit2/WKBundlePagePrivate.h>
+#include <WebKit2/WKBundlePrivate.h>
+#include <WebKit2/WKSecurityOrigin.h>
 #include <WebKit2/WKURLRequest.h>
 #include <wtf/HashMap.h>
 #include <wtf/text/CString.h>
 #include <WebKit2/WKURLRequest.h>
 #include <wtf/HashMap.h>
 #include <wtf/text/CString.h>
@@ -349,6 +351,7 @@ InjectedBundlePage::InjectedBundlePage(WKBundlePageRef page)
         0, /*statusBarIsVisible*/
         0, /*menuBarIsVisible*/
         0, /*toolbarsAreVisible*/
         0, /*statusBarIsVisible*/
         0, /*menuBarIsVisible*/
         0, /*toolbarsAreVisible*/
+        didReachApplicationCacheOriginQuota,
     };
     WKBundlePageSetUIClient(m_page, &uiClient);
 
     };
     WKBundlePageSetUIClient(m_page, &uiClient);
 
@@ -1318,6 +1321,11 @@ void InjectedBundlePage::willRunJavaScriptPrompt(WKBundlePageRef page, WKStringR
     static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->willRunJavaScriptPrompt(message, defaultValue, frame);
 }
 
     static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->willRunJavaScriptPrompt(message, defaultValue, frame);
 }
 
+void InjectedBundlePage::didReachApplicationCacheOriginQuota(WKBundlePageRef page, WKSecurityOriginRef origin, int64_t totalBytesNeeded, const void* clientInfo)
+{
+    static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didReachApplicationCacheOriginQuota(origin, totalBytesNeeded);
+}
+
 static WTF::String lastFileURLPathComponent(const WTF::String& path)
 {
     size_t pos = path.find("file://");
 static WTF::String lastFileURLPathComponent(const WTF::String& path)
 {
     size_t pos = path.find("file://");
@@ -1402,6 +1410,34 @@ void InjectedBundlePage::willRunJavaScriptPrompt(WKStringRef message, WKStringRe
     InjectedBundle::shared().stringBuilder()->append("\n");
 }
 
     InjectedBundle::shared().stringBuilder()->append("\n");
 }
 
+void InjectedBundlePage::didReachApplicationCacheOriginQuota(WKSecurityOriginRef origin, int64_t totalBytesNeeded)
+{
+    if (!InjectedBundle::shared().testRunner()->shouldDumpApplicationCacheDelegateCallbacks())
+        return;
+
+    // For example, numbers from 30000 - 39999 will output as 30000.
+    // Rounding up or down does not really matter for these tests. It's
+    // sufficient to just get a range of 10000 to determine if we were
+    // above or below a threshold.
+    int64_t truncatedSpaceNeeded = (totalBytesNeeded / 10000) * 10000;
+
+    InjectedBundle::shared().stringBuilder()->appendLiteral("UI DELEGATE APPLICATION CACHE CALLBACK: exceededApplicationCacheOriginQuotaForSecurityOrigin:{");
+    InjectedBundle::shared().stringBuilder()->append(toWTFString(adoptWK(WKSecurityOriginCopyProtocol(origin))));
+    InjectedBundle::shared().stringBuilder()->appendLiteral(", ");
+    InjectedBundle::shared().stringBuilder()->append(toWTFString(adoptWK(WKSecurityOriginCopyHost(origin))));
+    InjectedBundle::shared().stringBuilder()->appendLiteral(", ");
+    InjectedBundle::shared().stringBuilder()->append(WTF::String::number(WKSecurityOriginGetPort(origin)));
+    InjectedBundle::shared().stringBuilder()->appendLiteral("} totalSpaceNeeded:~");
+    InjectedBundle::shared().stringBuilder()->append(WTF::String::number(truncatedSpaceNeeded));
+    InjectedBundle::shared().stringBuilder()->append('\n');
+
+    if (InjectedBundle::shared().testRunner()->shouldDisallowIncreaseForApplicationCacheQuota())
+        return;
+
+    // Reset default application cache quota.
+    WKBundleResetApplicationCacheOriginQuota(InjectedBundle::shared().bundle(), adoptWK(WKSecurityOriginCopyToString(origin)).get());
+}
+
 // Editor Client Callbacks
 
 bool InjectedBundlePage::shouldBeginEditing(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo)
 // Editor Client Callbacks
 
 bool InjectedBundlePage::shouldBeginEditing(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo)
index 3ad203d..370f427 100644 (file)
@@ -124,11 +124,13 @@ private:
     static void willRunJavaScriptAlert(WKBundlePageRef, WKStringRef message, WKBundleFrameRef frame, const void* clientInfo);
     static void willRunJavaScriptConfirm(WKBundlePageRef, WKStringRef message, WKBundleFrameRef frame, const void* clientInfo);
     static void willRunJavaScriptPrompt(WKBundlePageRef, WKStringRef message, WKStringRef defaultValue, WKBundleFrameRef frame, const void* clientInfo);
     static void willRunJavaScriptAlert(WKBundlePageRef, WKStringRef message, WKBundleFrameRef frame, const void* clientInfo);
     static void willRunJavaScriptConfirm(WKBundlePageRef, WKStringRef message, WKBundleFrameRef frame, const void* clientInfo);
     static void willRunJavaScriptPrompt(WKBundlePageRef, WKStringRef message, WKStringRef defaultValue, WKBundleFrameRef frame, const void* clientInfo);
+    static void didReachApplicationCacheOriginQuota(WKBundlePageRef, WKSecurityOriginRef, int64_t totalBytesNeeded, const void* clientInfo);
     void willAddMessageToConsole(WKStringRef message, uint32_t lineNumber);
     void willSetStatusbarText(WKStringRef statusbarText);
     void willRunJavaScriptAlert(WKStringRef message, WKBundleFrameRef);
     void willRunJavaScriptConfirm(WKStringRef message, WKBundleFrameRef);
     void willRunJavaScriptPrompt(WKStringRef message, WKStringRef defaultValue, WKBundleFrameRef);
     void willAddMessageToConsole(WKStringRef message, uint32_t lineNumber);
     void willSetStatusbarText(WKStringRef statusbarText);
     void willRunJavaScriptAlert(WKStringRef message, WKBundleFrameRef);
     void willRunJavaScriptConfirm(WKStringRef message, WKBundleFrameRef);
     void willRunJavaScriptPrompt(WKStringRef message, WKStringRef defaultValue, WKBundleFrameRef);
+    void didReachApplicationCacheOriginQuota(WKSecurityOriginRef, int64_t totalBytesNeeded);
 
 #if ENABLE(FULLSCREEN_API)
     // Full Screen client
 
 #if ENABLE(FULLSCREEN_API)
     // Full Screen client
index fa0348d..d01dc8d 100644 (file)
@@ -80,6 +80,8 @@ TestRunner::TestRunner()
     , m_dumpResourceLoadCallbacks(false)
     , m_dumpResourceResponseMIMETypes(false)
     , m_dumpWillCacheResponse(false)
     , m_dumpResourceLoadCallbacks(false)
     , m_dumpResourceResponseMIMETypes(false)
     , m_dumpWillCacheResponse(false)
+    , m_dumpApplicationCacheDelegateCallbacks(false)
+    , m_disallowIncreaseForApplicationCacheQuota(false)
     , m_waitToDump(false)
     , m_testRepaint(false)
     , m_testRepaintSweepHorizontally(false)
     , m_waitToDump(false)
     , m_testRepaint(false)
     , m_testRepaintSweepHorizontally(false)
@@ -323,6 +325,11 @@ void TestRunner::setApplicationCacheOriginQuota(unsigned long long bytes)
     WKBundleSetApplicationCacheOriginQuota(InjectedBundle::shared().bundle(), origin.get(), bytes);
 }
 
     WKBundleSetApplicationCacheOriginQuota(InjectedBundle::shared().bundle(), origin.get(), bytes);
 }
 
+void TestRunner::disallowIncreaseForApplicationCacheQuota()
+{
+    m_disallowIncreaseForApplicationCacheQuota = true;
+}
+
 bool TestRunner::isCommandEnabled(JSStringRef name)
 {
     return WKBundlePageIsEditingCommandEnabled(InjectedBundle::shared().page()->page(), toWK(name).get());
 bool TestRunner::isCommandEnabled(JSStringRef name)
 {
     return WKBundlePageIsEditingCommandEnabled(InjectedBundle::shared().page()->page(), toWK(name).get());
index 77add0e..8e40493 100644 (file)
@@ -82,6 +82,7 @@ public:
     void dumpResourceLoadCallbacks() { m_dumpResourceLoadCallbacks = true; }
     void dumpResourceResponseMIMETypes() { m_dumpResourceResponseMIMETypes = true; }
     void dumpWillCacheResponse() { m_dumpWillCacheResponse = true; }
     void dumpResourceLoadCallbacks() { m_dumpResourceLoadCallbacks = true; }
     void dumpResourceResponseMIMETypes() { m_dumpResourceResponseMIMETypes = true; }
     void dumpWillCacheResponse() { m_dumpWillCacheResponse = true; }
+    void dumpApplicationCacheDelegateCallbacks() { m_dumpApplicationCacheDelegateCallbacks = true; }
 
     void setShouldDumpFrameLoadCallbacks(bool value) { m_dumpFrameLoadCallbacks = value; }
     void setShouldDumpProgressFinishedCallback(bool value) { m_dumpProgressFinishedCallback = value; }
 
     void setShouldDumpFrameLoadCallbacks(bool value) { m_dumpFrameLoadCallbacks = value; }
     void setShouldDumpProgressFinishedCallback(bool value) { m_dumpProgressFinishedCallback = value; }
@@ -149,6 +150,8 @@ public:
     void setAppCacheMaximumSize(uint64_t);
     long long applicationCacheDiskUsageForOrigin(JSStringRef origin);
     void setApplicationCacheOriginQuota(unsigned long long);
     void setAppCacheMaximumSize(uint64_t);
     long long applicationCacheDiskUsageForOrigin(JSStringRef origin);
     void setApplicationCacheOriginQuota(unsigned long long);
+    void disallowIncreaseForApplicationCacheQuota();
+    bool shouldDisallowIncreaseForApplicationCacheQuota() { return m_disallowIncreaseForApplicationCacheQuota; }
 
     // Printing
     bool isPageBoxVisible(int pageIndex);
 
     // Printing
     bool isPageBoxVisible(int pageIndex);
@@ -171,6 +174,7 @@ public:
     bool shouldDumpResourceLoadCallbacks() const { return m_dumpResourceLoadCallbacks; }
     bool shouldDumpResourceResponseMIMETypes() const { return m_dumpResourceResponseMIMETypes; }
     bool shouldDumpWillCacheResponse() const { return m_dumpWillCacheResponse; }
     bool shouldDumpResourceLoadCallbacks() const { return m_dumpResourceLoadCallbacks; }
     bool shouldDumpResourceResponseMIMETypes() const { return m_dumpResourceResponseMIMETypes; }
     bool shouldDumpWillCacheResponse() const { return m_dumpWillCacheResponse; }
+    bool shouldDumpApplicationCacheDelegateCallbacks() const { return m_dumpApplicationCacheDelegateCallbacks; }
 
     bool isPolicyDelegateEnabled() const { return m_policyDelegateEnabled; }
     bool isPolicyDelegatePermissive() const { return m_policyDelegatePermissive; }
 
     bool isPolicyDelegateEnabled() const { return m_policyDelegateEnabled; }
     bool isPolicyDelegatePermissive() const { return m_policyDelegatePermissive; }
@@ -267,6 +271,8 @@ private:
     bool m_dumpResourceLoadCallbacks;
     bool m_dumpResourceResponseMIMETypes;
     bool m_dumpWillCacheResponse;
     bool m_dumpResourceLoadCallbacks;
     bool m_dumpResourceResponseMIMETypes;
     bool m_dumpWillCacheResponse;
+    bool m_dumpApplicationCacheDelegateCallbacks;
+    bool m_disallowIncreaseForApplicationCacheQuota;
     bool m_waitToDump; // True if waitUntilDone() has been called, but notifyDone() has not yet been called.
     bool m_testRepaint;
     bool m_testRepaintSweepHorizontally;
     bool m_waitToDump; // True if waitUntilDone() has been called, but notifyDone() has not yet been called.
     bool m_testRepaint;
     bool m_testRepaintSweepHorizontally;