WebKitTestRunner needs layoutTestController.dumpResourceLoadCallbacks
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Aug 2012 19:49:40 +0000 (19:49 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Aug 2012 19:49:40 +0000 (19:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=42332

Patch by Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> on 2012-08-14
Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

Provide build for mac.

* WebCore.exp.in: Added __ZNK7WebCore19ResourceRequestBase20firstPartyForCookiesEv.

Source/WebKit2:

Added new getters to WKURL, WKURLRequest, WKURLResponse so that it is possible
to dump information necessary for the tests passing.

* Shared/API/c/WKURL.cpp:
(WKURLCopyPath):
* Shared/API/c/WKURL.h:
* Shared/API/c/WKURLRequest.cpp:
(WKURLRequestCopyFirstPartyForCookies):
(WKURLRequestCopyHTTPMethod):
* Shared/API/c/WKURLRequest.h:
* Shared/API/c/WKURLResponse.cpp:
(WKURLResponseHTTPStatusCode):
* Shared/API/c/WKURLResponse.h:
* Shared/WebURL.h:
(WebKit::WebURL::path):
(WebURL):

Tools:

Added Resource Callbacks logging. Several aux dumping functions are added.

* WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::isFileScheme):
(WTR):
(WTR::pathSuitableForTestResult):
(WTR::urlSuitableForTestResult):
(WTR::InjectedBundlePage::resetAfterTest):
(WTR::dumpRequestDescriptionSuitableForTestResult):
(WTR::dumpResponseDescriptionSuitableForTestResult):
(WTR::dumpErrorDescriptionSuitableForTestResult):
(WTR::InjectedBundlePage::didInitiateLoadForResource):
(WTR::InjectedBundlePage::willSendRequestForFrame):
(WTR::InjectedBundlePage::didReceiveResponseForResource):
(WTR::InjectedBundlePage::didFinishLoadForResource):
(WTR::InjectedBundlePage::didFailLoadForResource):
* WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
(WTR::LayoutTestController::LayoutTestController):
* WebKitTestRunner/InjectedBundle/LayoutTestController.h:
(WTR::LayoutTestController::dumpResourceLoadCallbacks):
(WTR::LayoutTestController::shouldDumpResourceLoadCallbacks):
(LayoutTestController):

LayoutTests:

Unskipped correspondong test cases.

* platform/wk2/Skipped:

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

17 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/wk2/Skipped
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/c/WKURL.cpp
Source/WebKit2/Shared/API/c/WKURL.h
Source/WebKit2/Shared/API/c/WKURLRequest.cpp
Source/WebKit2/Shared/API/c/WKURLRequest.h
Source/WebKit2/Shared/API/c/WKURLResponse.cpp
Source/WebKit2/Shared/API/c/WKURLResponse.h
Source/WebKit2/Shared/WebURL.h
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl
Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp
Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h

index 65fe2ae..abef92d 100644 (file)
@@ -1,3 +1,14 @@
+2012-08-14  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
+
+        WebKitTestRunner needs layoutTestController.dumpResourceLoadCallbacks
+        https://bugs.webkit.org/show_bug.cgi?id=42332
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Unskipped correspondong test cases.
+
+        * platform/wk2/Skipped:
+
 2012-08-14  Adam Barth  <abarth@webkit.org>
 
         DOMWindow::document() should not reach through Frame
index fde43a4..819ebc6 100644 (file)
@@ -386,35 +386,6 @@ webarchive/loading/mainresource-null-mimetype-crash.html
 webarchive/loading/missing-data.html
 http/tests/security/xssAuditor/script-tag-with-callbacks.html
 
-# WebKitTestRunner needs layoutTestController.dumpResourceLoadCallbacks
-# <https://bugs.webkit.org/show_bug.cgi?id=42332>
-fast/images/support-broken-image-delegate.html
-fast/loader/file-protocol-fragment.html
-fast/loader/main-document-url-for-non-http-loads.html
-fast/loader/user-style-sheet-resource-load-callbacks.html
-http/tests/loading/307-after-303-after-post.html
-http/tests/loading/pdf-commit-load-callbacks.html
-http/tests/loading/redirect-methods.html
-http/tests/misc/favicon-loads-with-images-disabled.html
-http/tests/misc/favicon-loads-with-icon-loading-override.html
-http/tests/misc/link-rel-icon-beforeload.html
-http/tests/misc/will-send-request-returns-null-on-redirect.html
-http/tests/misc/willCacheResponse-delegate-callback.html
-http/tests/misc/window-dot-stop.html
-http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-in-body.html
-http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-parent-same-origin-allow.html
-http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-parent-same-origin-deny.html
-http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag.html
-http/tests/security/XFrameOptions/x-frame-options-deny.html
-http/tests/security/XFrameOptions/x-frame-options-parent-same-origin-allow.html
-http/tests/security/XFrameOptions/x-frame-options-parent-same-origin-deny.html
-http/tests/xmlhttprequest/abort-should-cancel-load.html
-security/block-test-no-port.html
-security/block-test.html
-webarchive/loading/cache-expired-subresource.html
-webarchive/loading/test-loading-archive.html
-webarchive/loading/test-loading-archive-subresource-null-mimetype.html
-
 # WebKitTestRunner needs textInputController
 # <https://bugs.webkit.org/show_bug.cgi?id=42337>
 editing/input/setting-input-value-cancel-ime-composition.html
@@ -798,12 +769,25 @@ fast/text-autosizing
 ########################################
 ### START OF (2) Classified failures without bug reports (yet)
 
+# WebKitTestRunner needs layoutTestController.shouldPaintBrockenImage
+fast/images/support-broken-image-delegate.html
+
+# WebKitTestRunner needs layoutTestController.setWillSendRequestReturnNullOnRedirect
+http/tests/misc/will-send-request-returns-null-on-redirect.html
+
+# WebKitTestRunner needs ReceiveServerRedirectForProvisionalLoadForFrame logging
+http/tests/loading/307-after-303-after-post.html
+http/tests/loading/redirect-methods.html
+
 # WebKitTestrunner needs layoutTestController.dumpSourceAsWebArchive
 webarchive/doctype.html
 webarchive/archive-empty-frame-source.html
 
 # WebKitTestRunner needs layoutTestController.setIconDatabaseEnabled
 webarchive/test-link-rel-icon.html
+http/tests/misc/favicon-loads-with-images-disabled.html
+http/tests/misc/favicon-loads-with-icon-loading-override.html
+http/tests/misc/link-rel-icon-beforeload.html
 
 # WebKitTestRunner should dump text/plain content as text
 http/tests/incremental/slow-utf8-text.pl
@@ -1044,6 +1028,9 @@ http/tests/security/contentSecurityPolicy/1.1
 platform/mac/fast/loader/file-url-mimetypes-2.html
 platform/mac/fast/loader/file-url-mimetypes-3.html
 platform/mac/fast/loader/file-url-mimetypes.html
+webarchive/loading/cache-expired-subresource.html
+webarchive/loading/test-loading-archive.html
+webarchive/loading/test-loading-archive-subresource-null-mimetype.html
 
 ### END OF (2) Classified failures without bug reports (yet)
 ########################################
@@ -1303,6 +1290,10 @@ fast/loader/window-properties-restored-from-page-cache.html
 # https://bugs.webkit.org/show_bug.cgi?id=81616
 fast/harness/page-cache-crash-on-data-urls.html
 
+# Wrong logging order
+fast/loader/file-protocol-fragment.html
+http/tests/loading/pdf-commit-load-callbacks.html
+
 ### END OF (3) Unclassified failures
 ########################################
 
index 898de01..74f6df3 100644 (file)
@@ -1,3 +1,14 @@
+2012-08-14  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
+
+        WebKitTestRunner needs layoutTestController.dumpResourceLoadCallbacks
+        https://bugs.webkit.org/show_bug.cgi?id=42332
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Provide build for mac.
+
+        * WebCore.exp.in: Added __ZNK7WebCore19ResourceRequestBase20firstPartyForCookiesEv.
+
 2012-08-14  Adam Barth  <abarth@webkit.org>
 
         DOMWindow::document() should not reach through Frame
index 06965fe..09600fb 100644 (file)
@@ -1216,6 +1216,7 @@ __ZNK7WebCore17ResourceErrorBase8lazyInitEv
 __ZNK7WebCore18PlatformPasteboard11changeCountEv
 __ZNK7WebCore19AnimationController24numberOfActiveAnimationsEPNS_8DocumentE
 __ZNK7WebCore19InspectorController12getHighlightEPNS_9HighlightE
+__ZNK7WebCore19ResourceRequestBase20firstPartyForCookiesEv
 __ZNK7WebCore19ResourceRequestBase10httpMethodEv
 __ZNK7WebCore19ResourceRequestBase15httpHeaderFieldEPKc
 __ZNK7WebCore19ResourceRequestBase3urlEv
index f4ec21e..eb23284 100644 (file)
@@ -1,3 +1,27 @@
+2012-08-14  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
+
+        WebKitTestRunner needs layoutTestController.dumpResourceLoadCallbacks
+        https://bugs.webkit.org/show_bug.cgi?id=42332
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Added new getters to WKURL, WKURLRequest, WKURLResponse so that it is possible
+        to dump information necessary for the tests passing.
+
+        * Shared/API/c/WKURL.cpp:
+        (WKURLCopyPath):
+        * Shared/API/c/WKURL.h:
+        * Shared/API/c/WKURLRequest.cpp:
+        (WKURLRequestCopyFirstPartyForCookies):
+        (WKURLRequestCopyHTTPMethod):
+        * Shared/API/c/WKURLRequest.h:
+        * Shared/API/c/WKURLResponse.cpp:
+        (WKURLResponseHTTPStatusCode):
+        * Shared/API/c/WKURLResponse.h:
+        * Shared/WebURL.h:
+        (WebKit::WebURL::path):
+        (WebURL):
+
 2012-08-14  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
 
         [Qt] UpdateAtlas is wasting memory
index 99cde89..2268413 100644 (file)
@@ -60,6 +60,11 @@ WKStringRef WKURLCopyScheme(WKURLRef url)
     return toCopiedAPI(toImpl(url)->protocol());
 }
 
+WK_EXPORT WKStringRef WKURLCopyPath(WKURLRef url)
+{
+    return toCopiedAPI(toImpl(url)->path());
+}
+
 WKStringRef WKURLCopyLastPathComponent(WKURLRef url)
 {
     return toCopiedAPI(toImpl(url)->lastPathComponent());
index 2cda6c1..4e98672 100644 (file)
@@ -39,6 +39,7 @@ WK_EXPORT WKURLRef WKURLCreateWithUTF8CString(const char* string);
 WK_EXPORT WKStringRef WKURLCopyString(WKURLRef url);
 WK_EXPORT WKStringRef WKURLCopyHostName(WKURLRef url);
 WK_EXPORT WKStringRef WKURLCopyScheme(WKURLRef url);
+WK_EXPORT WKStringRef WKURLCopyPath(WKURLRef url);
 WK_EXPORT WKStringRef WKURLCopyLastPathComponent(WKURLRef url);
 
 WK_EXPORT bool WKURLIsEqual(WKURLRef a, WKURLRef b);
index 776367b..114c741 100644 (file)
@@ -48,6 +48,16 @@ WKURLRef WKURLRequestCopyURL(WKURLRequestRef requestRef)
     return toCopiedURLAPI(toImpl(requestRef)->url());
 }
 
+WKURLRef WKURLRequestCopyFirstPartyForCookies(WKURLRequestRef requestRef)
+{
+    return toCopiedURLAPI(toImpl(requestRef)->resourceRequest().firstPartyForCookies());
+}
+
+WKStringRef WKURLRequestCopyHTTPMethod(WKURLRequestRef requestRef)
+{
+    return toCopiedAPI(toImpl(requestRef)->resourceRequest().httpMethod());
+}
+
 void WKURLRequestSetDefaultTimeoutInterval(double timeoutInterval)
 {
     WebURLRequest::setDefaultTimeoutInterval(timeoutInterval);
index a53ce16..85df3d3 100644 (file)
@@ -38,6 +38,10 @@ WK_EXPORT WKURLRequestRef WKURLRequestCreateWithWKURL(WKURLRef);
 
 WK_EXPORT WKURLRef WKURLRequestCopyURL(WKURLRequestRef);
 
+WK_EXPORT WKURLRef WKURLRequestCopyFirstPartyForCookies(WKURLRequestRef);
+
+WK_EXPORT WKStringRef WKURLRequestCopyHTTPMethod(WKURLRequestRef);
+
 WK_EXPORT void WKURLRequestSetDefaultTimeoutInterval(double);
 
 #ifdef __cplusplus
index cefd07d..2d25f28 100644 (file)
@@ -46,3 +46,8 @@ WKStringRef WKURLResponseCopyMIMEType(WKURLResponseRef responseRef)
 {
     return toCopiedAPI(toImpl(responseRef)->resourceResponse().mimeType());
 }
+
+int32_t WKURLResponseHTTPStatusCode(WKURLResponseRef responseRef)
+{
+    return toImpl(responseRef)->resourceResponse().httpStatusCode();
+}
index 8988dff..d4c2693 100644 (file)
@@ -38,6 +38,8 @@ WK_EXPORT WKURLRef WKURLResponseCopyURL(WKURLResponseRef);
 
 WK_EXPORT WKStringRef WKURLResponseCopyMIMEType(WKURLResponseRef);
 
+WK_EXPORT int32_t WKURLResponseHTTPStatusCode(WKURLResponseRef);
+
 #ifdef __cplusplus
 }
 #endif
index f0cce8d..b296127 100644 (file)
@@ -63,6 +63,12 @@ public:
         return m_parsedURL->isValid() ? m_parsedURL->protocol() : String();
     }
 
+    String path() const
+    {
+        parseURLIfNecessary();
+        return m_parsedURL->isValid() ? m_parsedURL->path() : String();
+    }
+
     String lastPathComponent() const
     {
         parseURLIfNecessary();
index 48c667b..811444f 100644 (file)
@@ -1,3 +1,34 @@
+2012-08-14  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
+
+        WebKitTestRunner needs layoutTestController.dumpResourceLoadCallbacks
+        https://bugs.webkit.org/show_bug.cgi?id=42332
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Added Resource Callbacks logging. Several aux dumping functions are added.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::isFileScheme):
+        (WTR):
+        (WTR::pathSuitableForTestResult):
+        (WTR::urlSuitableForTestResult):
+        (WTR::InjectedBundlePage::resetAfterTest):
+        (WTR::dumpRequestDescriptionSuitableForTestResult):
+        (WTR::dumpResponseDescriptionSuitableForTestResult):
+        (WTR::dumpErrorDescriptionSuitableForTestResult):
+        (WTR::InjectedBundlePage::didInitiateLoadForResource):
+        (WTR::InjectedBundlePage::willSendRequestForFrame):
+        (WTR::InjectedBundlePage::didReceiveResponseForResource):
+        (WTR::InjectedBundlePage::didFinishLoadForResource):
+        (WTR::InjectedBundlePage::didFailLoadForResource):
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
+        (WTR::LayoutTestController::LayoutTestController):
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.h:
+        (WTR::LayoutTestController::dumpResourceLoadCallbacks):
+        (WTR::LayoutTestController::shouldDumpResourceLoadCallbacks):
+        (LayoutTestController):
+
 2012-08-14  Alexis Menard  <alexis.menard@openbossa.org>
 
         Update INdT build bot to Mountain Lion.
index df608da..9a0a65d 100644 (file)
@@ -44,6 +44,7 @@ module WTR {
         void dumpFullScreenCallbacks();
         void dumpFrameLoadCallbacks();
         void dumpProgressFinishedCallback();
+        void dumpResourceLoadCallbacks();
         void dumpResourceResponseMIMETypes();
 
         // Special options.
index 2a3ec20..6e2f508 100644 (file)
@@ -42,6 +42,7 @@
 #include <WebKit2/WKBundleNodeHandlePrivate.h>
 #include <WebKit2/WKBundlePagePrivate.h>
 #include <WebKit2/WKURLRequest.h>
+#include <wtf/HashMap.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/StringBuilder.h>
 
@@ -215,6 +216,58 @@ static WTF::String frameToStr(WKBundleFrameRef frame)
     return stringBuilder.toString();
 }
 
+static inline bool isLocalFileScheme(WKStringRef scheme)
+{
+    return WKStringIsEqualToUTF8CStringIgnoringCase(scheme, "file");
+}
+
+static const char divider = '/';
+
+static inline WTF::String pathSuitableForTestResult(WKURLRef fileUrl)
+{
+    if (!fileUrl)
+        return String();
+
+    WKRetainPtr<WKStringRef> schemeString = adoptWK(WKURLCopyScheme(fileUrl));
+    if (!isLocalFileScheme(schemeString.get()))
+        return toWTFString(adoptWK(WKURLCopyString(fileUrl)));
+
+    String pathString = toWTFString(adoptWK(WKURLCopyPath(fileUrl)));
+    WTF::StringBuilder stringBuilder;
+
+    // Remove the leading path from file urls.
+    const size_t indexBaseName = pathString.reverseFind(divider);
+    if (indexBaseName != notFound) {
+        const size_t indexDirName = pathString.reverseFind(divider, indexBaseName - 1);
+        if (indexDirName != notFound)
+            stringBuilder.append(pathString.substring(indexDirName + 1, indexBaseName - indexDirName - 1));
+        stringBuilder.append(divider);
+        stringBuilder.append(pathString.substring(indexBaseName + 1)); // Filename.
+    } else {
+        stringBuilder.append(divider);
+        stringBuilder.append(pathString); // Return "/pathString".
+    }
+
+    return stringBuilder.toString();
+}
+
+static inline WTF::String urlSuitableForTestResult(WKURLRef fileUrl)
+{
+    if (!fileUrl)
+        return String();
+
+    WKRetainPtr<WKStringRef> schemeString = adoptWK(WKURLCopyScheme(fileUrl));
+    if (!isLocalFileScheme(schemeString.get()))
+        return toWTFString(adoptWK(WKURLCopyString(fileUrl)));
+
+    WTF::String urlString = toWTFString(adoptWK(WKURLCopyString(fileUrl)));
+    const size_t indexBaseName = urlString.reverseFind(divider);
+
+    return (indexBaseName == notFound) ? urlString : urlString.substring(indexBaseName + 1);
+}
+
+static HashMap<uint64_t, String> assignedUrlsCache;
+
 InjectedBundlePage::InjectedBundlePage(WKBundlePageRef page)
     : m_page(page)
     , m_world(AdoptWK, WKBundleScriptWorldCreateWorld())
@@ -366,6 +419,7 @@ void InjectedBundlePage::resetAfterTest()
 #else
     WebCoreTestSupport::resetInternalsObject(context);
 #endif
+    assignedUrlsCache.clear();
 }
 
 // Loader Client Callbacks
@@ -396,6 +450,70 @@ static void dumpFrameDescriptionSuitableForTestResult(WKBundleFrameRef frame)
     InjectedBundle::shared().stringBuilder()->append("\"");
 }
 
+static inline void dumpRequestDescriptionSuitableForTestResult(WKURLRequestRef request)
+{
+    WKRetainPtr<WKURLRef> url = adoptWK(WKURLRequestCopyURL(request));
+    WKRetainPtr<WKURLRef> firstParty = adoptWK(WKURLRequestCopyFirstPartyForCookies(request));
+    WKRetainPtr<WKStringRef> httpMethod = adoptWK(WKURLRequestCopyHTTPMethod(request));
+
+    InjectedBundle::shared().stringBuilder()->append("<NSURLRequest URL ");
+    InjectedBundle::shared().stringBuilder()->append(pathSuitableForTestResult(url.get()));
+    InjectedBundle::shared().stringBuilder()->append(", main document URL ");
+    InjectedBundle::shared().stringBuilder()->append(urlSuitableForTestResult(firstParty.get()));
+    InjectedBundle::shared().stringBuilder()->append(", http method ");
+
+    if (WKStringIsEmpty(httpMethod.get()))
+        InjectedBundle::shared().stringBuilder()->append("(none)");
+    else
+        InjectedBundle::shared().stringBuilder()->append(toWTFString(httpMethod));
+
+    InjectedBundle::shared().stringBuilder()->append(">");
+}
+
+static inline void dumpResponseDescriptionSuitableForTestResult(WKURLResponseRef response)
+{
+    WKRetainPtr<WKURLRef> url = adoptWK(WKURLResponseCopyURL(response));
+    if (!url) {
+        InjectedBundle::shared().stringBuilder()->append("(null)");
+        return;
+    }
+    InjectedBundle::shared().stringBuilder()->append("<NSURLResponse ");
+    InjectedBundle::shared().stringBuilder()->append(pathSuitableForTestResult(url.get()));
+    InjectedBundle::shared().stringBuilder()->append(", http status code ");
+    InjectedBundle::shared().stringBuilder()->append(WTF::String::number(WKURLResponseHTTPStatusCode(response)));
+    InjectedBundle::shared().stringBuilder()->append(">");
+}
+
+static inline void dumpErrorDescriptionSuitableForTestResult(WKErrorRef error)
+{
+    WKRetainPtr<WKStringRef> errorDomain = adoptWK(WKErrorCopyDomain(error));
+    int errorCode = WKErrorGetErrorCode(error);
+
+    // We need to do some error mapping here to match the test expectations (Mac error names are expected).
+    if (WKStringIsEqualToUTF8CString(errorDomain.get(), "WebKitNetworkError")) {
+        errorDomain = adoptWK(WKStringCreateWithUTF8CString("NSURLErrorDomain"));
+        errorCode = -999;
+    }
+
+    if (WKStringIsEqualToUTF8CString(errorDomain.get(), "WebKitPolicyError"))
+        errorDomain = adoptWK(WKStringCreateWithUTF8CString("WebKitErrorDomain"));
+
+    InjectedBundle::shared().stringBuilder()->append("<NSError domain ");
+    InjectedBundle::shared().stringBuilder()->append(toWTFString(errorDomain));
+    InjectedBundle::shared().stringBuilder()->append(", code ");
+    InjectedBundle::shared().stringBuilder()->append(String::number(errorCode));
+
+    WKRetainPtr<WKURLRef> url = adoptWK(WKErrorCopyFailingURL(error));
+    if (url.get()) {
+        WKRetainPtr<WKStringRef> urlString = adoptWK(WKURLCopyString(url.get()));
+        InjectedBundle::shared().stringBuilder()->append(", failing URL \"");
+        InjectedBundle::shared().stringBuilder()->append(toWTFString(urlString));
+        InjectedBundle::shared().stringBuilder()->append("\"");
+    }
+
+    InjectedBundle::shared().stringBuilder()->append(">");
+}
+
 void InjectedBundlePage::didStartProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef*, const void *clientInfo)
 {
     static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didStartProvisionalLoadForFrame(frame);
@@ -938,8 +1056,16 @@ void InjectedBundlePage::didDetectXSSForFrame(WKBundleFrameRef frame)
 {
 }
 
-void InjectedBundlePage::didInitiateLoadForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier, WKURLRequestRef, bool)
+void InjectedBundlePage::didInitiateLoadForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier, WKURLRequestRef request, bool)
 {
+    if (!InjectedBundle::shared().isTestRunning())
+        return;
+
+    if (!InjectedBundle::shared().layoutTestController()->shouldDumpResourceLoadCallbacks())
+        return;
+
+    WKRetainPtr<WKURLRef> url = adoptWK(WKURLRequestCopyURL(request));
+    assignedUrlsCache.add(identifier, pathSuitableForTestResult(url.get()));
 }
 
 // Resource Load Client Callbacks
@@ -954,11 +1080,23 @@ static inline bool isHTTPOrHTTPSScheme(WKStringRef scheme)
     return WKStringIsEqualToUTF8CStringIgnoringCase(scheme, "http") || WKStringIsEqualToUTF8CStringIgnoringCase(scheme, "https");
 }
 
-WKURLRequestRef InjectedBundlePage::willSendRequestForFrame(WKBundlePageRef, WKBundleFrameRef frame, uint64_t, WKURLRequestRef request, WKURLResponseRef)
+WKURLRequestRef InjectedBundlePage::willSendRequestForFrame(WKBundlePageRef, WKBundleFrameRef frame, uint64_t identifier, WKURLRequestRef request, WKURLResponseRef response)
 {
     if (InjectedBundle::shared().isTestRunning() && InjectedBundle::shared().layoutTestController()->willSendRequestReturnsNull())
         return 0;
 
+    if (InjectedBundle::shared().isTestRunning()
+        && InjectedBundle::shared().layoutTestController()->shouldDumpResourceLoadCallbacks()) {
+        InjectedBundle::shared().stringBuilder()->append(assignedUrlsCache.contains(identifier)
+                                                         ? assignedUrlsCache.get(identifier)
+                                                         : "<unknown>");
+        InjectedBundle::shared().stringBuilder()->append(" - willSendRequest ");
+        dumpRequestDescriptionSuitableForTestResult(request);
+        InjectedBundle::shared().stringBuilder()->append(" redirectResponse ");
+        dumpResponseDescriptionSuitableForTestResult(response);
+        InjectedBundle::shared().stringBuilder()->append("\n");
+    }
+
     WKRetainPtr<WKURLRef> url = adoptWK(WKURLRequestCopyURL(request));
     WKRetainPtr<WKStringRef> host = adoptWK(WKURLCopyHostName(url.get()));
     WKRetainPtr<WKStringRef> scheme = adoptWK(WKURLCopyScheme(url.get()));
@@ -990,11 +1128,21 @@ WKURLRequestRef InjectedBundlePage::willSendRequestForFrame(WKBundlePageRef, WKB
     return request;
 }
 
-void InjectedBundlePage::didReceiveResponseForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t, WKURLResponseRef response)
+void InjectedBundlePage::didReceiveResponseForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier, WKURLResponseRef response)
 {
     if (!InjectedBundle::shared().isTestRunning())
         return;
 
+    if (InjectedBundle::shared().layoutTestController()->shouldDumpResourceLoadCallbacks()) {
+        InjectedBundle::shared().stringBuilder()->append(assignedUrlsCache.contains(identifier)
+                                                         ? assignedUrlsCache.get(identifier)
+                                                         : "<unknown>");
+        InjectedBundle::shared().stringBuilder()->append(" - didReceiveResponse ");
+        dumpResponseDescriptionSuitableForTestResult(response);
+        InjectedBundle::shared().stringBuilder()->append("\n");
+    }
+
+
     if (!InjectedBundle::shared().layoutTestController()->shouldDumpResourceResponseMIMETypes())
         return;
 
@@ -1012,12 +1160,35 @@ void InjectedBundlePage::didReceiveContentLengthForResource(WKBundlePageRef, WKB
 {
 }
 
-void InjectedBundlePage::didFinishLoadForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t)
+void InjectedBundlePage::didFinishLoadForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier)
 {
+    if (!InjectedBundle::shared().isTestRunning())
+        return;
+
+    if (!InjectedBundle::shared().layoutTestController()->shouldDumpResourceLoadCallbacks())
+        return;
+
+    InjectedBundle::shared().stringBuilder()->append(assignedUrlsCache.contains(identifier)
+                                                     ? assignedUrlsCache.get(identifier)
+                                                     : "<unknown>");
+    InjectedBundle::shared().stringBuilder()->append(" - didFinishLoading\n");
 }
 
-void InjectedBundlePage::didFailLoadForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t, WKErrorRef)
+void InjectedBundlePage::didFailLoadForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t identifier, WKErrorRef error)
 {
+    if (!InjectedBundle::shared().isTestRunning())
+        return;
+
+    if (!InjectedBundle::shared().layoutTestController()->shouldDumpResourceLoadCallbacks())
+        return;
+
+    InjectedBundle::shared().stringBuilder()->append(assignedUrlsCache.contains(identifier)
+                                                     ? assignedUrlsCache.get(identifier)
+                                                     : "<unknown>");
+    InjectedBundle::shared().stringBuilder()->append(" - didFailLoadingWithError: ");
+
+    dumpErrorDescriptionSuitableForTestResult(error);
+    InjectedBundle::shared().stringBuilder()->append("\n");
 }
 
 
index cdffcae..7d1f784 100644 (file)
@@ -77,6 +77,7 @@ LayoutTestController::LayoutTestController()
     , m_dumpFullScreenCallbacks(false)
     , m_dumpFrameLoadCallbacks(false)
     , m_dumpProgressFinishedCallback(false)
+    , m_dumpResourceLoadCallbacks(false)
     , m_dumpResourceResponseMIMETypes(false)
     , m_waitToDump(false)
     , m_testRepaint(false)
index 517a516..5a62213 100644 (file)
@@ -79,6 +79,7 @@ public:
     void dumpFullScreenCallbacks() { m_dumpFullScreenCallbacks = true; }
     void dumpFrameLoadCallbacks() { setShouldDumpFrameLoadCallbacks(true); }
     void dumpProgressFinishedCallback() { setShouldDumpProgressFinishedCallback(true); }
+    void dumpResourceLoadCallbacks() { m_dumpResourceLoadCallbacks = true; }
     void dumpResourceResponseMIMETypes() { m_dumpResourceResponseMIMETypes = true; }
 
     void setShouldDumpFrameLoadCallbacks(bool value) { m_dumpFrameLoadCallbacks = value; }
@@ -163,6 +164,7 @@ public:
     bool shouldDumpFullScreenCallbacks() const { return m_dumpFullScreenCallbacks; }
     bool shouldDumpFrameLoadCallbacks() const { return m_dumpFrameLoadCallbacks; }
     bool shouldDumpProgressFinishedCallback() const { return m_dumpProgressFinishedCallback; }
+    bool shouldDumpResourceLoadCallbacks() const { return m_dumpResourceLoadCallbacks; }
     bool shouldDumpResourceResponseMIMETypes() const { return m_dumpResourceResponseMIMETypes; }
 
     bool isPolicyDelegateEnabled() const { return m_policyDelegateEnabled; }
@@ -249,6 +251,7 @@ private:
     bool m_dumpFullScreenCallbacks;
     bool m_dumpFrameLoadCallbacks;
     bool m_dumpProgressFinishedCallback;
+    bool m_dumpResourceLoadCallbacks;
     bool m_dumpResourceResponseMIMETypes;
     bool m_waitToDump; // True if waitUntilDone() has been called, but notifyDone() has not yet been called.
     bool m_testRepaint;