Commit 4c837870 authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

WebKitTestRunner needs layoutTestController.dumpDatabaseCallbacks

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

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

Source/WebKit2:

Add new didExceedDatabaseQuota callback to WKBundlePageUIClient
and call it from WebChromeClient::exceededDatabaseQuota().
This is needed by WebKitTestRunner to dump information about
database callbacks.

* Shared/APIClientTraits.h:
* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::setDatabaseQuota): Call WebDatabaseManager::setQuotaForOrigin()
with "file__0" instead of "file:///" as origin identifier. WebDatabaseManager expects
a database identifier, not a string representation of the security origin. "file__0" is
the string that is used as databaseIdentifier of local files. This bug was causing the
database quota not to be set. The test cases would therefore fail due to the quota being
0 instead of the value explicitly set.
* WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp:
(WebKit::InjectedBundlePageUIClient::didExceedDatabaseQuota):
(WebKit):
* WebProcess/InjectedBundle/InjectedBundlePageUIClient.h:
(InjectedBundlePageUIClient):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::exceededDatabaseQuota):

Tools:

Implement testRunner.dumpDatabaseCallbacks in WebKitTestRunner
and dump the information expected by the test cases.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::beginTesting): Explicitly set the default
database quota.
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::securityOriginToStr): New convenience function to convert
a security origin to the string expected in test results.
(WTR):
(WTR::InjectedBundlePage::InjectedBundlePage):
(WTR::InjectedBundlePage::didExceedDatabaseQuota):
(WTR::InjectedBundlePage::didReachApplicationCacheOriginQuota): Minor
refactoring to share code with didExceedDatabaseQuota.
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.h:
(InjectedBundlePage):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::TestRunner):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
(WTR::TestRunner::dumpDatabaseCallbacks):
(WTR::TestRunner::shouldDumpDatabaseCallbacks):
(TestRunner):

LayoutTests:

Unskip several test cases which require implementation of
testRunner.dumpDatabaseCallbacks in WebKitTestRunner.

* platform/wk2/Skipped:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@128623 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d863be30
2012-09-14 Christophe Dumez <christophe.dumez@intel.com>
WebKitTestRunner needs layoutTestController.dumpDatabaseCallbacks
https://bugs.webkit.org/show_bug.cgi?id=57570
Reviewed by Kenneth Rohde Christiansen.
Unskip several test cases which require implementation of
testRunner.dumpDatabaseCallbacks in WebKitTestRunner.
* platform/wk2/Skipped:
2012-09-14 Sudarsana Nagineni <sudarsana.nagineni@linux.intel.com>
 
[EFL] Gardening of the WK2 Debug Bot failing tests
......@@ -288,11 +288,6 @@ platform/mac/editing/deleting/deletionUI-differing-background.html
platform/mac/editing/deleting/deletionUI-minimum-size.html
platform/mac/editing/deleting/deletionUI-successful-deletion.html
# WebKitTestRunner needs layoutTestController.dumpDatabaseCallbacks
# <https://bugs.webkit.org/show_bug.cgi?id=57570>
storage/websql/open-database-creation-callback.html
storage/websql/quota-tracking.html
# WebKitTestRunner needs layoutTestController.setMockGeolocationPosition
# and layoutTestController.setMockGeolocationError
# <https://bugs.webkit.org/show_bug.cgi?id=59201>
......
2012-09-14 Christophe Dumez <christophe.dumez@intel.com>
WebKitTestRunner needs layoutTestController.dumpDatabaseCallbacks
https://bugs.webkit.org/show_bug.cgi?id=57570
Reviewed by Kenneth Rohde Christiansen.
Add new didExceedDatabaseQuota callback to WKBundlePageUIClient
and call it from WebChromeClient::exceededDatabaseQuota().
This is needed by WebKitTestRunner to dump information about
database callbacks.
* Shared/APIClientTraits.h:
* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::setDatabaseQuota): Call WebDatabaseManager::setQuotaForOrigin()
with "file__0" instead of "file:///" as origin identifier. WebDatabaseManager expects
a database identifier, not a string representation of the security origin. "file__0" is
the string that is used as databaseIdentifier of local files. This bug was causing the
database quota not to be set. The test cases would therefore fail due to the quota being
0 instead of the value explicitly set.
* WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp:
(WebKit::InjectedBundlePageUIClient::didExceedDatabaseQuota):
(WebKit):
* WebProcess/InjectedBundle/InjectedBundlePageUIClient.h:
(InjectedBundlePageUIClient):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::exceededDatabaseQuota):
2012-09-14 Christophe Dumez <christophe.dumez@intel.com>
 
WebKitTestRunner needs layoutTestController.setStopProvisionalFrameLoads
......
......@@ -55,7 +55,7 @@ template<> struct APIClientTraits<WKBundlePageFullScreenClient> {
};
template<> struct APIClientTraits<WKBundlePageUIClient> {
static const size_t interfaceSizesByVersion[2];
static const size_t interfaceSizesByVersion[3];
};
template<> struct APIClientTraits<WKPageContextMenuClient> {
......
......@@ -237,6 +237,7 @@ typedef WKBundlePageUIElementVisibility (*WKBundlePageStatusBarIsVisibleCallback
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);
typedef uint64_t (*WKBundlePageExceededDatabaseQuotaCallback)(WKBundlePageRef page, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes, const void *clientInfo);
struct WKBundlePageUIClient {
int version;
......@@ -258,10 +259,14 @@ struct WKBundlePageUIClient {
// Version 1.
WKBundlePageReachedAppCacheOriginQuotaCallback didReachApplicationCacheOriginQuota;
// Version 2.
WKBundlePageExceededDatabaseQuotaCallback didExceedDatabaseQuota;
};
typedef struct WKBundlePageUIClient WKBundlePageUIClient;
enum { kWKBundlePageUIClientCurrentVersion = 1 };
enum { kWKBundlePageUIClientCurrentVersion = 2 };
// Editor client
typedef bool (*WKBundlePageShouldBeginEditingCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo);
......
......@@ -327,7 +327,9 @@ void InjectedBundle::clearAllDatabases()
void InjectedBundle::setDatabaseQuota(uint64_t quota)
{
#if ENABLE(SQL_DATABASE)
WebDatabaseManager::shared().setQuotaForOrigin("file:///", quota);
// Historically, we've used the following (somewhat non-sensical) string
// for the databaseIdentifier of local files.
WebDatabaseManager::shared().setQuotaForOrigin("file__0", quota);
#endif
}
......
......@@ -155,4 +155,12 @@ void InjectedBundlePageUIClient::didReachApplicationCacheOriginQuota(WebPage* pa
m_client.didReachApplicationCacheOriginQuota(toAPI(page), toAPI(origin), totalBytesNeeded, m_client.clientInfo);
}
uint64_t InjectedBundlePageUIClient::didExceedDatabaseQuota(WebPage* page, WebSecurityOrigin* origin, const String& databaseName, const String& databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes)
{
if (!m_client.didExceedDatabaseQuota)
return 0;
return m_client.didExceedDatabaseQuota(toAPI(page), toAPI(origin), toAPI(databaseName.impl()), toAPI(databaseDisplayName.impl()), currentQuotaBytes, currentOriginUsageBytes, currentDatabaseUsageBytes, expectedUsageBytes, m_client.clientInfo);
}
} // namespace WebKit
......@@ -67,6 +67,7 @@ public:
WKBundlePageUIElementVisibility toolbarsAreVisible(WebPage*);
void didReachApplicationCacheOriginQuota(WebPage*, WebSecurityOrigin*, int64_t totalBytesNeeded);
uint64_t didExceedDatabaseQuota(WebPage*, WebSecurityOrigin*, const String& databaseName, const String& databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes);
};
} // namespace WebKit
......
......@@ -536,9 +536,14 @@ void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String& database
uint64_t currentQuota = DatabaseTracker::tracker().quotaForOrigin(origin);
uint64_t currentOriginUsage = DatabaseTracker::tracker().usageForOrigin(origin);
uint64_t newQuota = 0;
WebProcess::shared().connection()->sendSync(
Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), databaseName, details.displayName(), currentQuota, currentOriginUsage, details.currentUsage(), details.expectedUsage()),
Messages::WebPageProxy::ExceededDatabaseQuota::Reply(newQuota), m_page->pageID());
RefPtr<WebSecurityOrigin> webSecurityOrigin = WebSecurityOrigin::createFromDatabaseIdentifier(origin->databaseIdentifier());
newQuota = m_page->injectedBundleUIClient().didExceedDatabaseQuota(m_page, webSecurityOrigin.get(), databaseName, details.displayName(), currentQuota, currentOriginUsage, details.currentUsage(), details.expectedUsage());
if (!newQuota) {
WebProcess::shared().connection()->sendSync(
Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), databaseName, details.displayName(), currentQuota, currentOriginUsage, details.currentUsage(), details.expectedUsage()),
Messages::WebPageProxy::ExceededDatabaseQuota::Reply(newQuota), m_page->pageID());
}
DatabaseTracker::tracker().setQuota(origin, newQuota);
}
......
2012-09-14 Christophe Dumez <christophe.dumez@intel.com>
WebKitTestRunner needs layoutTestController.dumpDatabaseCallbacks
https://bugs.webkit.org/show_bug.cgi?id=57570
Reviewed by Kenneth Rohde Christiansen.
Implement testRunner.dumpDatabaseCallbacks in WebKitTestRunner
and dump the information expected by the test cases.
* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::beginTesting): Explicitly set the default
database quota.
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::securityOriginToStr): New convenience function to convert
a security origin to the string expected in test results.
(WTR):
(WTR::InjectedBundlePage::InjectedBundlePage):
(WTR::InjectedBundlePage::didExceedDatabaseQuota):
(WTR::InjectedBundlePage::didReachApplicationCacheOriginQuota): Minor
refactoring to share code with didExceedDatabaseQuota.
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.h:
(InjectedBundlePage):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::TestRunner):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
(WTR::TestRunner::dumpDatabaseCallbacks):
(WTR::TestRunner::shouldDumpDatabaseCallbacks):
(TestRunner):
2012-09-14 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
 
[Qt] Set force_static_libs_as_shared early enough to be caught by configure
......
......@@ -48,6 +48,7 @@ module WTR {
void dumpResourceResponseMIMETypes();
void dumpWillCacheResponse();
void dumpApplicationCacheDelegateCallbacks();
void dumpDatabaseCallbacks();
// Special options.
void keepWebHistory();
......
......@@ -260,6 +260,7 @@ void InjectedBundle::beginTesting(WKDictionaryRef settings)
WKBundleClearAllDatabases(m_bundle);
WKBundleClearApplicationCache(m_bundle);
WKBundleResetOriginAccessWhitelists(m_bundle);
WKBundleSetDatabaseQuota(m_bundle, 5 * 1024 * 1024);
}
void InjectedBundle::done()
......
......@@ -194,6 +194,20 @@ static WTF::String styleDecToStr(WKBundleCSSStyleDeclarationRef style)
return stringBuilder.toString();
}
static WTF::String securityOriginToStr(WKSecurityOriginRef origin)
{
WTF::StringBuilder stringBuilder;
stringBuilder.append('{');
stringBuilder.append(toWTFString(adoptWK(WKSecurityOriginCopyProtocol(origin))));
stringBuilder.appendLiteral(", ");
stringBuilder.append(toWTFString(adoptWK(WKSecurityOriginCopyHost(origin))));
stringBuilder.appendLiteral(", ");
stringBuilder.appendNumber(WKSecurityOriginGetPort(origin));
stringBuilder.append('}');
return stringBuilder.toString();
}
static WTF::String frameToStr(WKBundleFrameRef frame)
{
WKRetainPtr<WKStringRef> name(AdoptWK, WKBundleFrameCopyName(frame));
......@@ -360,6 +374,7 @@ InjectedBundlePage::InjectedBundlePage(WKBundlePageRef page)
0, /*menuBarIsVisible*/
0, /*toolbarsAreVisible*/
didReachApplicationCacheOriginQuota,
didExceedDatabaseQuota,
};
WKBundlePageSetUIClient(m_page, &uiClient);
......@@ -1335,6 +1350,11 @@ void InjectedBundlePage::didReachApplicationCacheOriginQuota(WKBundlePageRef pag
static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didReachApplicationCacheOriginQuota(origin, totalBytesNeeded);
}
uint64_t InjectedBundlePage::didExceedDatabaseQuota(WKBundlePageRef page, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes, const void* clientInfo)
{
return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didExceedDatabaseQuota(origin, databaseName, databaseDisplayName, currentQuotaBytes, currentOriginUsageBytes, currentDatabaseUsageBytes, expectedUsageBytes);
}
static WTF::String lastFileURLPathComponent(const WTF::String& path)
{
size_t pos = path.find("file://");
......@@ -1421,24 +1441,19 @@ void InjectedBundlePage::willRunJavaScriptPrompt(WKStringRef message, WKStringRe
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()->appendNumber(WKSecurityOriginGetPort(origin));
InjectedBundle::shared().stringBuilder()->appendLiteral("} totalSpaceNeeded:~");
InjectedBundle::shared().stringBuilder()->appendNumber(truncatedSpaceNeeded);
InjectedBundle::shared().stringBuilder()->append('\n');
if (InjectedBundle::shared().testRunner()->shouldDumpApplicationCacheDelegateCallbacks()) {
// 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(securityOriginToStr(origin));
InjectedBundle::shared().stringBuilder()->appendLiteral(" totalSpaceNeeded:~");
InjectedBundle::shared().stringBuilder()->appendNumber(truncatedSpaceNeeded);
InjectedBundle::shared().stringBuilder()->append('\n');
}
if (InjectedBundle::shared().testRunner()->shouldDisallowIncreaseForApplicationCacheQuota())
return;
......@@ -1447,6 +1462,20 @@ void InjectedBundlePage::didReachApplicationCacheOriginQuota(WKSecurityOriginRef
WKBundleResetApplicationCacheOriginQuota(InjectedBundle::shared().bundle(), adoptWK(WKSecurityOriginCopyToString(origin)).get());
}
uint64_t InjectedBundlePage::didExceedDatabaseQuota(WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes)
{
if (InjectedBundle::shared().testRunner()->shouldDumpDatabaseCallbacks()) {
InjectedBundle::shared().stringBuilder()->appendLiteral("UI DELEGATE DATABASE CALLBACK: exceededDatabaseQuotaForSecurityOrigin:");
InjectedBundle::shared().stringBuilder()->append(securityOriginToStr(origin));
InjectedBundle::shared().stringBuilder()->appendLiteral(" database:");
InjectedBundle::shared().stringBuilder()->append(toWTFString(databaseName));
InjectedBundle::shared().stringBuilder()->append('\n');
}
static const uint64_t defaultQuota = 5 * 1024 * 1024;
return defaultQuota;
}
// Editor Client Callbacks
bool InjectedBundlePage::shouldBeginEditing(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo)
......
......@@ -125,12 +125,14 @@ private:
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);
static uint64_t didExceedDatabaseQuota(WKBundlePageRef, WKSecurityOriginRef, WKStringRef databaseName, WKStringRef databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes, 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 didReachApplicationCacheOriginQuota(WKSecurityOriginRef, int64_t totalBytesNeeded);
uint64_t didExceedDatabaseQuota(WKSecurityOriginRef, WKStringRef databaseName, WKStringRef databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes);
#if ENABLE(FULLSCREEN_API)
// Full Screen client
......
......@@ -81,6 +81,7 @@ TestRunner::TestRunner()
, m_dumpResourceResponseMIMETypes(false)
, m_dumpWillCacheResponse(false)
, m_dumpApplicationCacheDelegateCallbacks(false)
, m_dumpDatabaseCallbacks(false)
, m_disallowIncreaseForApplicationCacheQuota(false)
, m_waitToDump(false)
, m_testRepaint(false)
......
......@@ -83,6 +83,7 @@ public:
void dumpResourceResponseMIMETypes() { m_dumpResourceResponseMIMETypes = true; }
void dumpWillCacheResponse() { m_dumpWillCacheResponse = true; }
void dumpApplicationCacheDelegateCallbacks() { m_dumpApplicationCacheDelegateCallbacks = true; }
void dumpDatabaseCallbacks() { m_dumpDatabaseCallbacks = true; }
void setShouldDumpFrameLoadCallbacks(bool value) { m_dumpFrameLoadCallbacks = value; }
void setShouldDumpProgressFinishedCallback(bool value) { m_dumpProgressFinishedCallback = value; }
......@@ -177,6 +178,7 @@ public:
bool shouldDumpResourceResponseMIMETypes() const { return m_dumpResourceResponseMIMETypes; }
bool shouldDumpWillCacheResponse() const { return m_dumpWillCacheResponse; }
bool shouldDumpApplicationCacheDelegateCallbacks() const { return m_dumpApplicationCacheDelegateCallbacks; }
bool shouldDumpDatabaseCallbacks() const { return m_dumpDatabaseCallbacks; }
bool isPolicyDelegateEnabled() const { return m_policyDelegateEnabled; }
bool isPolicyDelegatePermissive() const { return m_policyDelegatePermissive; }
......@@ -279,6 +281,7 @@ private:
bool m_dumpResourceResponseMIMETypes;
bool m_dumpWillCacheResponse;
bool m_dumpApplicationCacheDelegateCallbacks;
bool m_dumpDatabaseCallbacks;
bool m_disallowIncreaseForApplicationCacheQuota;
bool m_waitToDump; // True if waitUntilDone() has been called, but notifyDone() has not yet been called.
bool m_testRepaint;
......
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