Skip to content
Permalink
Browse files
<https://webkit.org/b/42704> WebKitTestRunner needs to print history …
…delegate information

Tools:

Provide an implementation of WKContextHistoryClient that logs when called for tests in
the globalhistory directory.

Patch by Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> on 2014-03-27
Reviewed by Sam Weinig.

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::TestController):
(WTR::TestController::initialize): Set the history client.
(WTR::TestController::resetStateToConsistentValues): Disable logging of history client callbacks.
(WTR::TestController::didNavigateWithNavigationData): Log information about the navigation. Some portions
of the output are hard-coded to match WebKit1's results for now since they're fixed in our existing tests
and we don't yet have API to access the data in question.
(WTR::TestController::didPerformClientRedirect):
(WTR::TestController::didPerformServerRedirect):
(WTR::TestController::didUpdateHistoryTitle):
* WebKitTestRunner/TestController.h:
(WTR::TestController::setShouldLogHistoryClientCallbacks):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::shouldLogHistoryClientCallbacks): Log history client callbacks for tests in a globalhistory directory.
(WTR::TestInvocation::invoke):

LayoutTests:

Reviewed by Sam Weinig.

* platform/wk2/TestExpectations: Enable the two layout tests that pass. One test remains disabled
due to lack of testRunner API, and another due to an apparent bug in WebKit2's handling of
client redirects.

Canonical link: https://commits.webkit.org/148912@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166396 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Mikhail Pozdnyakov authored and bdash committed Mar 28, 2014
1 parent ca1abbb commit 2102c4a68f4237c2063a3390aac2c65f536d99af
Showing 6 changed files with 158 additions and 5 deletions.
@@ -1,3 +1,13 @@
2014-03-27 Mark Rowe <mrowe@apple.com>

<https://webkit.org/b/42704> WebKitTestRunner needs to print history delegate information

Reviewed by Sam Weinig.

* platform/wk2/TestExpectations: Enable the two layout tests that pass. One test remains disabled
due to lack of testRunner API, and another due to an apparent bug in WebKit2's handling of
client redirects.

2014-03-27 Oliver Hunt <oliver@apple.com>

Support spread operand in |new| expressions
@@ -175,13 +175,12 @@ http/tests/security/setDomainRelaxationForbiddenForURLScheme.html
# <https://bugs.webkit.org/show_bug.cgi?id=42777>
fast/loader/non-deferred-substitute-load.html

# WebKitTestRunner needs to print history delegate information
# <https://bugs.webkit.org/show_bug.cgi?id=42704>
http/tests/globalhistory/history-delegate-basic-302-redirect.html
http/tests/globalhistory/history-delegate-basic-refresh-redirect.html
http/tests/globalhistory/history-delegate-basic-title.html
# WebKitTestRunner needs testRunner.removeAllVisitedLinks
http/tests/globalhistory/history-delegate-basic-visited-links.html

# WebKit2 passes the wrong source URL for client redirects
http/tests/globalhistory/history-delegate-basic-refresh-redirect.html

# transitions/default-timing-function.html failing on WebKit2 since it was added
# <https://bugs.webkit.org/show_bug.cgi?id=56531>
transitions/default-timing-function.html
@@ -1,3 +1,28 @@
2014-03-27 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com>

<https://webkit.org/b/42704> WebKitTestRunner needs to print history delegate information

Provide an implementation of WKContextHistoryClient that logs when called for tests in
the globalhistory directory.

Reviewed by Sam Weinig.

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::TestController):
(WTR::TestController::initialize): Set the history client.
(WTR::TestController::resetStateToConsistentValues): Disable logging of history client callbacks.
(WTR::TestController::didNavigateWithNavigationData): Log information about the navigation. Some portions
of the output are hard-coded to match WebKit1's results for now since they're fixed in our existing tests
and we don't yet have API to access the data in question.
(WTR::TestController::didPerformClientRedirect):
(WTR::TestController::didPerformServerRedirect):
(WTR::TestController::didUpdateHistoryTitle):
* WebKitTestRunner/TestController.h:
(WTR::TestController::setShouldLogHistoryClientCallbacks):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::shouldLogHistoryClientCallbacks): Log history client callbacks for tests in a globalhistory directory.
(WTR::TestInvocation::invoke):

2014-03-27 Filip Pizlo <fpizlo@apple.com>

Revert http://trac.webkit.org/changeset/166386 because it broke builds.
@@ -121,6 +121,7 @@ TestController::TestController(int argc, const char* argv[])
, m_forceComplexText(false)
, m_shouldUseAcceleratedDrawing(false)
, m_shouldUseRemoteLayerTree(false)
, m_shouldLogHistoryClientCallbacks(false)
{

#if PLATFORM(IOS)
@@ -369,6 +370,16 @@ void TestController::initialize(int argc, const char* argv[])
};
WKContextSetInjectedBundleClient(m_context.get(), &injectedBundleClient.base);

WKContextHistoryClientV0 historyClient = {
{ 0, this },
didNavigateWithNavigationData,
didPerformClientRedirect,
didPerformServerRedirect,
didUpdateHistoryTitle,
0, // populateVisitedLinks
};
WKContextSetHistoryClient(m_context.get(), &historyClient.base);

WKNotificationManagerRef notificationManager = WKContextGetNotificationManager(m_context.get());
WKNotificationProviderV0 notificationKit = m_webNotificationProvider.provider();
WKNotificationManagerSetProvider(notificationManager, &notificationKit.base);
@@ -635,6 +646,8 @@ bool TestController::resetStateToConsistentValues()

m_shouldBlockAllPlugins = false;

m_shouldLogHistoryClientCallbacks = false;

// Reset main page back to about:blank
m_doneResetting = false;

@@ -1293,4 +1306,86 @@ void TestController::decidePolicyForResponse(WKFrameRef frame, WKURLResponseRef
WKFramePolicyListenerIgnore(listener);
}

void TestController::didNavigateWithNavigationData(WKContextRef, WKPageRef, WKNavigationDataRef navigationData, WKFrameRef frame, const void* clientInfo)
{
static_cast<TestController*>(const_cast<void*>(clientInfo))->didNavigateWithNavigationData(navigationData, frame);
}

void TestController::didNavigateWithNavigationData(WKNavigationDataRef navigationData, WKFrameRef)
{
if (m_state != RunningTest)
return;

if (!m_shouldLogHistoryClientCallbacks)
return;

// URL
WKRetainPtr<WKURLRef> urlWK = adoptWK(WKNavigationDataCopyURL(navigationData));
WKRetainPtr<WKStringRef> urlStringWK = adoptWK(WKURLCopyString(urlWK.get()));
// Title
WKRetainPtr<WKStringRef> titleWK = adoptWK(WKNavigationDataCopyTitle(navigationData));
// HTTP method
WKRetainPtr<WKURLRequestRef> requestWK = adoptWK(WKNavigationDataCopyOriginalRequest(navigationData));
WKRetainPtr<WKStringRef> methodWK = adoptWK(WKURLRequestCopyHTTPMethod(requestWK.get()));

// FIXME: Determine whether the navigation was successful / a client redirect rather than hard-coding the message here.
m_currentInvocation->outputText(String::format("WebView navigated to url \"%s\" with title \"%s\" with HTTP equivalent method \"%s\". The navigation was successful and was not a client redirect.\n",
toSTD(urlStringWK).c_str(), toSTD(titleWK).c_str(), toSTD(methodWK).c_str()));
}

void TestController::didPerformClientRedirect(WKContextRef, WKPageRef, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef frame, const void* clientInfo)
{
static_cast<TestController*>(const_cast<void*>(clientInfo))->didPerformClientRedirect(sourceURL, destinationURL, frame);
}

void TestController::didPerformClientRedirect(WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef)
{
if (m_state != RunningTest)
return;

if (!m_shouldLogHistoryClientCallbacks)
return;

WKRetainPtr<WKStringRef> sourceStringWK = adoptWK(WKURLCopyString(sourceURL));
WKRetainPtr<WKStringRef> destinationStringWK = adoptWK(WKURLCopyString(destinationURL));

m_currentInvocation->outputText(String::format("WebView performed a client redirect from \"%s\" to \"%s\".\n", toSTD(sourceStringWK).c_str(), toSTD(destinationStringWK).c_str()));
}

void TestController::didPerformServerRedirect(WKContextRef, WKPageRef, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef frame, const void* clientInfo)
{
static_cast<TestController*>(const_cast<void*>(clientInfo))->didPerformServerRedirect(sourceURL, destinationURL, frame);
}

void TestController::didPerformServerRedirect(WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef)
{
if (m_state != RunningTest)
return;

if (!m_shouldLogHistoryClientCallbacks)
return;

WKRetainPtr<WKStringRef> sourceStringWK = adoptWK(WKURLCopyString(sourceURL));
WKRetainPtr<WKStringRef> destinationStringWK = adoptWK(WKURLCopyString(destinationURL));

m_currentInvocation->outputText(String::format("WebView performed a server redirect from \"%s\" to \"%s\".\n", toSTD(sourceStringWK).c_str(), toSTD(destinationStringWK).c_str()));
}

void TestController::didUpdateHistoryTitle(WKContextRef, WKPageRef, WKStringRef title, WKURLRef URL, WKFrameRef frame, const void* clientInfo)
{
static_cast<TestController*>(const_cast<void*>(clientInfo))->didUpdateHistoryTitle(title, URL, frame);
}

void TestController::didUpdateHistoryTitle(WKStringRef title, WKURLRef URL, WKFrameRef)
{
if (m_state != RunningTest)
return;

if (!m_shouldLogHistoryClientCallbacks)
return;

WKRetainPtr<WKStringRef> urlStringWK(AdoptWK, WKURLCopyString(URL));
m_currentInvocation->outputText(String::format("WebView updated the title for history URL \"%s\" to \"%s\".\n", toSTD(urlStringWK).c_str(), toSTD(title).c_str()));
}

} // namespace WTR
@@ -104,6 +104,8 @@ class TestController {

void setBlockAllPlugins(bool shouldBlock) { m_shouldBlockAllPlugins = shouldBlock; }

void setShouldLogHistoryClientCallbacks(bool shouldLog) { m_shouldLogHistoryClientCallbacks = shouldLog; }

private:
void initialize(int argc, const char* argv[]);
void createWebViewWithOptions(WKDictionaryRef);
@@ -159,6 +161,19 @@ class TestController {
static void decidePolicyForResponse(WKPageRef, WKFrameRef, WKURLResponseRef, WKURLRequestRef, bool canShowMIMEType, WKFramePolicyListenerRef, WKTypeRef, const void*);
void decidePolicyForResponse(WKFrameRef, WKURLResponseRef, WKFramePolicyListenerRef);

// WKContextHistoryClient
static void didNavigateWithNavigationData(WKContextRef, WKPageRef, WKNavigationDataRef, WKFrameRef, const void*);
void didNavigateWithNavigationData(WKNavigationDataRef, WKFrameRef);

static void didPerformClientRedirect(WKContextRef, WKPageRef, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef, const void*);
void didPerformClientRedirect(WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef);

static void didPerformServerRedirect(WKContextRef, WKPageRef, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef, const void*);
void didPerformServerRedirect(WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef);

static void didUpdateHistoryTitle(WKContextRef, WKPageRef, WKStringRef title, WKURLRef, WKFrameRef, const void*);
void didUpdateHistoryTitle(WKStringRef title, WKURLRef, WKFrameRef);

static WKPageRef createOtherPage(WKPageRef oldPage, WKURLRequestRef, WKDictionaryRef, WKEventModifiers, WKEventMouseButton, const void*);

static void runModal(WKPageRef, const void* clientInfo);
@@ -223,6 +238,8 @@ class TestController {
bool m_shouldUseAcceleratedDrawing;
bool m_shouldUseRemoteLayerTree;

bool m_shouldLogHistoryClientCallbacks;

OwnPtr<EventSenderProxy> m_eventSenderProxy;

WorkQueueManager m_workQueueManager;
@@ -146,6 +146,11 @@ static bool shouldUseThreadedScrolling(const char* pathOrURL)
}
#endif

static bool shouldLogHistoryClientCallbacks(const char* pathOrURL)
{
return strstr(pathOrURL, "globalhistory/");
}

static void updateThreadedScrollingForCurrentTest(const char* pathOrURL)
{
#if PLATFORM(COCOA)
@@ -200,6 +205,8 @@ void TestInvocation::invoke()

m_textOutput.clear();

TestController::shared().setShouldLogHistoryClientCallbacks(shouldLogHistoryClientCallbacks(m_pathOrURL.c_str()));

WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("BeginTest"));
WKRetainPtr<WKMutableDictionaryRef> beginTestMessageBody = adoptWK(WKMutableDictionaryCreate());

0 comments on commit 2102c4a

Please sign in to comment.