<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[182017] trunk/Tools</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/182017">182017</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2015-03-26 11:12:56 -0700 (Thu, 26 Mar 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Mac] Add an --allowed-host argument to DRT and WKTR to allow tests to connect to non-localhost servers
https://bugs.webkit.org/show_bug.cgi?id=142931
Reviewed by Brent Fulgham.
Currently, both DRT and WKTR will refuse to allow network connections to non-localhost servers
over HTTP/HTTPS. For certain testing scenarios, however, it would be useful if both DRT and
WKTR could be allowed to make HTTP/HTTPS connections to certain, specific servers defined at
runtime.
To allow this, add an optional argument to DRT and WKTR, --allowed-host, which will add the specified
hostname to a whitelist; requests to these hosts will allowed to proceed normally.
Drive-by fix: in InjectedBundlePage::willSendRequestForFrame, we get the top loading frame from the
injected bundle. But after the main resource load completes, the bundle nulls out it's pointer to the
top loading frame, which causes a subsequent crash when further resources are requested. Instead, get
the top loading frame from the page, as we do elsewhere in this class.
* DumpRenderTree/TestRunner.h:
(TestRunner::allowedHosts):
(TestRunner::setAllowedHosts):
* DumpRenderTree/mac/DumpRenderTree.mm:
(initializeGlobalsFromCommandLineOptions):
(runTest):
* DumpRenderTree/mac/ResourceLoadDelegate.mm:
(isAllowedHost):
(-[ResourceLoadDelegate webView:resource:willSendRequest:redirectResponse:fromDataSource:]):
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didReceiveMessage):
(WTR::InjectedBundle::isAllowedHost):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::isAllowedHost):
(WTR::InjectedBundlePage::willSendRequestForFrame):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/Options.cpp:
(WTR::handleOptionAllowedHost):
(WTR::OptionsHandler::OptionsHandler):
* WebKitTestRunner/Options.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::initialize):
(WTR::TestController::resetStateToConsistentValues):
* WebKitTestRunner/TestController.h:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsDumpRenderTreeTestRunnerh">trunk/Tools/DumpRenderTree/TestRunner.h</a></li>
<li><a href="#trunkToolsDumpRenderTreemacDumpRenderTreemm">trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm</a></li>
<li><a href="#trunkToolsDumpRenderTreemacResourceLoadDelegatemm">trunk/Tools/DumpRenderTree/mac/ResourceLoadDelegate.mm</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleInjectedBundlecpp">trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleInjectedBundleh">trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleInjectedBundlePagecpp">trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleTestRunnerh">trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnerOptionscpp">trunk/Tools/WebKitTestRunner/Options.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerOptionsh">trunk/Tools/WebKitTestRunner/Options.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestControllercpp">trunk/Tools/WebKitTestRunner/TestController.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestControllerh">trunk/Tools/WebKitTestRunner/TestController.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (182016 => 182017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-03-26 17:45:12 UTC (rev 182016)
+++ trunk/Tools/ChangeLog        2015-03-26 18:12:56 UTC (rev 182017)
</span><span class="lines">@@ -1,3 +1,49 @@
</span><ins>+2015-03-26 Jer Noble <jer.noble@apple.com>
+
+ [Mac] Add an --allowed-host argument to DRT and WKTR to allow tests to connect to non-localhost servers
+ https://bugs.webkit.org/show_bug.cgi?id=142931
+
+ Reviewed by Brent Fulgham.
+
+ Currently, both DRT and WKTR will refuse to allow network connections to non-localhost servers
+ over HTTP/HTTPS. For certain testing scenarios, however, it would be useful if both DRT and
+ WKTR could be allowed to make HTTP/HTTPS connections to certain, specific servers defined at
+ runtime.
+
+ To allow this, add an optional argument to DRT and WKTR, --allowed-host, which will add the specified
+ hostname to a whitelist; requests to these hosts will allowed to proceed normally.
+
+ Drive-by fix: in InjectedBundlePage::willSendRequestForFrame, we get the top loading frame from the
+ injected bundle. But after the main resource load completes, the bundle nulls out it's pointer to the
+ top loading frame, which causes a subsequent crash when further resources are requested. Instead, get
+ the top loading frame from the page, as we do elsewhere in this class.
+
+ * DumpRenderTree/TestRunner.h:
+ (TestRunner::allowedHosts):
+ (TestRunner::setAllowedHosts):
+ * DumpRenderTree/mac/DumpRenderTree.mm:
+ (initializeGlobalsFromCommandLineOptions):
+ (runTest):
+ * DumpRenderTree/mac/ResourceLoadDelegate.mm:
+ (isAllowedHost):
+ (-[ResourceLoadDelegate webView:resource:willSendRequest:redirectResponse:fromDataSource:]):
+ * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+ (WTR::InjectedBundle::didReceiveMessage):
+ (WTR::InjectedBundle::isAllowedHost):
+ * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+ * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+ (WTR::isAllowedHost):
+ (WTR::InjectedBundlePage::willSendRequestForFrame):
+ * WebKitTestRunner/InjectedBundle/TestRunner.h:
+ * WebKitTestRunner/Options.cpp:
+ (WTR::handleOptionAllowedHost):
+ (WTR::OptionsHandler::OptionsHandler):
+ * WebKitTestRunner/Options.h:
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::TestController::initialize):
+ (WTR::TestController::resetStateToConsistentValues):
+ * WebKitTestRunner/TestController.h:
+
</ins><span class="cx"> 2015-03-26 Brady Eidson <beidson@apple.com>
</span><span class="cx">
</span><span class="cx"> Apply ContentExtension actions after redirects.
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreeTestRunnerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/TestRunner.h (182016 => 182017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/TestRunner.h        2015-03-26 17:45:12 UTC (rev 182016)
+++ trunk/Tools/DumpRenderTree/TestRunner.h        2015-03-26 18:12:56 UTC (rev 182017)
</span><span class="lines">@@ -52,6 +52,8 @@
</span><span class="cx"> void makeWindowObject(JSContextRef, JSObjectRef windowObject, JSValueRef* exception);
</span><span class="cx">
</span><span class="cx"> void addDisallowedURL(JSStringRef url);
</span><ins>+ const std::set<std::string>& allowedHosts() const { return m_allowedHosts; }
+ void setAllowedHosts(std::set<std::string> hosts) { m_allowedHosts = WTF::move(hosts); }
</ins><span class="cx"> void addURLToRedirect(std::string origin, std::string destination);
</span><span class="cx"> const std::string& redirectionDestinationForURL(std::string);
</span><span class="cx"> void clearAllApplicationCaches();
</span><span class="lines">@@ -418,11 +420,12 @@
</span><span class="cx"> std::string m_titleTextDirection;
</span><span class="cx">
</span><span class="cx"> std::set<std::string> m_willSendRequestClearHeaders;
</span><ins>+ std::set<std::string> m_allowedHosts;
</ins><span class="cx">
</span><span class="cx"> std::vector<char> m_audioResult;
</span><span class="cx">
</span><span class="cx"> std::map<std::string, std::string> m_URLsToRedirect;
</span><del>-
</del><ins>+
</ins><span class="cx"> static JSClassRef getJSClass();
</span><span class="cx"> static JSStaticValue* staticValues();
</span><span class="cx"> static JSStaticFunction* staticFunctions();
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreemacDumpRenderTreemm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (182016 => 182017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm        2015-03-26 17:45:12 UTC (rev 182016)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm        2015-03-26 18:12:56 UTC (rev 182017)
</span><span class="lines">@@ -202,6 +202,7 @@
</span><span class="cx"> static int gcBetweenTests;
</span><span class="cx"> static BOOL printSeparators;
</span><span class="cx"> static RetainPtr<CFStringRef> persistentUserStyleSheetLocation;
</span><ins>+static std::set<std::string> allowedHosts;
</ins><span class="cx">
</span><span class="cx"> static WebHistoryItem *prevTestBFItem = nil; // current b/f item at the end of the previous test
</span><span class="cx">
</span><span class="lines">@@ -1080,6 +1081,7 @@
</span><span class="cx"> {"accelerated-drawing", no_argument, &useAcceleratedDrawing, YES},
</span><span class="cx"> {"gc-between-tests", no_argument, &gcBetweenTests, YES},
</span><span class="cx"> {"no-timeout", no_argument, &useTimeoutWatchdog, NO},
</span><ins>+ {"allowed-host", required_argument, nullptr, 'a'},
</ins><span class="cx"> {nullptr, 0, nullptr, 0}
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -1090,6 +1092,9 @@
</span><span class="cx"> case ':': // missing argument
</span><span class="cx"> exit(1);
</span><span class="cx"> break;
</span><ins>+ case 'a': // "allowed-host"
+ allowedHosts.insert(optarg);
+ break;
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -1880,6 +1885,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> gTestRunner = TestRunner::create(testURL, command.expectedPixelHash);
</span><ins>+ gTestRunner->setAllowedHosts(allowedHosts);
</ins><span class="cx"> gTestRunner->setCustomTimeout(command.timeout);
</span><span class="cx"> topLoadingFrame = nil;
</span><span class="cx"> #if !PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreemacResourceLoadDelegatemm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/mac/ResourceLoadDelegate.mm (182016 => 182017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/mac/ResourceLoadDelegate.mm        2015-03-26 17:45:12 UTC (rev 182016)
+++ trunk/Tools/DumpRenderTree/mac/ResourceLoadDelegate.mm        2015-03-26 18:12:56 UTC (rev 182017)
</span><span class="lines">@@ -137,6 +137,11 @@
</span><span class="cx"> return NSOrderedSame == [host compare:@"255.255.255.255"];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+BOOL isAllowedHost(NSString *host)
+{
+ return gTestRunner->allowedHosts().count(host.UTF8String);
+}
+
</ins><span class="cx"> -(NSURLRequest *)webView: (WebView *)wv resource:identifier willSendRequest: (NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource
</span><span class="cx"> {
</span><span class="cx"> if (!done && gTestRunner->dumpResourceLoadCallbacks()) {
</span><span class="lines">@@ -165,7 +170,7 @@
</span><span class="cx"> NSString *testHost = 0;
</span><span class="cx"> if ([lowercaseTestURL hasPrefix:@"http:"] || [lowercaseTestURL hasPrefix:@"https:"])
</span><span class="cx"> testHost = [[NSURL URLWithString:testURL] host];
</span><del>- if (!isLocalhost(host) && !hostIsUsedBySomeTestsToGenerateError(host) && (!testHost || isLocalhost(testHost))) {
</del><ins>+ if (!isLocalhost(host) && !hostIsUsedBySomeTestsToGenerateError(host) && !isAllowedHost(host) && (!testHost || isLocalhost(testHost))) {
</ins><span class="cx"> printf("Blocked access to external URL %s\n", [[url absoluteString] cStringUsingEncoding:NSUTF8StringEncoding]);
</span><span class="cx"> return nil;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleInjectedBundlecpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (182016 => 182017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp        2015-03-26 17:45:12 UTC (rev 182016)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp        2015-03-26 18:12:56 UTC (rev 182017)
</span><span class="lines">@@ -166,6 +166,17 @@
</span><span class="cx"> if (shouldGC)
</span><span class="cx"> WKBundleGarbageCollectJavaScriptObjects(m_bundle);
</span><span class="cx">
</span><ins>+ WKRetainPtr<WKStringRef> allowedHostsKey(AdoptWK, WKStringCreateWithUTF8CString("AllowedHosts"));
+ WKTypeRef allowedHostsValue = WKDictionaryGetItemForKey(messageBodyDictionary, allowedHostsKey.get());
+ if (allowedHostsValue && WKGetTypeID(allowedHostsValue) == WKArrayGetTypeID()) {
+ WKArrayRef allowedHostsArray = static_cast<WKArrayRef>(allowedHostsValue);
+ for (size_t i = 0, size = WKArrayGetSize(allowedHostsArray); i < size; ++i) {
+ WKTypeRef item = WKArrayGetItemAtIndex(allowedHostsArray, i);
+ if (item && WKGetTypeID(item) == WKStringGetTypeID())
+ m_allowedHosts.append(toWTFString(static_cast<WKStringRef>(item)));
+ }
+ }
+
</ins><span class="cx"> m_state = Idle;
</span><span class="cx"> m_dumpPixels = false;
</span><span class="cx">
</span><span class="lines">@@ -599,4 +610,11 @@
</span><span class="cx"> WKBundlePostMessage(m_bundle, messageName.get(), script);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool InjectedBundle::isAllowedHost(WKStringRef host)
+{
+ if (m_allowedHosts.isEmpty())
+ return false;
+ return m_allowedHosts.contains(toWTFString(host));
+}
+
</ins><span class="cx"> } // namespace WTR
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleInjectedBundleh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h (182016 => 182017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h        2015-03-26 17:45:12 UTC (rev 182016)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h        2015-03-26 18:12:56 UTC (rev 182017)
</span><span class="lines">@@ -115,6 +115,8 @@
</span><span class="cx"> void queueLoadingScript(WKStringRef script);
</span><span class="cx"> void queueNonLoadingScript(WKStringRef script);
</span><span class="cx">
</span><ins>+ bool isAllowedHost(WKStringRef);
+
</ins><span class="cx"> private:
</span><span class="cx"> InjectedBundle();
</span><span class="cx"> ~InjectedBundle();
</span><span class="lines">@@ -165,6 +167,8 @@
</span><span class="cx"> WKRetainPtr<WKDataRef> m_audioResult;
</span><span class="cx"> WKRetainPtr<WKImageRef> m_pixelResult;
</span><span class="cx"> WKRetainPtr<WKArrayRef> m_repaintRects;
</span><ins>+
+ Vector<String> m_allowedHosts;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WTR
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleInjectedBundlePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp (182016 => 182017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp        2015-03-26 17:45:12 UTC (rev 182016)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp        2015-03-26 18:12:56 UTC (rev 182017)
</span><span class="lines">@@ -1077,6 +1077,11 @@
</span><span class="cx"> return WKStringIsEqualToUTF8CStringIgnoringCase(scheme, "http") || WKStringIsEqualToUTF8CStringIgnoringCase(scheme, "https");
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static inline bool isAllowedHost(WKStringRef host)
+{
+ return InjectedBundle::singleton().isAllowedHost(host);
+}
+
</ins><span class="cx"> WKURLRequestRef InjectedBundlePage::willSendRequestForFrame(WKBundlePageRef page, WKBundleFrameRef frame, uint64_t identifier, WKURLRequestRef request, WKURLResponseRef response)
</span><span class="cx"> {
</span><span class="cx"> auto& injectedBundle = InjectedBundle::singleton();
</span><span class="lines">@@ -1111,7 +1116,7 @@
</span><span class="cx"> && !isLocalHost(host.get())) {
</span><span class="cx"> bool mainFrameIsExternal = false;
</span><span class="cx"> if (injectedBundle.isTestRunning()) {
</span><del>- WKBundleFrameRef mainFrame = injectedBundle.topLoadingFrame();
</del><ins>+ WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(m_page);
</ins><span class="cx"> WKRetainPtr<WKURLRef> mainFrameURL = adoptWK(WKBundleFrameCopyURL(mainFrame));
</span><span class="cx"> if (!mainFrameURL || WKStringIsEqualToUTF8CString(adoptWK(WKURLCopyString(mainFrameURL.get())).get(), "about:blank"))
</span><span class="cx"> mainFrameURL = adoptWK(WKBundleFrameCopyProvisionalURL(mainFrame));
</span><span class="lines">@@ -1120,7 +1125,7 @@
</span><span class="cx"> WKRetainPtr<WKStringRef> mainFrameScheme = adoptWK(WKURLCopyScheme(mainFrameURL.get()));
</span><span class="cx"> mainFrameIsExternal = isHTTPOrHTTPSScheme(mainFrameScheme.get()) && !isLocalHost(mainFrameHost.get());
</span><span class="cx"> }
</span><del>- if (!mainFrameIsExternal) {
</del><ins>+ if (!mainFrameIsExternal && !isAllowedHost(host.get())) {
</ins><span class="cx"> StringBuilder stringBuilder;
</span><span class="cx"> stringBuilder.appendLiteral("Blocked access to external URL ");
</span><span class="cx"> stringBuilder.append(toWTFString(urlString));
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleTestRunnerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (182016 => 182017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h        2015-03-26 17:45:12 UTC (rev 182016)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h        2015-03-26 18:12:56 UTC (rev 182017)
</span><span class="lines">@@ -331,6 +331,8 @@
</span><span class="cx"> bool m_userStyleSheetEnabled;
</span><span class="cx"> WKRetainPtr<WKStringRef> m_userStyleSheetLocation;
</span><span class="cx">
</span><ins>+ WKRetainPtr<WKArrayRef> m_allowedHosts;
+
</ins><span class="cx"> PlatformTimerRef m_waitToDumpWatchdogTimer;
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerOptionscpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/Options.cpp (182016 => 182017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/Options.cpp        2015-03-26 17:45:12 UTC (rev 182016)
+++ trunk/Tools/WebKitTestRunner/Options.cpp        2015-03-26 18:12:56 UTC (rev 182017)
</span><span class="lines">@@ -99,6 +99,12 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool handleOptionAllowedHost(Options& options, const char*, const char* host)
+{
+ options.allowedHosts.push_back(host);
+ return true;
+}
+
</ins><span class="cx"> bool handleOptionUnmatched(Options& options, const char* option, const char*)
</span><span class="cx"> {
</span><span class="cx"> if (option[0] && option[1] && option[0] == '-' && option[1] == '-')
</span><span class="lines">@@ -120,6 +126,8 @@
</span><span class="cx"> optionList.append(Option("--complex-text", "Force complex tests.", handleOptionComplexText));
</span><span class="cx"> optionList.append(Option("--accelerated-drawing", "Use accelerated drawing.", handleOptionAcceleratedDrawing));
</span><span class="cx"> optionList.append(Option("--remote-layer-tree", "Use remote layer tree.", handleOptionRemoteLayerTree));
</span><ins>+ optionList.append(Option("--allowed-host", "Allows access to the specified host from tests.", handleOptionAllowedHost, true));
+
</ins><span class="cx"> optionList.append(Option(0, 0, handleOptionUnmatched));
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerOptionsh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/Options.h (182016 => 182017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/Options.h        2015-03-26 17:45:12 UTC (rev 182016)
+++ trunk/Tools/WebKitTestRunner/Options.h        2015-03-26 18:12:56 UTC (rev 182017)
</span><span class="lines">@@ -47,6 +47,7 @@
</span><span class="cx"> bool shouldUseAcceleratedDrawing;
</span><span class="cx"> bool shouldUseRemoteLayerTree;
</span><span class="cx"> std::vector<std::string> paths;
</span><ins>+ std::vector<std::string> allowedHosts;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> class Option {
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (182016 => 182017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestController.cpp        2015-03-26 17:45:12 UTC (rev 182016)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp        2015-03-26 18:12:56 UTC (rev 182017)
</span><span class="lines">@@ -325,6 +325,7 @@
</span><span class="cx"> m_shouldUseAcceleratedDrawing = options.shouldUseAcceleratedDrawing;
</span><span class="cx"> m_shouldUseRemoteLayerTree = options.shouldUseRemoteLayerTree;
</span><span class="cx"> m_paths = options.paths;
</span><ins>+ m_allowedHosts = options.allowedHosts;
</ins><span class="cx">
</span><span class="cx"> if (options.printSupportedFeatures) {
</span><span class="cx"> // FIXME: On Windows, DumpRenderTree uses this to expose whether it supports 3d
</span><span class="lines">@@ -612,6 +613,14 @@
</span><span class="cx"> WKRetainPtr<WKBooleanRef> shouldGCValue = adoptWK(WKBooleanCreate(m_gcBetweenTests));
</span><span class="cx"> WKDictionarySetItem(resetMessageBody.get(), shouldGCKey.get(), shouldGCValue.get());
</span><span class="cx">
</span><ins>+ WKRetainPtr<WKStringRef> allowedHostsKey = adoptWK(WKStringCreateWithUTF8CString("AllowedHosts"));
+ WKRetainPtr<WKMutableArrayRef> allowedHostsValue = adoptWK(WKMutableArrayCreate());
+ for (auto& host : m_allowedHosts) {
+ WKRetainPtr<WKStringRef> wkHost = adoptWK(WKStringCreateWithUTF8CString(host.c_str()));
+ WKArrayAppendItem(allowedHostsValue.get(), wkHost.get());
+ }
+ WKDictionarySetItem(resetMessageBody.get(), allowedHostsKey.get(), allowedHostsValue.get());
+
</ins><span class="cx"> WKContextPostMessageToInjectedBundle(TestController::singleton().context(), messageName.get(), resetMessageBody.get());
</span><span class="cx">
</span><span class="cx"> WKContextSetShouldUseFontSmoothing(TestController::singleton().context(), false);
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestController.h (182016 => 182017)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestController.h        2015-03-26 17:45:12 UTC (rev 182016)
+++ trunk/Tools/WebKitTestRunner/TestController.h        2015-03-26 18:12:56 UTC (rev 182017)
</span><span class="lines">@@ -214,6 +214,7 @@
</span><span class="cx"> bool m_gcBetweenTests;
</span><span class="cx"> bool m_shouldDumpPixelsForAllTests;
</span><span class="cx"> std::vector<std::string> m_paths;
</span><ins>+ std::vector<std::string> m_allowedHosts;
</ins><span class="cx"> WKRetainPtr<WKStringRef> m_injectedBundlePath;
</span><span class="cx"> WKRetainPtr<WKStringRef> m_testPluginDirectory;
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>