Title: [118231] trunk/Tools
Revision
118231
Author
[email protected]
Date
2012-05-23 13:21:45 -0700 (Wed, 23 May 2012)

Log Message

Mac DRT should be able to load external URLs for replay performance tests
https://bugs.webkit.org/show_bug.cgi?id=86191

Reviewed by Alexey Proskuryakov.

Let external URL requests go through if the test file is not a local file or hosted at localhost.
e.g. "DumpRenderTree http://webkit.org/" as supposed to "DumpRenderTree test.html" or
"DumpRenderTree http://localhost:8000/".

* DumpRenderTree/mac/ResourceLoadDelegate.mm:
(isLocalhost):
(hostIsUsedBySomeTestsToGenerateError):
(-[ResourceLoadDelegate webView:resource:willSendRequest:redirectResponse:fromDataSource:]):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (118230 => 118231)


--- trunk/Tools/ChangeLog	2012-05-23 20:12:34 UTC (rev 118230)
+++ trunk/Tools/ChangeLog	2012-05-23 20:21:45 UTC (rev 118231)
@@ -1,3 +1,19 @@
+2012-05-21  Ryosuke Niwa  <[email protected]>
+
+        Mac DRT should be able to load external URLs for replay performance tests
+        https://bugs.webkit.org/show_bug.cgi?id=86191
+
+        Reviewed by Alexey Proskuryakov.
+
+        Let external URL requests go through if the test file is not a local file or hosted at localhost.
+        e.g. "DumpRenderTree http://webkit.org/" as supposed to "DumpRenderTree test.html" or
+        "DumpRenderTree http://localhost:8000/".
+
+        * DumpRenderTree/mac/ResourceLoadDelegate.mm:
+        (isLocalhost):
+        (hostIsUsedBySomeTestsToGenerateError):
+        (-[ResourceLoadDelegate webView:resource:willSendRequest:redirectResponse:fromDataSource:]):
+
 2012-05-23  Malcolm MacLeod <[email protected]>
 
         [wx] In wxWebKit release builds on MSW, keep release settings but also build the 

Modified: trunk/Tools/DumpRenderTree/mac/ResourceLoadDelegate.mm (118230 => 118231)


--- trunk/Tools/DumpRenderTree/mac/ResourceLoadDelegate.mm	2012-05-23 20:12:34 UTC (rev 118230)
+++ trunk/Tools/DumpRenderTree/mac/ResourceLoadDelegate.mm	2012-05-23 20:21:45 UTC (rev 118231)
@@ -127,6 +127,17 @@
     return @"<unknown>";
 }
 
+BOOL isLocalhost(NSString *host)
+{
+    // FIXME: Support IPv6 loopbacks.
+    return NSOrderedSame == [host compare:@"127.0.0.1"] || NSOrderedSame == [host caseInsensitiveCompare:@"localhost"];
+}
+
+BOOL hostIsUsedBySomeTestsToGenerateError(NSString *host)
+{
+    return NSOrderedSame == [host compare:@"255.255.255.255"];
+}
+
 -(NSURLRequest *)webView: (WebView *)wv resource:identifier willSendRequest: (NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource
 {
     if (!done && gLayoutTestController->dumpResourceLoadCallbacks()) {
@@ -149,13 +160,16 @@
 
     NSURL *url = "" URL];
     NSString *host = [url host];
-    if (host
-        && (NSOrderedSame == [[url scheme] caseInsensitiveCompare:@"http"] || NSOrderedSame == [[url scheme] caseInsensitiveCompare:@"https"])
-        && NSOrderedSame != [host compare:@"127.0.0.1"]
-        && NSOrderedSame != [host compare:@"255.255.255.255"] // used in some tests that expect to get back an error
-        && NSOrderedSame != [host caseInsensitiveCompare:@"localhost"]) {
-        printf("Blocked access to external URL %s\n", [[url absoluteString] cStringUsingEncoding:NSUTF8StringEncoding]);
-        return nil;
+    if (host && (NSOrderedSame == [[url scheme] caseInsensitiveCompare:@"http"] || NSOrderedSame == [[url scheme] caseInsensitiveCompare:@"https"])) {
+        NSString *testPathOrURL = [NSString stringWithUTF8String:gLayoutTestController->testPathOrURL().c_str()];
+        NSString *lowercaseTestPathOrURL = [testPathOrURL lowercaseString];
+        NSString *testHost = 0;
+        if ([lowercaseTestPathOrURL hasPrefix:@"http:"] || [lowercaseTestPathOrURL hasPrefix:@"https:"])
+            testHost = [[NSURL URLWithString:testPathOrURL] host];
+        if (!isLocalhost(host) && !hostIsUsedBySomeTestsToGenerateError(host) && (!testHost || isLocalhost(testHost))) {
+            printf("Blocked access to external URL %s\n", [[url absoluteString] cStringUsingEncoding:NSUTF8StringEncoding]);
+            return nil;
+        }
     }
 
     if (disallowedURLs && CFSetContainsValue(disallowedURLs, url))
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to