[WK2] loader/go-back-cached-main-resource.html fails
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Aug 2013 22:38:04 +0000 (22:38 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Aug 2013 22:38:04 +0000 (22:38 +0000)
        https://bugs.webkit.org/show_bug.cgi?id=116491

        Reviewed by Tim Horton.

        * DumpRenderTree/efl/DumpRenderTreeChrome.cpp:
        * DumpRenderTree/gtk/DumpRenderTree.cpp:
        * DumpRenderTree/qt/DumpRenderTreeQt.cpp:
        * DumpRenderTree/win/DumpRenderTree.cpp:
        Added FIXMEs about making path printing normalization more compatible.

        * DumpRenderTree/mac/ResourceLoadDelegate.mm: (-[NSURL _drt_descriptionSuitableForTestResult]):
        Return last path component in cases where we used to return a full path, which is
        never desirable. Added a null check to basePath to prevent potentially getting
        an Objective C exception.

        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
        (WTR::pathSuitableForTestResult): Changed to use path for main test window, not
        for a currently loading one (which is different for tests that use multiple windows).
        Changed to return "(null)" for empty URLs to match WK1 output. Changed to return
        last path component as last fallback.
        (WTR::dumpRequestDescriptionSuitableForTestResult): We no longer need to pass main
        frame URL here, and it was potentially a wrong frame.
        (WTR::dumpResponseDescriptionSuitableForTestResult): Ditto.
        (WTR::InjectedBundlePage::willPerformClientRedirectForFrame): Ditto.
        (WTR::InjectedBundlePage::didInitiateLoadForResource): Ditto.
        (WTR::InjectedBundlePage::willSendRequestForFrame): Ditto.
        (WTR::InjectedBundlePage::didReceiveResponseForResource): Ditto.

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

LayoutTests/ChangeLog
LayoutTests/platform/mac-wk2/loader/go-back-cached-main-resource-expected.txt [deleted file]
LayoutTests/platform/wk2/TestExpectations
LayoutTests/webarchive/loading/test-loading-archive-subresource-null-mimetype-expected.txt
Tools/ChangeLog
Tools/DumpRenderTree/efl/DumpRenderTreeChrome.cpp
Tools/DumpRenderTree/gtk/DumpRenderTree.cpp
Tools/DumpRenderTree/mac/ResourceLoadDelegate.mm
Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp
Tools/DumpRenderTree/win/DumpRenderTree.cpp
Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp

index 9cb942f15d78e9d1a7f618114246a9a49d0c7982..12b0e2d3256bb3508a7c9a921d4caeb5586e84ba 100644 (file)
@@ -1,3 +1,17 @@
+2013-08-08  Alexey Proskuryakov  <ap@apple.com>
+
+        [WK2] loader/go-back-cached-main-resource.html fails
+        https://bugs.webkit.org/show_bug.cgi?id=116491
+
+        Reviewed by Tim Horton.
+
+        * platform/wk2/TestExpectations:
+        * webarchive/loading/test-loading-archive-subresource-null-mimetype-expected.txt:
+        Updated to not have file:// in results. This may not be desirable for a webarchive
+        test, but shouldn't be too bad either.
+        * platform/mac-wk2/loader/go-back-cached-main-resource-expected.txt: Deleted.
+        Cross-platform results now work.
+
 2013-08-08  Jer Noble  <jer.noble@apple.com>
 
         [EME] setMediaKeys function as defined in the EME specification does not work
diff --git a/LayoutTests/platform/mac-wk2/loader/go-back-cached-main-resource-expected.txt b/LayoutTests/platform/mac-wk2/loader/go-back-cached-main-resource-expected.txt
deleted file mode 100644 (file)
index 16cf9fe..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-resources/first-page.html - willSendRequest <NSURLRequest URL resources/first-page.html, main document URL first-page.html, http method GET> redirectResponse (null)
-<unknown> - didFinishLoading
-resources/first-page.html - didReceiveResponse <NSURLResponse resources/first-page.html, http status code 0>
-resources/first-page.html - didFinishLoading
-resources/other-page.html - willSendRequest <NSURLRequest URL resources/other-page.html, main document URL other-page.html, http method GET> redirectResponse (null)
-resources/other-page.html - didReceiveResponse <NSURLResponse resources/other-page.html, http status code 0>
-resources/other-page.html - didFinishLoading
-resources/first-page.html - willSendRequest <NSURLRequest URL resources/first-page.html, main document URL first-page.html, http method GET> redirectResponse (null)
-resources/first-page.html - didReceiveResponse <NSURLResponse resources/first-page.html, http status code 0>
-resources/first-page.html - didFinishLoading
-resources/other-page.html - willSendRequest <NSURLRequest URL resources/other-page.html, main document URL other-page.html, http method GET> redirectResponse (null)
-resources/other-page.html - didReceiveResponse <NSURLResponse resources/other-page.html, http status code 0>
-resources/other-page.html - didFinishLoading
-resources/first-page.html - willSendRequest <NSURLRequest URL resources/first-page.html, main document URL , http method GET> redirectResponse (null)
-resources/first-page.html - didReceiveResponse <NSURLResponse resources/first-page.html, http status code 0>
-resources/first-page.html - didFinishLoading
-This test check the following situation:
-
-First you navigate to a page (first-page.html).
-Then you go to another page (other-page.html).
-You repeat previous steps again (going to first-page.html and then to other-page.html).
-Finally you click back.
-The problem was that the resource load callbacks when going back to the cached main resource were not being called.
-
-See bug #112418.
index 0e9db7809b09781bf2339b318f7a7dc43c7d2fb3..8b5ad418d9d95982e146570a8f0b950c0009a489 100644 (file)
@@ -271,8 +271,6 @@ plugins/npruntime/embed-property-iframe-equality.html
 
 webkit.org/b/105952 fast/loader/submit-form-while-parsing-2.html [ Pass Failure ]
 
-webkit.org/b/116491 loader/go-back-cached-main-resource.html [ Failure ] 
-
 ### END OF (1) Classified failures with bug reports
 ########################################
 
index 627a58aa50ad8fad43bc682e610e83a7534fbad8..54bbc92bca43b3268b4b5d7034d5bf8831d59154 100644 (file)
@@ -6,11 +6,11 @@ main frame - didFinishDocumentLoadForFrame
 <unknown> - didFinishLoading
 resources/subresource-null-mimetype.webarchive - didReceiveResponse <NSURLResponse resources/subresource-null-mimetype.webarchive, http status code 0>
 frame "<!--framePath //<!--frame0-->-->" - didCommitLoadForFrame
-file:///test.png - willSendRequest <NSURLRequest URL file:///test.png, main document URL test-loading-archive-subresource-null-mimetype.html, http method GET> redirectResponse (null)
+test.png - willSendRequest <NSURLRequest URL test.png, main document URL test-loading-archive-subresource-null-mimetype.html, http method GET> redirectResponse (null)
 frame "<!--framePath //<!--frame0-->-->" - didFinishDocumentLoadForFrame
 resources/subresource-null-mimetype.webarchive - didFinishLoading
-file:///test.png - didReceiveResponse <NSURLResponse file:///Users/pecoraro/Desktop/test.png, http status code 0>
-file:///test.png - didFinishLoading
+test.png - didReceiveResponse <NSURLResponse test.png, http status code 0>
+test.png - didFinishLoading
 frame "<!--framePath //<!--frame0-->-->" - didHandleOnloadEventsForFrame
 main frame - didHandleOnloadEventsForFrame
 frame "<!--framePath //<!--frame0-->-->" - didFinishLoadForFrame
index 3e722dfd1bcf83bbcb7c34f7c752e6ca373df820..347c124d3397ea1a2e2b22bfdfe55e0bc97f8fba 100644 (file)
@@ -1,3 +1,34 @@
+2013-08-08  Alexey Proskuryakov  <ap@apple.com>
+
+        [WK2] loader/go-back-cached-main-resource.html fails
+        https://bugs.webkit.org/show_bug.cgi?id=116491
+
+        Reviewed by Tim Horton.
+
+        * DumpRenderTree/efl/DumpRenderTreeChrome.cpp:
+        * DumpRenderTree/gtk/DumpRenderTree.cpp:
+        * DumpRenderTree/qt/DumpRenderTreeQt.cpp:
+        * DumpRenderTree/win/DumpRenderTree.cpp:
+        Added FIXMEs about making path printing normalization more compatible.
+
+        * DumpRenderTree/mac/ResourceLoadDelegate.mm: (-[NSURL _drt_descriptionSuitableForTestResult]):
+        Return last path component in cases where we used to return a full path, which is
+        never desirable. Added a null check to basePath to prevent potentially getting
+        an Objective C exception.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::pathSuitableForTestResult): Changed to use path for main test window, not
+        for a currently loading one (which is different for tests that use multiple windows).
+        Changed to return "(null)" for empty URLs to match WK1 output. Changed to return
+        last path component as last fallback.
+        (WTR::dumpRequestDescriptionSuitableForTestResult): We no longer need to pass main
+        frame URL here, and it was potentially a wrong frame.
+        (WTR::dumpResponseDescriptionSuitableForTestResult): Ditto.
+        (WTR::InjectedBundlePage::willPerformClientRedirectForFrame): Ditto.
+        (WTR::InjectedBundlePage::didInitiateLoadForResource): Ditto.
+        (WTR::InjectedBundlePage::willSendRequestForFrame): Ditto.
+        (WTR::InjectedBundlePage::didReceiveResponseForResource): Ditto.
+
 2013-08-08  Alex Christensen  <achristensen@apple.com>
 
         WTR::pathSuitableForTestResult should behave the same as _drt_descriptionSuitableForTestResult so we can unskip tests.
index 5a63384d8f6488cb29715145e17129e411d15526..bc97188c65dc4e0c4dfe55617eaf16780ca7fa10 100644 (file)
@@ -336,6 +336,7 @@ void DumpRenderTreeChrome::resetDefaultsToConsistentValues()
     policyDelegatePermissive = false;
 }
 
+// FIXME (119585): Make this match other platforms better.
 static CString pathSuitableForTestResult(const char* uriString)
 {
     if (!uriString)
index 83212e65d4d00d5889e395d5deb39952967ca8c7..f155fb803b4720e3152a26b62391c71c6d3ccc5a 100644 (file)
@@ -1140,7 +1140,7 @@ static void frameCreatedCallback(WebKitWebView* webView, WebKitWebFrame* webFram
     g_signal_connect(webFrame, "insecure-content-run", G_CALLBACK(didRunInsecureContent), NULL);
 }
 
-
+// FIXME (119584): Make this match other platforms better.
 static CString pathFromSoupURI(SoupURI* uri)
 {
     if (!uri)
index c5b26442c3825709cede90de4722c1ea8bb301c8..0f558ee29c026d83544655358eac3eb1d4c20b39 100644 (file)
@@ -84,9 +84,9 @@ using namespace std;
     NSString *basePath = [[[[dataSource request] URL] path] stringByDeletingLastPathComponent];
     basePath = [basePath stringByAppendingString:@"/"];
 
-    if ([[self path] hasPrefix:basePath])
+    if (basePath && [[self path] hasPrefix:basePath])
         return [[self path] substringFromIndex:[basePath length]];
-    return [self absoluteString];
+    return [self lastPathComponent]; // We lose some information here, but it's better than exposing a full path, which is always machine specific.
 }
 
 @end
index c0c285353720cdef355c1768807bb68c216ebc43..13462143d93beffd10354afdda702ccadc6aa26b 100755 (executable)
@@ -275,6 +275,7 @@ void WebPage::permissionSet(QWebPage::Feature feature)
     }
 }
 
+// FIXME (119591): Make this match other platforms better.
 static QString urlSuitableForTestResult(const QString& url)
 {
     if (url.isEmpty() || !url.startsWith(QLatin1String("file://")))
index 46c528a6df5453e25c2368e1bc46d8a1e0bf9488..75b0f78a53e567ec9a7e311c4964143f75138e6d 100644 (file)
@@ -141,6 +141,7 @@ static RetainPtr<CFStringRef> substringFromIndex(CFStringRef string, CFIndex ind
     return adoptCF(CFStringCreateWithSubstring(kCFAllocatorDefault, string, CFRangeMake(index, CFStringGetLength(string) - index)));
 }
 
+// FIXME (119583): Make this match other platforms better.
 wstring urlSuitableForTestResult(const wstring& urlString)
 {
     RetainPtr<CFURLRef> url = adoptCF(CFURLCreateWithBytes(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(urlString.c_str()), urlString.length() * sizeof(wstring::value_type), kCFStringEncodingUTF16, 0));
index 959a88266d1b5645912a0cebba539389481ed4dc..932367fb0822edbae34cd10bf32eadde57dc0801 100644 (file)
@@ -235,22 +235,27 @@ static inline bool isLocalFileScheme(WKStringRef scheme)
 
 static const char divider = '/';
 
-static inline WTF::String pathSuitableForTestResult(WKURLRef fileUrl, WKURLRef mainFrameURL)
+static inline WTF::String pathSuitableForTestResult(WKURLRef fileUrl)
 {
     if (!fileUrl)
-        return String();
+        return "(null)";
 
     WKRetainPtr<WKStringRef> schemeString = adoptWK(WKURLCopyScheme(fileUrl));
     if (!isLocalFileScheme(schemeString.get()))
         return toWTFString(adoptWK(WKURLCopyString(fileUrl)));
 
+    WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
+    WKRetainPtr<WKURLRef> mainFrameURL = adoptWK(WKBundleFrameCopyURL(mainFrame));
+    if (!mainFrameURL)
+        mainFrameURL = adoptWK(WKBundleFrameCopyProvisionalURL(mainFrame));
+
     String pathString = toWTFString(adoptWK(WKURLCopyPath(fileUrl)));
-    String mainFrameURLPathString = toWTFString(adoptWK(WKURLCopyPath(mainFrameURL)));
+    String mainFrameURLPathString = toWTFString(adoptWK(WKURLCopyPath(mainFrameURL.get())));
     String basePath = mainFrameURLPathString.substring(0, mainFrameURLPathString.reverseFind(divider) + 1);
     
-    if (pathString.startsWith(basePath))
+    if (!basePath.isEmpty() && pathString.startsWith(basePath))
         return pathString.substring(basePath.length());
-    return toWTFString(adoptWK(WKURLCopyString(fileUrl)));
+    return toWTFString(adoptWK(WKURLCopyLastPathComponent(fileUrl))); // We lose some information here, but it's better than exposing a full path, which is always machine specific.
 }
 
 static HashMap<uint64_t, String> assignedUrlsCache;
@@ -468,16 +473,16 @@ static void dumpLoadEvent(WKBundleFrameRef frame, const char* eventName)
     InjectedBundle::shared().outputText(stringBuilder.toString());
 }
 
-static inline void dumpRequestDescriptionSuitableForTestResult(WKURLRequestRef request, StringBuilder& stringBuilder, WKURLRef mainFrameURL)
+static inline void dumpRequestDescriptionSuitableForTestResult(WKURLRequestRef request, StringBuilder& stringBuilder)
 {
     WKRetainPtr<WKURLRef> url = adoptWK(WKURLRequestCopyURL(request));
     WKRetainPtr<WKURLRef> firstParty = adoptWK(WKURLRequestCopyFirstPartyForCookies(request));
     WKRetainPtr<WKStringRef> httpMethod = adoptWK(WKURLRequestCopyHTTPMethod(request));
 
     stringBuilder.appendLiteral("<NSURLRequest URL ");
-    stringBuilder.append(pathSuitableForTestResult(url.get(), mainFrameURL));
+    stringBuilder.append(pathSuitableForTestResult(url.get()));
     stringBuilder.appendLiteral(", main document URL ");
-    stringBuilder.append(pathSuitableForTestResult(firstParty.get(), mainFrameURL));
+    stringBuilder.append(pathSuitableForTestResult(firstParty.get()));
     stringBuilder.appendLiteral(", http method ");
 
     if (WKStringIsEmpty(httpMethod.get()))
@@ -488,7 +493,7 @@ static inline void dumpRequestDescriptionSuitableForTestResult(WKURLRequestRef r
     stringBuilder.append('>');
 }
 
-static inline void dumpResponseDescriptionSuitableForTestResult(WKURLResponseRef response, StringBuilder& stringBuilder, WKURLRef mainFrameURL)
+static inline void dumpResponseDescriptionSuitableForTestResult(WKURLResponseRef response, StringBuilder& stringBuilder)
 {
     WKRetainPtr<WKURLRef> url = adoptWK(WKURLResponseCopyURL(response));
     if (!url) {
@@ -496,7 +501,7 @@ static inline void dumpResponseDescriptionSuitableForTestResult(WKURLResponseRef
         return;
     }
     stringBuilder.appendLiteral("<NSURLResponse ");
-    stringBuilder.append(pathSuitableForTestResult(url.get(), mainFrameURL));
+    stringBuilder.append(pathSuitableForTestResult(url.get()));
     stringBuilder.appendLiteral(", http status code ");
     stringBuilder.appendNumber(WKURLResponseHTTPStatusCode(response));
     stringBuilder.append('>');
@@ -974,7 +979,7 @@ void InjectedBundlePage::didCancelClientRedirectForFrame(WKBundleFrameRef frame)
     dumpLoadEvent(frame, "didCancelClientRedirectForFrame");
 }
 
-void InjectedBundlePage::willPerformClientRedirectForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKURLRef url, double delay, double date)
+void InjectedBundlePage::willPerformClientRedirectForFrame(WKBundlePageRef, WKBundleFrameRef frame, WKURLRef url, double delay, double date)
 {
     if (!InjectedBundle::shared().isTestRunning())
         return;
@@ -983,10 +988,9 @@ void InjectedBundlePage::willPerformClientRedirectForFrame(WKBundlePageRef page,
         return;
 
     StringBuilder stringBuilder;
-    WKRetainPtr<WKURLRef> mainFrameURL = adoptWK(WKBundleFrameCopyURL(WKBundlePageGetMainFrame(page)));
     dumpFrameDescriptionSuitableForTestResult(frame, stringBuilder);
     stringBuilder.appendLiteral(" - willPerformClientRedirectToURL: ");
-    stringBuilder.append(pathSuitableForTestResult(url, mainFrameURL.get()));
+    stringBuilder.append(pathSuitableForTestResult(url));
     stringBuilder.appendLiteral(" \n");
     InjectedBundle::shared().outputText(stringBuilder.toString());
 }
@@ -1050,8 +1054,7 @@ void InjectedBundlePage::didInitiateLoadForResource(WKBundlePageRef page, WKBund
         return;
 
     WKRetainPtr<WKURLRef> url = adoptWK(WKURLRequestCopyURL(request));
-    WKRetainPtr<WKURLRef> mainFrameURL = adoptWK(WKBundleFrameCopyURL(WKBundlePageGetMainFrame(page)));
-    assignedUrlsCache.add(identifier, pathSuitableForTestResult(url.get(), mainFrameURL.get()));
+    assignedUrlsCache.add(identifier, pathSuitableForTestResult(url.get()));
 }
 
 // Resource Load Client Callbacks
@@ -1073,10 +1076,9 @@ WKURLRequestRef InjectedBundlePage::willSendRequestForFrame(WKBundlePageRef page
         StringBuilder stringBuilder;
         dumpResourceURL(identifier, stringBuilder);
         stringBuilder.appendLiteral(" - willSendRequest ");
-        WKRetainPtr<WKURLRef> mainFrameURL = adoptWK(WKBundleFrameCopyURL(WKBundlePageGetMainFrame(page)));
-        dumpRequestDescriptionSuitableForTestResult(request, stringBuilder, mainFrameURL.get());
+        dumpRequestDescriptionSuitableForTestResult(request, stringBuilder);
         stringBuilder.appendLiteral(" redirectResponse ");
-        dumpResponseDescriptionSuitableForTestResult(response, stringBuilder, mainFrameURL.get());
+        dumpResponseDescriptionSuitableForTestResult(response, stringBuilder);
         stringBuilder.append('\n');
         InjectedBundle::shared().outputText(stringBuilder.toString());
     }
@@ -1132,8 +1134,7 @@ void InjectedBundlePage::didReceiveResponseForResource(WKBundlePageRef page, WKB
         StringBuilder stringBuilder;
         dumpResourceURL(identifier, stringBuilder);
         stringBuilder.appendLiteral(" - didReceiveResponse ");
-        WKRetainPtr<WKURLRef> mainFrameURL = adoptWK(WKBundleFrameCopyURL(WKBundlePageGetMainFrame(page)));
-        dumpResponseDescriptionSuitableForTestResult(response, stringBuilder, mainFrameURL.get());
+        dumpResponseDescriptionSuitableForTestResult(response, stringBuilder);
         stringBuilder.append('\n');
         InjectedBundle::shared().outputText(stringBuilder.toString());
     }