<!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>[177613] 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/177613">177613</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2014-12-19 17:21:38 -0800 (Fri, 19 Dec 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Win] Revise DRT logic to match Mac.

Rubberstamped by Anders Carlsson.

Update the Windows logic to perform initialization of preferences and WebKit
settings to match Mac. Also make sure that we only ever emit #EOF tokens under
the same circumstances as the Mac version.

* DumpRenderTree/win/DumpRenderTree.cpp:
(dump):
(resetWebPreferencesToConsistentValues):
(setDefaultsToConsistentValuesForTesting):
(resetWebViewToConsistentStateBeforeTesting):
(sizeWebViewForCurrentTest):
(runTest):
(createWebViewAndOffscreenWindow):
(allocateGlobalControllers):
(prepareConsistentTestingEnvironment):
(main):
(resetDefaultsToConsistentValues): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsDumpRenderTreewinDumpRenderTreecpp">trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (177612 => 177613)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2014-12-20 01:11:44 UTC (rev 177612)
+++ trunk/Tools/ChangeLog        2014-12-20 01:21:38 UTC (rev 177613)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2014-12-19  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        [Win] Revise DRT logic to match Mac.
+
+        Rubberstamped by Anders Carlsson.
+
+        Update the Windows logic to perform initialization of preferences and WebKit
+        settings to match Mac. Also make sure that we only ever emit #EOF tokens under
+        the same circumstances as the Mac version.
+
+        * DumpRenderTree/win/DumpRenderTree.cpp:
+        (dump):
+        (resetWebPreferencesToConsistentValues):
+        (setDefaultsToConsistentValuesForTesting):
+        (resetWebViewToConsistentStateBeforeTesting):
+        (sizeWebViewForCurrentTest):
+        (runTest):
+        (createWebViewAndOffscreenWindow):
+        (allocateGlobalControllers):
+        (prepareConsistentTestingEnvironment):
+        (main):
+        (resetDefaultsToConsistentValues): Deleted.
+
</ins><span class="cx"> 2014-12-19  Roger Fong  &lt;roger_fong@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed. Rollout r177605.
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreewinDumpRenderTreecpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp (177612 => 177613)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp        2014-12-20 01:11:44 UTC (rev 177612)
+++ trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp        2014-12-20 01:21:38 UTC (rev 177613)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2014 Apple Inc.  All rights reserved.
</del><ins>+ * Copyright (C) 2005-2014 Apple Inc.  All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -108,6 +108,7 @@
</span><span class="cx"> COMPtr&lt;FrameLoadDelegate&gt; sharedFrameLoadDelegate;
</span><span class="cx"> COMPtr&lt;UIDelegate&gt; sharedUIDelegate;
</span><span class="cx"> COMPtr&lt;EditingDelegate&gt; sharedEditingDelegate;
</span><ins>+COMPtr&lt;ResourceLoadDelegate&gt; resourceLoadDelegate;
</ins><span class="cx"> COMPtr&lt;HistoryDelegate&gt; sharedHistoryDelegate;
</span><span class="cx"> 
</span><span class="cx"> IWebFrame* frame;
</span><span class="lines">@@ -678,11 +679,11 @@
</span><span class="cx">     ::SendMessage(webViewWindow, WM_PAINT, 0, 0);
</span><span class="cx"> 
</span><span class="cx">     invalidateAnyPreviousWaitToDumpWatchdog();
</span><del>-    ASSERT(!gTestRunner-&gt;hasPendingWebNotificationClick());
</del><ins>+    ASSERT(!::gTestRunner-&gt;hasPendingWebNotificationClick());
</ins><span class="cx"> 
</span><del>-    _bstr_t resultString;
</del><ins>+    if (dumpTree) {
+        _bstr_t resultString;
</ins><span class="cx"> 
</span><del>-    if (dumpTree) {
</del><span class="cx">         COMPtr&lt;IWebDataSource&gt; dataSource;
</span><span class="cx">         if (SUCCEEDED(frame-&gt;dataSource(&amp;dataSource))) {
</span><span class="cx">             COMPtr&lt;IWebURLResponse&gt; response;
</span><span class="lines">@@ -701,7 +702,7 @@
</span><span class="cx">             COMPtr&lt;IWebFramePrivate&gt; framePrivate;
</span><span class="cx">             if (FAILED(frame-&gt;QueryInterface(&amp;framePrivate)))
</span><span class="cx">                 goto fail;
</span><del>-            framePrivate-&gt;renderTreeAsExternalRepresentation(gTestRunner-&gt;isPrinting(), &amp;resultString.GetBSTR());
</del><ins>+            framePrivate-&gt;renderTreeAsExternalRepresentation(::gTestRunner-&gt;isPrinting(), &amp;resultString.GetBSTR());
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (resultString.length()) {
</span><span class="lines">@@ -720,21 +721,17 @@
</span><span class="cx">         } else
</span><span class="cx">             printf(&quot;ERROR: nil result from %s&quot;, ::gTestRunner-&gt;dumpAsText() ? &quot;IDOMElement::innerText&quot; : &quot;IFrameViewPrivate::renderTreeAsExternalRepresentation&quot;);
</span><span class="cx"> 
</span><del>-        if (printSeparators) {
</del><ins>+        if (printSeparators)
</ins><span class="cx">             puts(&quot;#EOF&quot;); // terminate the content block
</span><del>-            fputs(&quot;#EOF\n&quot;, stderr);
-        }
</del><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (dumpPixelsForCurrentTest
-        &amp;&amp; gTestRunner-&gt;generatePixelResults()
-        &amp;&amp; !gTestRunner-&gt;dumpDOMAsWebArchive()
-        &amp;&amp; !gTestRunner-&gt;dumpSourceAsWebArchive())
</del><ins>+    if (dumpPixelsForCurrentTest &amp;&amp; ::gTestRunner-&gt;generatePixelResults()) {
+        // FIXME: when isPrinting is set, dump the image with page separators.
</ins><span class="cx">         dumpWebViewAsPixelsAndCompareWithExpected(gTestRunner-&gt;expectedPixelHash());
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-    printf(&quot;#EOF\n&quot;);   // terminate the (possibly empty) pixels block
</del><ins>+    puts(&quot;#EOF&quot;);   // terminate the (possibly empty) pixels block
</ins><span class="cx">     fflush(stdout);
</span><del>-    fflush(stderr);
</del><span class="cx"> 
</span><span class="cx"> fail:
</span><span class="cx">     // This will exit from our message loop.
</span><span class="lines">@@ -762,7 +759,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void resetDefaultsToConsistentValues(IWebPreferences* preferences)
</del><ins>+static void resetWebPreferencesToConsistentValues(IWebPreferences* preferences)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(preferences);
</span><span class="cx"> 
</span><span class="lines">@@ -848,8 +845,19 @@
</span><span class="cx">     prefsPrivate-&gt;setScreenFontSubstitutionEnabled(TRUE);
</span><span class="cx"> 
</span><span class="cx">     setAlwaysAcceptCookies(false);
</span><ins>+}
</ins><span class="cx"> 
</span><del>-    setlocale(LC_ALL, &quot;&quot;);
</del><ins>+// Called once on DumpRenderTree startup.
+static void setDefaultsToConsistentValuesForTesting()
+{
+#if USE(CF)
+    String libraryPath = libraryPathForDumpRenderTree();
+
+    // Set up these values before creating the WebView so that the various initializations will see these preferred values.
+    CFPreferencesSetAppValue(WebDatabaseDirectoryDefaultsKey, WebCore::pathByAppendingComponent(libraryPath, &quot;Databases&quot;).createCFString().get(), kCFPreferencesCurrentApplication);
+    CFPreferencesSetAppValue(WebStorageDirectoryDefaultsKey, WebCore::pathByAppendingComponent(libraryPath, &quot;LocalStorage&quot;).createCFString().get(), kCFPreferencesCurrentApplication);
+    CFPreferencesSetAppValue(WebKitLocalCacheDefaultsKey, WebCore::pathByAppendingComponent(libraryPath, &quot;LocalCache&quot;).createCFString().get(), kCFPreferencesCurrentApplication);
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void resetWebViewToConsistentStateBeforeTesting()
</span><span class="lines">@@ -882,15 +890,27 @@
</span><span class="cx"> 
</span><span class="cx">     COMPtr&lt;IWebPreferences&gt; preferences;
</span><span class="cx">     if (SUCCEEDED(webView-&gt;preferences(&amp;preferences)))
</span><del>-        resetDefaultsToConsistentValues(preferences.get());
</del><ins>+        resetWebPreferencesToConsistentValues(preferences.get());
</ins><span class="cx"> 
</span><span class="cx">     TestRunner::setSerializeHTTPLoads(false);
</span><span class="cx"> 
</span><del>-    if (gTestRunner) {
</del><ins>+    setlocale(LC_ALL, &quot;&quot;);
+
+    if (::gTestRunner) {
</ins><span class="cx">         JSGlobalContextRef context = frame-&gt;globalContext();
</span><span class="cx">         WebCoreTestSupport::resetInternalsObject(context);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (preferences) {
+        preferences-&gt;setContinuousSpellCheckingEnabled(TRUE);
+        // Automatic Quote Subs
+        // Automatic Link Detection
+        // Autommatic Dash substitution
+        // Automatic Spell Check
+        preferences-&gt;setGrammarCheckingEnabled(TRUE);
+        // Use Test Mode Focus Ring
+    }
+
</ins><span class="cx">     HWND viewWindow;
</span><span class="cx">     if (webViewPrivate &amp;&amp; SUCCEEDED(webViewPrivate-&gt;viewWindow(&amp;viewWindow)) &amp;&amp; viewWindow)
</span><span class="cx">         ::SetFocus(viewWindow);
</span><span class="lines">@@ -906,7 +926,7 @@
</span><span class="cx"> 
</span><span class="cx"> static void sizeWebViewForCurrentTest()
</span><span class="cx"> {
</span><del>-    bool isSVGW3CTest = (gTestRunner-&gt;testURL().find(&quot;svg\\W3C-SVG-1.1&quot;) != string::npos);
</del><ins>+    bool isSVGW3CTest = (::gTestRunner-&gt;testURL().find(&quot;svg\\W3C-SVG-1.1&quot;) != string::npos);
</ins><span class="cx">     unsigned width = isSVGW3CTest ? TestRunner::w3cSVGViewWidth : TestRunner::viewWidth;
</span><span class="cx">     unsigned height = isSVGW3CTest ? TestRunner::w3cSVGViewHeight : TestRunner::viewHeight;
</span><span class="cx"> 
</span><span class="lines">@@ -994,6 +1014,11 @@
</span><span class="cx">     static _bstr_t methodBStr(TEXT(&quot;GET&quot;));
</span><span class="cx"> 
</span><span class="cx">     CFStringRef str = CFStringCreateWithCString(0, pathOrURL.c_str(), kCFStringEncodingWindowsLatin1);
</span><ins>+    if (!str) {
+        fprintf(stderr, &quot;Failed to parse \&quot;%s\&quot; as UTF-8\n&quot;, pathOrURL.c_str());
+        return;
+    }
+
</ins><span class="cx">     CFURLRef url = CFURLCreateWithString(0, str, 0);
</span><span class="cx"> 
</span><span class="cx">     if (!url)
</span><span class="lines">@@ -1001,6 +1026,11 @@
</span><span class="cx"> 
</span><span class="cx">     CFRelease(str);
</span><span class="cx"> 
</span><ins>+    if (!url) {
+        fprintf(stderr, &quot;Failed to parse \&quot;%s\&quot; as a URL\n&quot;, pathOrURL.c_str());
+        return;
+    }
+
</ins><span class="cx">     String fallbackPath = findFontFallback(pathOrURL.c_str());
</span><span class="cx"> 
</span><span class="cx">     str = CFURLGetString(url);
</span><span class="lines">@@ -1021,29 +1051,29 @@
</span><span class="cx"> 
</span><span class="cx">     CFRelease(url);
</span><span class="cx"> 
</span><ins>+    resetWebViewToConsistentStateBeforeTesting();
+
</ins><span class="cx">     ::gTestRunner = TestRunner::create(testURL, command.expectedPixelHash);
</span><del>-    topLoadingFrame = 0;
</del><ins>+    delete[] testURL;
+    ::gTestRunner-&gt;setCustomTimeout(command.timeout);
+    topLoadingFrame = nullptr;
</ins><span class="cx">     done = false;
</span><span class="cx"> 
</span><del>-    delete[] testURL;
-
</del><span class="cx">     addFontFallbackIfPresent(fallbackPath);
</span><span class="cx"> 
</span><del>-    resetWebViewToConsistentStateBeforeTesting();
-
</del><span class="cx">     sizeWebViewForCurrentTest();
</span><del>-    gTestRunner-&gt;setIconDatabaseEnabled(false);
-    gTestRunner-&gt;clearAllApplicationCaches();
</del><ins>+    ::gTestRunner-&gt;setIconDatabaseEnabled(false);
+    ::gTestRunner-&gt;clearAllApplicationCaches();
</ins><span class="cx"> 
</span><span class="cx">     if (shouldLogFrameLoadDelegates(pathOrURL.c_str()))
</span><del>-        gTestRunner-&gt;setDumpFrameLoadCallbacks(true);
</del><ins>+        ::gTestRunner-&gt;setDumpFrameLoadCallbacks(true);
</ins><span class="cx"> 
</span><span class="cx">     COMPtr&lt;IWebView&gt; webView;
</span><span class="cx">     if (SUCCEEDED(frame-&gt;webView(&amp;webView))) {
</span><span class="cx">         COMPtr&lt;IWebViewPrivate&gt; viewPrivate;
</span><span class="cx">         if (SUCCEEDED(webView-&gt;QueryInterface(&amp;viewPrivate))) {
</span><span class="cx">             if (shouldLogHistoryDelegates(pathOrURL.c_str())) {
</span><del>-                gTestRunner-&gt;setDumpHistoryDelegateCallbacks(true);            
</del><ins>+                ::gTestRunner-&gt;setDumpHistoryDelegateCallbacks(true);            
</ins><span class="cx">                 viewPrivate-&gt;setHistoryDelegate(sharedHistoryDelegate.get());
</span><span class="cx">             } else
</span><span class="cx">                 viewPrivate-&gt;setHistoryDelegate(nullptr);
</span><span class="lines">@@ -1051,10 +1081,10 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (shouldEnableDeveloperExtras(pathOrURL.c_str())) {
</span><del>-        gTestRunner-&gt;setDeveloperExtrasEnabled(true);
</del><ins>+        ::gTestRunner-&gt;setDeveloperExtrasEnabled(true);
</ins><span class="cx">         if (shouldDumpAsText(pathOrURL.c_str())) {
</span><del>-            gTestRunner-&gt;setDumpAsText(true);
-            gTestRunner-&gt;setGeneratePixelResults(false);
</del><ins>+            ::gTestRunner-&gt;setDumpAsText(true);
+            ::gTestRunner-&gt;setGeneratePixelResults(false);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1074,13 +1104,12 @@
</span><span class="cx">     HWND hostWindow;
</span><span class="cx">     webView-&gt;hostWindow(&amp;hostWindow);
</span><span class="cx"> 
</span><del>-    COMPtr&lt;IWebMutableURLRequest&gt; request;
</del><ins>+    COMPtr&lt;IWebMutableURLRequest&gt; request, emptyRequest;
</ins><span class="cx">     HRESULT hr = WebKitCreateInstance(CLSID_WebMutableURLRequest, 0, IID_IWebMutableURLRequest, (void**)&amp;request);
</span><span class="cx">     if (FAILED(hr))
</span><span class="cx">         goto exit;
</span><span class="cx"> 
</span><span class="cx">     request-&gt;initWithURL(urlBStr, WebURLRequestUseProtocolCachePolicy, 60);
</span><del>-
</del><span class="cx">     request-&gt;setHTTPMethod(methodBStr);
</span><span class="cx">     frame-&gt;loadRequest(request.get());
</span><span class="cx"> 
</span><span class="lines">@@ -1118,19 +1147,33 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (shouldEnableDeveloperExtras(pathOrURL.c_str())) {
</span><del>-        gTestRunner-&gt;closeWebInspector();
-        gTestRunner-&gt;setDeveloperExtrasEnabled(false);
</del><ins>+        ::gTestRunner-&gt;closeWebInspector();
+        ::gTestRunner-&gt;setDeveloperExtrasEnabled(false);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     resetWebViewToConsistentStateBeforeTesting();
</span><span class="cx"> 
</span><ins>+    // Loading an empty request synchronously replaces the document with a blank one, which is necessary
+    // to stop timers, WebSockets and other activity that could otherwise spill output into next test's results.
+    if (SUCCEEDED(WebKitCreateInstance(CLSID_WebMutableURLRequest, 0, IID_IWebMutableURLRequest, (void**)&amp;emptyRequest))) {
+        _bstr_t emptyURL(L&quot;&quot;);
+        emptyRequest-&gt;initWithURL(emptyURL.GetBSTR(), WebURLRequestUseProtocolCachePolicy, 60);
+        emptyRequest-&gt;setHTTPMethod(methodBStr);
+        frame-&gt;loadRequest(request.get());
+    }
+
</ins><span class="cx">     frame-&gt;stopLoading();
</span><span class="cx"> 
</span><ins>+    // We should only have our main window left open when we're done
+    ASSERT(openWindows().size() == 1);
+    ASSERT(openWindows()[0] == hostWindow);
+
</ins><span class="cx"> exit:
</span><span class="cx">     removeFontFallbackIfPresent(fallbackPath);
</span><span class="cx">     ::gTestRunner.clear();
</span><span class="cx"> 
</span><del>-    return;
</del><ins>+    fputs(&quot;#EOF\n&quot;, stderr);
+    fflush(stderr);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Vector&lt;HWND&gt;&amp; openWindows()
</span><span class="lines">@@ -1190,15 +1233,15 @@
</span><span class="cx">     ::SetWindowPos(viewWindow, 0, 0, 0, maxViewWidth, maxViewHeight, 0);
</span><span class="cx">     ::ShowWindow(hostWindow, SW_SHOW);
</span><span class="cx"> 
</span><ins>+    if (FAILED(webView-&gt;setUIDelegate(sharedUIDelegate.get())))
+        return nullptr;
+
</ins><span class="cx">     if (FAILED(webView-&gt;setFrameLoadDelegate(sharedFrameLoadDelegate.get())))
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="cx">     if (FAILED(viewPrivate-&gt;setFrameLoadDelegatePrivate(sharedFrameLoadDelegate.get())))
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    if (FAILED(webView-&gt;setUIDelegate(sharedUIDelegate.get())))
-        return nullptr;
-
</del><span class="cx">     COMPtr&lt;IWebViewEditing&gt; viewEditing;
</span><span class="cx">     if (FAILED(webView-&gt;QueryInterface(&amp;viewEditing)))
</span><span class="cx">         return nullptr;
</span><span class="lines">@@ -1206,12 +1249,11 @@
</span><span class="cx">     if (FAILED(viewEditing-&gt;setEditingDelegate(sharedEditingDelegate.get())))
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    ResourceLoadDelegate* resourceLoadDelegate = new ResourceLoadDelegate();
-    HRESULT result = webView-&gt;setResourceLoadDelegate(resourceLoadDelegate);
-    resourceLoadDelegate-&gt;Release(); // The delegate is owned by the WebView, so release our reference to it.
-    if (FAILED(result))
</del><ins>+    if (FAILED(webView-&gt;setResourceLoadDelegate(resourceLoadDelegate.get())))
</ins><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><ins>+    viewPrivate-&gt;setDefersCallbacks(FALSE);
+
</ins><span class="cx">     openWindows().append(hostWindow);
</span><span class="cx">     windowToWebViewMap().set(hostWindow, webView);
</span><span class="cx">     return webView;
</span><span class="lines">@@ -1308,6 +1350,36 @@
</span><span class="cx">     return tests;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void allocateGlobalControllers()
+{
+    sharedFrameLoadDelegate.adoptRef(new FrameLoadDelegate);
+    sharedUIDelegate.adoptRef(new UIDelegate);
+    sharedEditingDelegate.adoptRef(new EditingDelegate);
+    resourceLoadDelegate.adoptRef(new ResourceLoadDelegate);
+    policyDelegate = new PolicyDelegate();
+    sharedHistoryDelegate.adoptRef(new HistoryDelegate);
+    // storage delegate
+    // policy delegate
+}
+
+static void prepareConsistentTestingEnvironment(IWebPreferences* standardPreferences, IWebPreferencesPrivate* standardPreferencesPrivate)
+{
+    ASSERT(standardPreferences);
+    ASSERT(standardPreferencesPrivate);
+    standardPreferences-&gt;setAutosaves(FALSE);
+
+    // FIXME - need to make DRT pass with Windows native controls &lt;http://bugs.webkit.org/show_bug.cgi?id=25592&gt;
+    standardPreferencesPrivate-&gt;setShouldPaintNativeControls(FALSE);
+    standardPreferences-&gt;setJavaScriptEnabled(TRUE);
+    standardPreferences-&gt;setDefaultFontSize(16);
+#if USE(CG)
+    standardPreferences-&gt;setAcceleratedCompositingEnabled(TRUE);
+    standardPreferences-&gt;setAVFoundationEnabled(TRUE);
+#endif
+
+    allocateGlobalControllers();
+}
+
</ins><span class="cx"> int main(int argc, const char* argv[])
</span><span class="cx"> {
</span><span class="cx"> #ifdef _CRTDBG_MAP_ALLOC
</span><span class="lines">@@ -1329,33 +1401,23 @@
</span><span class="cx"> 
</span><span class="cx">     initialize();
</span><span class="cx"> 
</span><ins>+    setDefaultsToConsistentValuesForTesting();
+
</ins><span class="cx">     Vector&lt;const char*&gt; tests = initializeGlobalsFromCommandLineOptions(argc, argv);
</span><span class="cx"> 
</span><del>-    policyDelegate = new PolicyDelegate();
-    sharedFrameLoadDelegate.adoptRef(new FrameLoadDelegate);
-    sharedUIDelegate.adoptRef(new UIDelegate);
-    sharedEditingDelegate.adoptRef(new EditingDelegate);
-    sharedHistoryDelegate.adoptRef(new HistoryDelegate);
-
</del><span class="cx">     // FIXME - need to make DRT pass with Windows native controls &lt;http://bugs.webkit.org/show_bug.cgi?id=25592&gt;
</span><span class="cx">     COMPtr&lt;IWebPreferences&gt; tmpPreferences;
</span><span class="cx">     if (FAILED(WebKitCreateInstance(CLSID_WebPreferences, 0, IID_IWebPreferences, reinterpret_cast&lt;void**&gt;(&amp;tmpPreferences))))
</span><span class="cx">         return -1;
</span><span class="cx">     COMPtr&lt;IWebPreferences&gt; standardPreferences;
</span><span class="cx">     if (FAILED(tmpPreferences-&gt;standardPreferences(&amp;standardPreferences)))
</span><del>-        return -1;
</del><ins>+        return -2;
</ins><span class="cx">     COMPtr&lt;IWebPreferencesPrivate&gt; standardPreferencesPrivate;
</span><span class="cx">     if (FAILED(standardPreferences-&gt;QueryInterface(&amp;standardPreferencesPrivate)))
</span><del>-        return -1;
-    standardPreferencesPrivate-&gt;setShouldPaintNativeControls(FALSE);
-    standardPreferences-&gt;setJavaScriptEnabled(TRUE);
-    standardPreferences-&gt;setDefaultFontSize(16);
-#if USE(CG)
-    standardPreferences-&gt;setAcceleratedCompositingEnabled(TRUE);
-    standardPreferences-&gt;setAVFoundationEnabled(TRUE);
-#endif
-    standardPreferences-&gt;setContinuousSpellCheckingEnabled(TRUE);
</del><ins>+        return -3;
</ins><span class="cx"> 
</span><ins>+    prepareConsistentTestingEnvironment(standardPreferences.get(), standardPreferencesPrivate.get());
+
</ins><span class="cx">     if (printSupportedFeatures) {
</span><span class="cx">         BOOL acceleratedCompositingAvailable;
</span><span class="cx">         standardPreferences-&gt;acceleratedCompositingEnabled(&amp;acceleratedCompositingAvailable);
</span><span class="lines">@@ -1373,27 +1435,18 @@
</span><span class="cx">         return 0;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-#if USE(CF)
-    // Set up these values before creating the WebView so that the various initializations will see these preferred values.
-    String path = libraryPathForDumpRenderTree();
-    CFPreferencesSetAppValue(WebDatabaseDirectoryDefaultsKey, WebCore::pathByAppendingComponent(path, &quot;Databases&quot;).createCFString().get(), kCFPreferencesCurrentApplication);
-    CFPreferencesSetAppValue(WebStorageDirectoryDefaultsKey, WebCore::pathByAppendingComponent(path, &quot;LocalStorage&quot;).createCFString().get(), kCFPreferencesCurrentApplication);
-    CFPreferencesSetAppValue(WebKitLocalCacheDefaultsKey, WebCore::pathByAppendingComponent(path, &quot;LocalCache&quot;).createCFString().get(), kCFPreferencesCurrentApplication);
-#endif
-
</del><span class="cx">     COMPtr&lt;IWebView&gt; webView(AdoptCOM, createWebViewAndOffscreenWindow(&amp;webViewWindow));
</span><span class="cx">     if (!webView)
</span><del>-        return -1;
</del><ins>+        return -4;
</ins><span class="cx"> 
</span><span class="cx">     COMPtr&lt;IWebIconDatabase&gt; iconDatabase;
</span><span class="cx">     COMPtr&lt;IWebIconDatabase&gt; tmpIconDatabase;
</span><span class="cx">     if (FAILED(WebKitCreateInstance(CLSID_WebIconDatabase, 0, IID_IWebIconDatabase, (void**)&amp;tmpIconDatabase)))
</span><del>-        return -1;
</del><ins>+        return -5;
</ins><span class="cx">     if (FAILED(tmpIconDatabase-&gt;sharedIconDatabase(&amp;iconDatabase)))
</span><del>-        return -1;
-        
</del><ins>+        return -6;
</ins><span class="cx">     if (FAILED(webView-&gt;mainFrame(&amp;frame)))
</span><del>-        return -1;
</del><ins>+        return -7;
</ins><span class="cx"> 
</span><span class="cx"> #if USE(CFNETWORK)
</span><span class="cx">     RetainPtr&lt;CFURLCacheRef&gt; urlCache = sharedCFURLCache();
</span></span></pre>
</div>
</div>

</body>
</html>