[Mac] _drt_descriptionSuitableForTestResult generate an exception for absolute paths...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Nov 2011 02:08:19 +0000 (02:08 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Nov 2011 02:08:19 +0000 (02:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=71342

Patch by Benjamin Poulain <bpoulain@apple.com> on 2011-11-01
Reviewed by Darin Adler.

Tools:

[NSURL _drt_descriptionSuitableForTestResult] was generating a NSRangeException due to the call to
[NSString substringFromIndex:] with an index out of the string range.

The source of this path is the test-loading-archive-subresource-null-mimetype.html which load a subresource
from the root of the disk.
The problem was hidden because the exception are catched when calling the delegate.

This patch changes _drt_descriptionSuitableForTestResult to return absolute string if the resource is not
in a subdirectory of the main frame.

* DumpRenderTree/mac/ResourceLoadDelegate.mm:
(-[NSURL _drt_descriptionSuitableForTestResult]):

LayoutTests:

Update the test results following the fix of _drt_descriptionSuitableForTestResult.

* webarchive/loading/test-loading-archive-subresource-null-mimetype-expected.txt:

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

LayoutTests/ChangeLog
LayoutTests/webarchive/loading/test-loading-archive-subresource-null-mimetype-expected.txt
Tools/ChangeLog
Tools/DumpRenderTree/mac/ResourceLoadDelegate.mm

index 2d065be..ee9ff6e 100755 (executable)
@@ -1,3 +1,14 @@
+2011-11-01  Benjamin Poulain  <bpoulain@apple.com>
+
+        [Mac] _drt_descriptionSuitableForTestResult generate an exception for absolute paths above the main frame
+        https://bugs.webkit.org/show_bug.cgi?id=71342
+
+        Reviewed by Darin Adler.
+
+        Update the test results following the fix of _drt_descriptionSuitableForTestResult.
+
+        * webarchive/loading/test-loading-archive-subresource-null-mimetype-expected.txt:
+
 2011-11-01  Anna Cavender  <annacc@chromium.org>
 
         Makes [Reflect] work for constants.
index 64df4e3..1f11658 100644 (file)
@@ -6,7 +6,10 @@ 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)
 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>
 frame "<!--framePath //<!--frame0-->-->" - didHandleOnloadEventsForFrame
 main frame - didHandleOnloadEventsForFrame
 frame "<!--framePath //<!--frame0-->-->" - didFinishLoadForFrame
index 31ef0f3..46ff287 100644 (file)
@@ -1,3 +1,23 @@
+2011-11-01  Benjamin Poulain  <bpoulain@apple.com>
+
+        [Mac] _drt_descriptionSuitableForTestResult generate an exception for absolute paths above the main frame
+        https://bugs.webkit.org/show_bug.cgi?id=71342
+
+        Reviewed by Darin Adler.
+
+        [NSURL _drt_descriptionSuitableForTestResult] was generating a NSRangeException due to the call to
+        [NSString substringFromIndex:] with an index out of the string range.
+
+        The source of this path is the test-loading-archive-subresource-null-mimetype.html which load a subresource
+        from the root of the disk.
+        The problem was hidden because the exception are catched when calling the delegate.
+
+        This patch changes _drt_descriptionSuitableForTestResult to return absolute string if the resource is not
+        in a subdirectory of the main frame.
+
+        * DumpRenderTree/mac/ResourceLoadDelegate.mm:
+        (-[NSURL _drt_descriptionSuitableForTestResult]):
+
 2011-11-01  Alok Priyadarshi  <alokp@chromium.org>
 
         [chromium] --enable-hardware-gpu flag is not recognized by run-webkit-tests
index 3d87331..468a8ce 100644 (file)
@@ -83,7 +83,11 @@ using namespace std;
 
     NSString *basePath = [[[[dataSource request] URL] path] stringByDeletingLastPathComponent];
 
-    return [[self path] substringFromIndex:[basePath length] + 1];
+    if ([[self path] hasPrefix:basePath]) {
+        ASSERT([[self path] length] >= ([basePath length] + 1));
+        return [[self path] substringFromIndex:[basePath length] + 1];
+    }
+    return [self absoluteString];
 }
 
 @end