[Win] Some tests are flaky because certain DLLs are writing to stdout.
authorpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Jan 2017 12:46:34 +0000 (12:46 +0000)
committerpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Jan 2017 12:46:34 +0000 (12:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=166760

Reviewed by Darin Adler.

Some tests are flaky because certain DLLs are writing to stdout, giving incorrect test results.
We can work around that by duplicating and redirecting stdout.

* DumpRenderTree/PixelDumpSupport.cpp:
(dumpWebViewAsPixelsAndCompareWithExpected):
(printPNG):
* DumpRenderTree/win/AccessibilityControllerWin.cpp:
(logEventProc):
* DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp:
(DRTDesktopNotificationPresenter::showDesktopNotification):
(DRTDesktopNotificationPresenter::cancelDesktopNotification):
(DRTDesktopNotificationPresenter::requestNotificationPermission):
* DumpRenderTree/win/DumpRenderTree.cpp:
(dumpFrameScrollPosition):
(dumpHistoryItem):
(dumpBackForwardList):
(dump):
(runTest):
(main):
* DumpRenderTree/win/DumpRenderTreeWin.h:
* DumpRenderTree/win/EditingDelegate.cpp:
(EditingDelegate::shouldBeginEditingInDOMRange):
(EditingDelegate::shouldEndEditingInDOMRange):
(EditingDelegate::shouldInsertNode):
(EditingDelegate::shouldInsertText):
(EditingDelegate::shouldDeleteDOMRange):
(EditingDelegate::shouldChangeSelectedDOMRange):
(EditingDelegate::shouldApplyStyle):
(EditingDelegate::shouldChangeTypingStyle):
(EditingDelegate::doPlatformCommand):
(EditingDelegate::webViewDidBeginEditing):
(EditingDelegate::webViewDidChange):
(EditingDelegate::webViewDidEndEditing):
(EditingDelegate::webViewDidChangeTypingStyle):
(EditingDelegate::webViewDidChangeSelection):
* DumpRenderTree/win/FrameLoadDelegate.cpp:
(FrameLoadDelegate::didStartProvisionalLoadForFrame):
(FrameLoadDelegate::didReceiveServerRedirectForProvisionalLoadForFrame):
(FrameLoadDelegate::didChangeLocationWithinPageForFrame):
(FrameLoadDelegate::didFailProvisionalLoadWithError):
(FrameLoadDelegate::didCommitLoadForFrame):
(FrameLoadDelegate::didReceiveTitle):
(FrameLoadDelegate::didFinishLoadForFrame):
(FrameLoadDelegate::didFailLoadWithError):
(FrameLoadDelegate::willPerformClientRedirectToURL):
(FrameLoadDelegate::didCancelClientRedirectForFrame):
(FrameLoadDelegate::windowScriptObjectAvailable):
(FrameLoadDelegate::didFinishDocumentLoadForFrame):
(FrameLoadDelegate::didHandleOnloadEventsForFrame):
(FrameLoadDelegate::didDisplayInsecureContent):
(FrameLoadDelegate::didRunInsecureContent):
(FrameLoadDelegate::webViewProgressFinishedNotification):
* DumpRenderTree/win/HistoryDelegate.cpp:
(HistoryDelegate::didNavigateWithNavigationData):
(HistoryDelegate::didPerformClientRedirectFromURL):
(HistoryDelegate::didPerformServerRedirectFromURL):
(HistoryDelegate::updateHistoryTitle):
(HistoryDelegate::populateVisitedLinksForWebView):
* DumpRenderTree/win/PolicyDelegate.cpp:
(PolicyDelegate::decidePolicyForNavigationAction):
(PolicyDelegate::unableToImplementPolicyWithError):
* DumpRenderTree/win/ResourceLoadDelegate.cpp:
(ResourceLoadDelegate::willSendRequest):
(ResourceLoadDelegate::didReceiveAuthenticationChallenge):
(ResourceLoadDelegate::didReceiveResponse):
(ResourceLoadDelegate::didFinishLoadingFromDataSource):
(ResourceLoadDelegate::didFailLoadingWithError):
* DumpRenderTree/win/TestRunnerWin.cpp:
(TestRunner::addDisallowedURL):
(TestRunner::originsWithApplicationCache):
(TestRunner::setStorageDatabaseIdleInterval):
(TestRunner::closeIdleLocalStorageDatabases):
(TestRunner::copyDecodedHostName):
(TestRunner::copyEncodedHostName):
(TestRunner::numberOfPendingGeolocationPermissionRequests):
(TestRunner::isGeolocationProviderActive):
(TestRunner::pathToLocalResource):
(TestRunner::setMockDeviceOrientation):
(TestRunner::setMockGeolocationPosition):
(TestRunner::setMockGeolocationPositionUnavailableError):
(TestRunner::setSpatialNavigationEnabled):
(TestRunner::setAutomaticLinkDetectionEnabled):
(TestRunner::isCommandEnabled):
(TestRunner::authenticateSession):
(TestRunner::addChromeInputField):
(TestRunner::removeChromeInputField):
(TestRunner::focusWebView):
(TestRunner::grantWebNotificationPermission):
(TestRunner::denyWebNotificationPermission):
(TestRunner::removeAllWebNotificationPermissions):
(TestRunner::simulateWebNotificationClick):
(TestRunner::imageCountInGeneralPasteboard):
* DumpRenderTree/win/UIDelegate.cpp:
(UIDelegate::runJavaScriptAlertPanelWithMessage):
(UIDelegate::runJavaScriptConfirmPanelWithMessage):
(UIDelegate::runJavaScriptTextInputPanelWithPrompt):
(UIDelegate::runBeforeUnloadConfirmPanelWithMessage):
(UIDelegate::webViewAddMessageToConsole):
(UIDelegate::exceededDatabaseQuota):
(UIDelegate::setStatusText):
(UIDelegate::didPressMissingPluginButton):

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

13 files changed:
Tools/ChangeLog
Tools/DumpRenderTree/PixelDumpSupport.cpp
Tools/DumpRenderTree/win/AccessibilityControllerWin.cpp
Tools/DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp
Tools/DumpRenderTree/win/DumpRenderTree.cpp
Tools/DumpRenderTree/win/DumpRenderTreeWin.h
Tools/DumpRenderTree/win/EditingDelegate.cpp
Tools/DumpRenderTree/win/FrameLoadDelegate.cpp
Tools/DumpRenderTree/win/HistoryDelegate.cpp
Tools/DumpRenderTree/win/PolicyDelegate.cpp
Tools/DumpRenderTree/win/ResourceLoadDelegate.cpp
Tools/DumpRenderTree/win/TestRunnerWin.cpp
Tools/DumpRenderTree/win/UIDelegate.cpp

index 6618cda..48d22b9 100644 (file)
@@ -1,3 +1,112 @@
+2017-01-06  Per Arne Vollan  <pvollan@apple.com>
+
+        [Win] Some tests are flaky because certain DLLs are writing to stdout.
+        https://bugs.webkit.org/show_bug.cgi?id=166760
+
+        Reviewed by Darin Adler.
+
+        Some tests are flaky because certain DLLs are writing to stdout, giving incorrect test results.
+        We can work around that by duplicating and redirecting stdout.
+
+        * DumpRenderTree/PixelDumpSupport.cpp:
+        (dumpWebViewAsPixelsAndCompareWithExpected):
+        (printPNG):
+        * DumpRenderTree/win/AccessibilityControllerWin.cpp:
+        (logEventProc):
+        * DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp:
+        (DRTDesktopNotificationPresenter::showDesktopNotification):
+        (DRTDesktopNotificationPresenter::cancelDesktopNotification):
+        (DRTDesktopNotificationPresenter::requestNotificationPermission):
+        * DumpRenderTree/win/DumpRenderTree.cpp:
+        (dumpFrameScrollPosition):
+        (dumpHistoryItem):
+        (dumpBackForwardList):
+        (dump):
+        (runTest):
+        (main):
+        * DumpRenderTree/win/DumpRenderTreeWin.h:
+        * DumpRenderTree/win/EditingDelegate.cpp:
+        (EditingDelegate::shouldBeginEditingInDOMRange):
+        (EditingDelegate::shouldEndEditingInDOMRange):
+        (EditingDelegate::shouldInsertNode):
+        (EditingDelegate::shouldInsertText):
+        (EditingDelegate::shouldDeleteDOMRange):
+        (EditingDelegate::shouldChangeSelectedDOMRange):
+        (EditingDelegate::shouldApplyStyle):
+        (EditingDelegate::shouldChangeTypingStyle):
+        (EditingDelegate::doPlatformCommand):
+        (EditingDelegate::webViewDidBeginEditing):
+        (EditingDelegate::webViewDidChange):
+        (EditingDelegate::webViewDidEndEditing):
+        (EditingDelegate::webViewDidChangeTypingStyle):
+        (EditingDelegate::webViewDidChangeSelection):
+        * DumpRenderTree/win/FrameLoadDelegate.cpp:
+        (FrameLoadDelegate::didStartProvisionalLoadForFrame):
+        (FrameLoadDelegate::didReceiveServerRedirectForProvisionalLoadForFrame):
+        (FrameLoadDelegate::didChangeLocationWithinPageForFrame):
+        (FrameLoadDelegate::didFailProvisionalLoadWithError):
+        (FrameLoadDelegate::didCommitLoadForFrame):
+        (FrameLoadDelegate::didReceiveTitle):
+        (FrameLoadDelegate::didFinishLoadForFrame):
+        (FrameLoadDelegate::didFailLoadWithError):
+        (FrameLoadDelegate::willPerformClientRedirectToURL):
+        (FrameLoadDelegate::didCancelClientRedirectForFrame):
+        (FrameLoadDelegate::windowScriptObjectAvailable):
+        (FrameLoadDelegate::didFinishDocumentLoadForFrame):
+        (FrameLoadDelegate::didHandleOnloadEventsForFrame):
+        (FrameLoadDelegate::didDisplayInsecureContent):
+        (FrameLoadDelegate::didRunInsecureContent):
+        (FrameLoadDelegate::webViewProgressFinishedNotification):
+        * DumpRenderTree/win/HistoryDelegate.cpp:
+        (HistoryDelegate::didNavigateWithNavigationData):
+        (HistoryDelegate::didPerformClientRedirectFromURL):
+        (HistoryDelegate::didPerformServerRedirectFromURL):
+        (HistoryDelegate::updateHistoryTitle):
+        (HistoryDelegate::populateVisitedLinksForWebView):
+        * DumpRenderTree/win/PolicyDelegate.cpp:
+        (PolicyDelegate::decidePolicyForNavigationAction):
+        (PolicyDelegate::unableToImplementPolicyWithError):
+        * DumpRenderTree/win/ResourceLoadDelegate.cpp:
+        (ResourceLoadDelegate::willSendRequest):
+        (ResourceLoadDelegate::didReceiveAuthenticationChallenge):
+        (ResourceLoadDelegate::didReceiveResponse):
+        (ResourceLoadDelegate::didFinishLoadingFromDataSource):
+        (ResourceLoadDelegate::didFailLoadingWithError):
+        * DumpRenderTree/win/TestRunnerWin.cpp:
+        (TestRunner::addDisallowedURL):
+        (TestRunner::originsWithApplicationCache):
+        (TestRunner::setStorageDatabaseIdleInterval):
+        (TestRunner::closeIdleLocalStorageDatabases):
+        (TestRunner::copyDecodedHostName):
+        (TestRunner::copyEncodedHostName):
+        (TestRunner::numberOfPendingGeolocationPermissionRequests):
+        (TestRunner::isGeolocationProviderActive):
+        (TestRunner::pathToLocalResource):
+        (TestRunner::setMockDeviceOrientation):
+        (TestRunner::setMockGeolocationPosition):
+        (TestRunner::setMockGeolocationPositionUnavailableError):
+        (TestRunner::setSpatialNavigationEnabled):
+        (TestRunner::setAutomaticLinkDetectionEnabled):
+        (TestRunner::isCommandEnabled):
+        (TestRunner::authenticateSession):
+        (TestRunner::addChromeInputField):
+        (TestRunner::removeChromeInputField):
+        (TestRunner::focusWebView):
+        (TestRunner::grantWebNotificationPermission):
+        (TestRunner::denyWebNotificationPermission):
+        (TestRunner::removeAllWebNotificationPermissions):
+        (TestRunner::simulateWebNotificationClick):
+        (TestRunner::imageCountInGeneralPasteboard):
+        * DumpRenderTree/win/UIDelegate.cpp:
+        (UIDelegate::runJavaScriptAlertPanelWithMessage):
+        (UIDelegate::runJavaScriptConfirmPanelWithMessage):
+        (UIDelegate::runJavaScriptTextInputPanelWithPrompt):
+        (UIDelegate::runBeforeUnloadConfirmPanelWithMessage):
+        (UIDelegate::webViewAddMessageToConsole):
+        (UIDelegate::exceededDatabaseQuota):
+        (UIDelegate::setStatusText):
+        (UIDelegate::didPressMissingPluginButton):
+
 2017-01-07  Tim Horton  <timothy_horton@apple.com>
 
         Add a setting to create editable MiniBrowser windows by default
index aeb902c..0ea34af 100644 (file)
 #include "PixelDumpSupportCairo.h"
 #endif
 
+#if !PLATFORM(WIN)
+#define testResult stdout
+#endif
+
 void dumpWebViewAsPixelsAndCompareWithExpected(const std::string& expectedHash)
 {
     RefPtr<BitmapContext> context;
@@ -57,14 +61,14 @@ void dumpWebViewAsPixelsAndCompareWithExpected(const std::string& expectedHash)
     // Compute the hash of the bitmap context pixels
     char actualHash[33];
     computeMD5HashStringForBitmapContext(context.get(), actualHash);
-    printf("\nActualHash: %s\n", actualHash); // FIXME: No need for the leading newline.
+    fprintf(testResult, "\nActualHash: %s\n", actualHash); // FIXME: No need for the leading newline.
 
     // Check the computed hash against the expected one and dump image on mismatch
     bool dumpImage = true;
     if (expectedHash.length() > 0) {
         ASSERT(expectedHash.length() == 32);
 
-        printf("\nExpectedHash: %s\n", expectedHash.c_str()); // FIXME: No need for the leading newline.
+        fprintf(testResult, "\nExpectedHash: %s\n", expectedHash.c_str()); // FIXME: No need for the leading newline.
         
         if (expectedHash == actualHash) // FIXME: do case insensitive compare
             dumpImage = false;
@@ -114,20 +118,20 @@ void printPNG(const unsigned char* data, const size_t dataLength, const char* ch
     Vector<unsigned char> bytesToAdd;
     convertChecksumToPNGComment(checksum, bytesToAdd);
 
-    printf("Content-Type: %s\n", "image/png");
-    printf("Content-Length: %lu\n", static_cast<unsigned long>(dataLength + bytesToAdd.size()));
+    fprintf(testResult, "Content-Type: image/png\n");
+    fprintf(testResult, "Content-Length: %lu\n", static_cast<unsigned long>(dataLength + bytesToAdd.size()));
 
     size_t insertOffset = offsetAfterIHDRChunk(data, dataLength);
 
-    fwrite(data, 1, insertOffset, stdout);
-    fwrite(bytesToAdd.data(), 1, bytesToAdd.size(), stdout);
+    fwrite(data, 1, insertOffset, testResult);
+    fwrite(bytesToAdd.data(), 1, bytesToAdd.size(), testResult);
 
     const size_t bytesToWriteInOneChunk = 1 << 15;
     data += insertOffset;
     size_t dataRemainingToWrite = dataLength - insertOffset;
     while (dataRemainingToWrite) {
         size_t bytesToWriteInThisChunk = std::min(dataRemainingToWrite, bytesToWriteInOneChunk);
-        size_t bytesWritten = fwrite(data, 1, bytesToWriteInThisChunk, stdout);
+        size_t bytesWritten = fwrite(data, 1, bytesToWriteInThisChunk, testResult);
         if (bytesWritten != bytesToWriteInThisChunk)
             break;
         dataRemainingToWrite -= bytesWritten;
index 0600ff6..d4073a7 100644 (file)
@@ -192,11 +192,11 @@ static void CALLBACK logEventProc(HWINEVENTHOOK, DWORD event, HWND hwnd, LONG id
 
     switch (event) {
         case EVENT_OBJECT_FOCUS:
-            printf("Received focus event for object '%S'.\n", name.c_str());
+            fprintf(testResult, "Received focus event for object '%S'.\n", name.c_str());
             break;
 
         case EVENT_OBJECT_SELECTION:
-            printf("Received selection event for object '%S'.\n", name.c_str());
+            fprintf(testResult, "Received selection event for object '%S'.\n", name.c_str());
             break;
 
         case EVENT_OBJECT_VALUECHANGE: {
@@ -205,16 +205,16 @@ static void CALLBACK logEventProc(HWINEVENTHOOK, DWORD event, HWND hwnd, LONG id
             ASSERT(SUCCEEDED(hr));
             wstring value(valueBSTR, valueBSTR.length());
 
-            printf("Received value change event for object '%S', value '%S'.\n", name.c_str(), value.c_str());
+            fprintf(testResult, "Received value change event for object '%S', value '%S'.\n", name.c_str(), value.c_str());
             break;
         }
 
         case EVENT_SYSTEM_SCROLLINGSTART:
-            printf("Received scrolling start event for object '%S'.\n", name.c_str());
+            fprintf(testResult, "Received scrolling start event for object '%S'.\n", name.c_str());
             break;
 
         default:
-            printf("Received unknown event for object '%S'.\n", name.c_str());
+            fprintf(testResult, "Received unknown event for object '%S'.\n", name.c_str());
             break;
     }
 }
index 09275e9..da39eb1 100644 (file)
@@ -80,12 +80,12 @@ HRESULT DRTDesktopNotificationPresenter::showDesktopNotification(_In_opt_ IWebDe
 
     if (SUCCEEDED(notification->isHTML(&html)) && html) {
         notification->contentsURL(&url.GetBSTR());    
-        printf("DESKTOP NOTIFICATION: contents at %S\n", static_cast<wchar_t*>(url));
+        fprintf(testResult, "DESKTOP NOTIFICATION: contents at %S\n", static_cast<wchar_t*>(url));
     } else {
         notification->iconURL(&url.GetBSTR());
         notification->title(&title.GetBSTR());
         notification->text(&text.GetBSTR());
-        printf("DESKTOP NOTIFICATION: icon %S, title %S, text %S\n", static_cast<wchar_t*>(url), static_cast<wchar_t*>(title), static_cast<wchar_t*>(text));
+        fprintf(testResult, "DESKTOP NOTIFICATION: icon %S, title %S, text %S\n", static_cast<wchar_t*>(url), static_cast<wchar_t*>(title), static_cast<wchar_t*>(text));
     }
 
     // In this stub implementation, the notification is displayed immediately;
@@ -105,7 +105,7 @@ HRESULT DRTDesktopNotificationPresenter::cancelDesktopNotification(_In_opt_ IWeb
     else
         notification->title(&identifier.GetBSTR());
 
-    printf("DESKTOP NOTIFICATION CLOSED: %S\n", static_cast<wchar_t*>(identifier));
+    fprintf(testResult, "DESKTOP NOTIFICATION CLOSED: %S\n", static_cast<wchar_t*>(identifier));
     notification->notifyClose(false);
 
     return S_OK;
@@ -141,6 +141,6 @@ HRESULT DRTDesktopNotificationPresenter::checkNotificationPermission(_In_ BSTR /
 
 HRESULT DRTDesktopNotificationPresenter::requestNotificationPermission(_In_ BSTR origin)
 {
-    printf("DESKTOP NOTIFICATION PERMISSION REQUESTED: %S\n", origin ? origin : L"");
+    fprintf(testResult, "DESKTOP NOTIFICATION PERMISSION REQUESTED: %S\n", origin ? origin : L"");
     return S_OK;
 }
index f9203e9..d65cd25 100644 (file)
 #include "WorkQueueItem.h"
 #include "WorkQueue.h"
 
+#include <CoreFoundation/CoreFoundation.h>
+#include <WebCore/FileSystem.h>
+#include <WebKit/WebKit.h>
+#include <WebKit/WebKitCOMAPI.h>
 #include <comutil.h>
 #include <cstdio>
 #include <cstring>
 #include <shlobj.h>
 #include <shlwapi.h>
 #include <tchar.h>
+#include <windows.h>
+#include <wtf/HashSet.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/RetainPtr.h>
 #include <wtf/Vector.h>
 #include <wtf/text/CString.h>
-#include <windows.h>
-#include <CoreFoundation/CoreFoundation.h>
-#include <WebCore/FileSystem.h>
-#include <WebKit/WebKit.h>
-#include <WebKit/WebKitCOMAPI.h>
+#include <wtf/text/StringHash.h>
 
 #if USE(CFURLCONNECTION)
 #include <CFNetwork/CFHTTPCookiesPriv.h>
@@ -121,6 +123,8 @@ RefPtr<TestRunner> gTestRunner;
 
 UINT_PTR waitToDumpWatchdog = 0;
 
+FILE* testResult = nullptr;
+
 void setPersistentUserStyleSheetLocation(CFStringRef url)
 {
     persistentUserStyleSheetLocation = url;
@@ -405,9 +409,9 @@ void dumpFrameScrollPosition(IWebFrame* frame)
             _bstr_t name;
             if (FAILED(frame->name(&name.GetBSTR())))
                 return;
-            printf("frame '%S' ", static_cast<wchar_t*>(name));
+            fprintf(testResult, "frame '%S' ", static_cast<wchar_t*>(name));
         }
-        printf("scrolled to %.f,%.f\n", (double)scrollPosition.cx, (double)scrollPosition.cy);
+        fprintf(testResult, "scrolled to %.f,%.f\n", (double)scrollPosition.cx, (double)scrollPosition.cy);
     }
 
     if (::gTestRunner->dumpChildFrameScrollPositions()) {
@@ -506,11 +510,11 @@ static void dumpHistoryItem(IWebHistoryItem* item, int indent, bool current)
 
     int start = 0;
     if (current) {
-        printf("curr->");
+        fprintf(testResult, "curr->");
         start = 6;
     }
     for (int i = start; i < indent; i++)
-        putchar(' ');
+        fputc(' ', testResult);
 
     _bstr_t url;
     if (FAILED(item->URLString(&url.GetBSTR())))
@@ -531,7 +535,7 @@ static void dumpHistoryItem(IWebHistoryItem* item, int indent, bool current)
         url = _bstr_t(L"(file test):") + _bstr_t(start);
     }
 
-    printf("%S", static_cast<wchar_t*>(url));
+    fprintf(testResult, "%S", static_cast<wchar_t*>(url));
 
     COMPtr<IWebHistoryItemPrivate> itemPrivate;
     if (FAILED(item->QueryInterface(&itemPrivate)))
@@ -541,13 +545,13 @@ static void dumpHistoryItem(IWebHistoryItem* item, int indent, bool current)
     if (FAILED(itemPrivate->target(&target.GetBSTR())))
         return;
     if (target.length())
-        printf(" (in frame \"%S\")", static_cast<wchar_t*>(target));
+        fprintf(testResult, " (in frame \"%S\")", static_cast<wchar_t*>(target));
     BOOL isTargetItem = FALSE;
     if (FAILED(itemPrivate->isTargetItem(&isTargetItem)))
         return;
     if (isTargetItem)
-        printf("  **nav target**");
-    putchar('\n');
+        fprintf(testResult, "  **nav target**");
+    fputc('\n', testResult);
 
     unsigned kidsCount;
     SAFEARRAY* arrPtr;
@@ -595,7 +599,7 @@ static void dumpBackForwardList(IWebView* webView)
 {
     ASSERT(webView);
 
-    printf("\n============== Back Forward List ==============\n");
+    fprintf(testResult, "\n============== Back Forward List ==============\n");
 
     COMPtr<IWebBackForwardList> bfList;
     if (FAILED(webView->backForwardList(&bfList)))
@@ -652,7 +656,7 @@ static void dumpBackForwardList(IWebView* webView)
         dumpHistoryItem(historyItemToPrint.get(), 8, i == currentItemIndex);
     }
 
-    printf("===============================================\n");
+    fprintf(testResult, "===============================================\n");
 }
 
 static void dumpBackForwardListForAllWindows()
@@ -711,7 +715,7 @@ void dump()
             int bufferSize = ::WideCharToMultiByte(CP_UTF8, 0, resultString, stringLength, 0, 0, 0, 0);
             char* buffer = (char*)malloc(bufferSize + 1);
             ::WideCharToMultiByte(CP_UTF8, 0, resultString, stringLength, buffer, bufferSize + 1, 0, 0);
-            fwrite(buffer, 1, bufferSize, stdout);
+            fwrite(buffer, 1, bufferSize, testResult);
             free(buffer);
 
             if (!::gTestRunner->dumpAsText() && !::gTestRunner->dumpDOMAsWebArchive() && !::gTestRunner->dumpSourceAsWebArchive() && !::gTestRunner->dumpAsAudio())
@@ -720,10 +724,10 @@ void dump()
             if (::gTestRunner->dumpBackForwardList())
                 dumpBackForwardListForAllWindows();
         } else
-            printf("ERROR: nil result from %s", ::gTestRunner->dumpAsText() ? "IDOMElement::innerText" : "IFrameViewPrivate::renderTreeAsExternalRepresentation");
+            fprintf(testResult, "ERROR: nil result from %s", ::gTestRunner->dumpAsText() ? "IDOMElement::innerText" : "IFrameViewPrivate::renderTreeAsExternalRepresentation");
 
         if (printSeparators)
-            puts("#EOF"); // terminate the content block
+            fputs("#EOF\n", testResult); // terminate the content block
     }
 
     if (dumpPixelsForCurrentTest && ::gTestRunner->generatePixelResults()) {
@@ -731,8 +735,8 @@ void dump()
         dumpWebViewAsPixelsAndCompareWithExpected(gTestRunner->expectedPixelHash());
     }
 
-    puts("#EOF");   // terminate the (possibly empty) pixels block
-    fflush(stdout);
+    fputs("#EOF\n", testResult); // terminate the (possibly empty) pixels block
+    fflush(testResult);
 
 fail:
     // This will exit from our message loop.
@@ -1110,6 +1114,12 @@ static void runTest(const string& inputLine)
     _bstr_t urlBStr(reinterpret_cast<wchar_t*>(buffer.data()));
     ASSERT(urlBStr.length() == length);
 
+    // Check that test has not already run
+    static HashSet<String> testUrls;
+    if (testUrls.contains(String(inputLine.c_str())))
+        fprintf(stderr, "Test has already run \"%s\"\n", inputLine.c_str());
+    testUrls.add(String(inputLine.c_str()));
+
     CFIndex maximumURLLengthAsUTF8 = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1;
     Vector<char> testURL(maximumURLLengthAsUTF8 + 1, 0);
     CFStringGetCString(str, testURL.data(), maximumURLLengthAsUTF8, kCFStringEncodingUTF8);
@@ -1455,6 +1465,14 @@ int main(int argc, const char* argv[])
     _setmode(1, _O_BINARY);
     _setmode(2, _O_BINARY);
 
+    // Some tests are flaky because certain DLLs are writing to stdout, giving incorrect test results.
+    // We work around that here by duplicating and redirecting stdout.
+    int fdStdout = _dup(1);
+    _setmode(fdStdout, _O_BINARY);
+    testResult = fdopen(fdStdout, "a+b");
+    // Redirect stdout to stderr.
+    int result = _dup2(_fileno(stderr), 1);
+
     initialize();
 
     setDefaultsToConsistentValuesForTesting();
@@ -1487,7 +1505,7 @@ int main(int argc, const char* argv[])
         BOOL threeDTransformsAvailable = FALSE;
 #endif
 
-        printf("SupportedFeatures:%s %s\n", acceleratedCompositingAvailable ? "AcceleratedCompositing" : "", threeDTransformsAvailable ? "3DTransforms" : "");
+        fprintf(testResult, "SupportedFeatures:%s %s\n", acceleratedCompositingAvailable ? "AcceleratedCompositing" : "", threeDTransformsAvailable ? "3DTransforms" : "");
         return 0;
     }
 
index 45e7423..332c9ca 100644 (file)
@@ -43,6 +43,8 @@ extern PolicyDelegate* policyDelegate;
 
 extern HWND webViewWindow;
 
+extern FILE* testResult;
+
 #include <WebCore/COMPtr.h>
 #include <string>
 #include <wtf/HashMap.h>
index cc26ec7..6aa10f0 100644 (file)
@@ -132,7 +132,7 @@ HRESULT EditingDelegate::shouldBeginEditingInDOMRange(_In_opt_ IWebView*, _In_op
     }
 
     if (::gTestRunner->dumpEditingCallbacks() && !done)
-        printf("EDITING DELEGATE: shouldBeginEditingInDOMRange:%s\n", dump(range).c_str());
+        fprintf(testResult, "EDITING DELEGATE: shouldBeginEditingInDOMRange:%s\n", dump(range).c_str());
 
     *result = m_acceptsEditing;
     return S_OK;
@@ -146,7 +146,7 @@ HRESULT EditingDelegate::shouldEndEditingInDOMRange(_In_opt_ IWebView*, _In_opt_
     }
 
     if (::gTestRunner->dumpEditingCallbacks() && !done)
-        printf("EDITING DELEGATE: shouldEndEditingInDOMRange:%s\n", dump(range).c_str());
+        fprintf(testResult, "EDITING DELEGATE: shouldEndEditingInDOMRange:%s\n", dump(range).c_str());
 
     *result = m_acceptsEditing;
     return S_OK;
@@ -172,7 +172,7 @@ HRESULT EditingDelegate::shouldInsertNode(_In_opt_ IWebView* /*webView*/, _In_op
         return E_POINTER;
 
     if (::gTestRunner->dumpEditingCallbacks() && !done)
-        printf("EDITING DELEGATE: shouldInsertNode:%s replacingDOMRange:%s givenAction:%s\n", dumpPath(node).c_str(), dump(range).c_str(), insertActionString[action]);
+        fprintf(testResult, "EDITING DELEGATE: shouldInsertNode:%s replacingDOMRange:%s givenAction:%s\n", dumpPath(node).c_str(), dump(range).c_str(), insertActionString[action]);
 
     *result = m_acceptsEditing;
     return S_OK;
@@ -193,7 +193,7 @@ HRESULT EditingDelegate::shouldInsertText(_In_opt_ IWebView* /*webView*/, _In_ B
 
     if (::gTestRunner->dumpEditingCallbacks() && !done) {
         _bstr_t textBstr(text);
-        printf("EDITING DELEGATE: shouldInsertText:%s replacingDOMRange:%s givenAction:%s\n", static_cast<const char*>(textBstr), dump(range).c_str(), insertactionstring[action]);
+        fprintf(testResult, "EDITING DELEGATE: shouldInsertText:%s replacingDOMRange:%s givenAction:%s\n", static_cast<const char*>(textBstr), dump(range).c_str(), insertactionstring[action]);
     }
 
     *result = m_acceptsEditing;
@@ -208,7 +208,7 @@ HRESULT EditingDelegate::shouldDeleteDOMRange(_In_opt_ IWebView* /*webView*/, _I
     }
 
     if (::gTestRunner->dumpEditingCallbacks() && !done)
-        printf("EDITING DELEGATE: shouldDeleteDOMRange:%s\n", dump(range).c_str());
+        fprintf(testResult, "EDITING DELEGATE: shouldDeleteDOMRange:%s\n", dump(range).c_str());
 
     *result = m_acceptsEditing;
     return S_OK;
@@ -232,7 +232,7 @@ HRESULT EditingDelegate::shouldChangeSelectedDOMRange(_In_opt_ IWebView* /*webVi
     };
 
     if (::gTestRunner->dumpEditingCallbacks() && !done)
-        printf("EDITING DELEGATE: shouldChangeSelectedDOMRange:%s toDOMRange:%s affinity:%s stillSelecting:%s\n", dump(currentRange).c_str(), dump(proposedRange).c_str(), affinityString[selectionAffinity], boolstring[stillSelecting]);
+        fprintf(testResult, "EDITING DELEGATE: shouldChangeSelectedDOMRange:%s toDOMRange:%s affinity:%s stillSelecting:%s\n", dump(currentRange).c_str(), dump(proposedRange).c_str(), affinityString[selectionAffinity], boolstring[stillSelecting]);
 
     *result = m_acceptsEditing;
     return S_OK;
@@ -246,7 +246,7 @@ HRESULT EditingDelegate::shouldApplyStyle(_In_opt_ IWebView* /*webView*/, _In_op
     }
 
     if (::gTestRunner->dumpEditingCallbacks() && !done)
-        printf("EDITING DELEGATE: shouldApplyStyle:%s toElementsInDOMRange:%s\n", "'style description'"/*[[style description] UTF8String]*/, dump(range).c_str());
+        fprintf(testResult, "EDITING DELEGATE: shouldApplyStyle:%s toElementsInDOMRange:%s\n", "'style description'"/*[[style description] UTF8String]*/, dump(range).c_str());
 
     *result = m_acceptsEditing;
     return S_OK;
@@ -261,7 +261,7 @@ HRESULT EditingDelegate::shouldChangeTypingStyle(_In_opt_ IWebView* /*webView*/,
     }
 
     if (::gTestRunner->dumpEditingCallbacks() && !done)
-        printf("EDITING DELEGATE: shouldChangeTypingStyle:%s toStyle:%s\n", "'currentStyle description'", "'proposedStyle description'");
+        fprintf(testResult, "EDITING DELEGATE: shouldChangeTypingStyle:%s toStyle:%s\n", "'currentStyle description'", "'proposedStyle description'");
 
     *result = m_acceptsEditing;
     return S_OK;
@@ -276,7 +276,7 @@ HRESULT EditingDelegate::doPlatformCommand(_In_opt_ IWebView* /*webView*/, _In_
 
     if (::gTestRunner->dumpEditingCallbacks() && !done) {
         _bstr_t commandBSTR(command);
-        printf("EDITING DELEGATE: doPlatformCommand:%s\n", static_cast<const char*>(commandBSTR));
+        fprintf(testResult, "EDITING DELEGATE: doPlatformCommand:%s\n", static_cast<const char*>(commandBSTR));
     }
 
     *result = m_acceptsEditing;
@@ -291,7 +291,7 @@ HRESULT EditingDelegate::webViewDidBeginEditing(_In_opt_ IWebNotification* notif
     if (::gTestRunner->dumpEditingCallbacks() && !done) {
         _bstr_t name;
         notification->name(&name.GetBSTR());
-        printf("EDITING DELEGATE: webViewDidBeginEditing:%s\n", static_cast<const char*>(name));
+        fprintf(testResult, "EDITING DELEGATE: webViewDidBeginEditing:%s\n", static_cast<const char*>(name));
     }
     return S_OK;
 }
@@ -304,7 +304,7 @@ HRESULT EditingDelegate::webViewDidChange(_In_opt_ IWebNotification* notificatio
     if (::gTestRunner->dumpEditingCallbacks() && !done) {
         _bstr_t name;
         notification->name(&name.GetBSTR());
-        printf("EDITING DELEGATE: webViewDidChange:%s\n", static_cast<const char*>(name));
+        fprintf(testResult, "EDITING DELEGATE: webViewDidChange:%s\n", static_cast<const char*>(name));
     }
     return S_OK;
 }
@@ -317,7 +317,7 @@ HRESULT EditingDelegate::webViewDidEndEditing(_In_opt_ IWebNotification* notific
     if (::gTestRunner->dumpEditingCallbacks() && !done) {
         _bstr_t name;
         notification->name(&name.GetBSTR());
-        printf("EDITING DELEGATE: webViewDidEndEditing:%s\n", static_cast<const char*>(name));
+        fprintf(testResult, "EDITING DELEGATE: webViewDidEndEditing:%s\n", static_cast<const char*>(name));
     }
     return S_OK;
 }
@@ -330,7 +330,7 @@ HRESULT EditingDelegate::webViewDidChangeTypingStyle(_In_opt_ IWebNotification*
     if (::gTestRunner->dumpEditingCallbacks() && !done) {
         _bstr_t name;
         notification->name(&name.GetBSTR());
-        printf("EDITING DELEGATE: webViewDidChangeTypingStyle:%s\n", static_cast<const char*>(name));
+        fprintf(testResult, "EDITING DELEGATE: webViewDidChangeTypingStyle:%s\n", static_cast<const char*>(name));
     }
     return S_OK;
 }
@@ -343,7 +343,7 @@ HRESULT EditingDelegate::webViewDidChangeSelection(_In_opt_ IWebNotification* no
     if (::gTestRunner->dumpEditingCallbacks() && !done) {
         _bstr_t name;
         notification->name(&name.GetBSTR());
-        printf("EDITING DELEGATE: webViewDidChangeSelection:%s\n", static_cast<const char*>(name));
+        fprintf(testResult, "EDITING DELEGATE: webViewDidChangeSelection:%s\n", static_cast<const char*>(name));
     }
     return S_OK;
 }
index 1862c82..3f6bd9e 100644 (file)
@@ -123,7 +123,7 @@ ULONG FrameLoadDelegate::Release()
 HRESULT FrameLoadDelegate::didStartProvisionalLoadForFrame(_In_opt_ IWebView*, _In_opt_ IWebFrame* frame)
 {
     if (!done && gTestRunner->dumpFrameLoadCallbacks())
-        printf("%s - didStartProvisionalLoadForFrame\n", descriptionSuitableForTestResult(frame).c_str());
+        fprintf(testResult, "%s - didStartProvisionalLoadForFrame\n", descriptionSuitableForTestResult(frame).c_str());
 
     // Make sure we only set this once per test.  If it gets cleared, and then set again, we might
     // end up doing two dumps for one test.
@@ -136,7 +136,7 @@ HRESULT FrameLoadDelegate::didStartProvisionalLoadForFrame(_In_opt_ IWebView*, _
 HRESULT FrameLoadDelegate::didReceiveServerRedirectForProvisionalLoadForFrame(_In_opt_ IWebView*, _In_opt_ IWebFrame* frame)
 { 
     if (!done && gTestRunner->dumpFrameLoadCallbacks())
-        printf("%s - didReceiveServerRedirectForProvisionalLoadForFrame\n", descriptionSuitableForTestResult(frame).c_str());
+        fprintf(testResult, "%s - didReceiveServerRedirectForProvisionalLoadForFrame\n", descriptionSuitableForTestResult(frame).c_str());
 
     return S_OK;
 }
@@ -144,7 +144,7 @@ HRESULT FrameLoadDelegate::didReceiveServerRedirectForProvisionalLoadForFrame(_I
 HRESULT FrameLoadDelegate::didChangeLocationWithinPageForFrame(_In_opt_ IWebView* , _In_opt_ IWebFrame* frame)
 {
     if (!done && gTestRunner->dumpFrameLoadCallbacks())
-        printf("%s - didChangeLocationWithinPageForFrame\n", descriptionSuitableForTestResult(frame).c_str());
+        fprintf(testResult, "%s - didChangeLocationWithinPageForFrame\n", descriptionSuitableForTestResult(frame).c_str());
 
     return S_OK;
 }
@@ -152,7 +152,7 @@ HRESULT FrameLoadDelegate::didChangeLocationWithinPageForFrame(_In_opt_ IWebView
 HRESULT FrameLoadDelegate::didFailProvisionalLoadWithError(_In_opt_ IWebView*, _In_opt_ IWebError* error, _In_opt_ IWebFrame* frame)
 {
     if (!done && gTestRunner->dumpFrameLoadCallbacks())
-        printf("%s - didFailProvisionalLoadWithError\n", descriptionSuitableForTestResult(frame).c_str());
+        fprintf(testResult, "%s - didFailProvisionalLoadWithError\n", descriptionSuitableForTestResult(frame).c_str());
 
     locationChangeDone(error, frame);
     return S_OK;
@@ -161,7 +161,7 @@ HRESULT FrameLoadDelegate::didFailProvisionalLoadWithError(_In_opt_ IWebView*, _
 HRESULT FrameLoadDelegate::didCommitLoadForFrame(_In_opt_ IWebView* webView, _In_opt_ IWebFrame* frame)
 {
     if (!done && gTestRunner->dumpFrameLoadCallbacks())
-        printf("%s - didCommitLoadForFrame\n", descriptionSuitableForTestResult(frame).c_str());
+        fprintf(testResult, "%s - didCommitLoadForFrame\n", descriptionSuitableForTestResult(frame).c_str());
 
     COMPtr<IWebViewPrivate2> webViewPrivate;
     HRESULT hr = webView->QueryInterface(&webViewPrivate);
@@ -175,10 +175,10 @@ HRESULT FrameLoadDelegate::didCommitLoadForFrame(_In_opt_ IWebView* webView, _In
 HRESULT FrameLoadDelegate::didReceiveTitle(_In_opt_ IWebView*, _In_ BSTR title, _In_opt_ IWebFrame* frame)
 {
     if (!done && gTestRunner->dumpFrameLoadCallbacks())
-        printf("%s - didReceiveTitle: %S\n", descriptionSuitableForTestResult(frame).c_str(), title);
+        fprintf(testResult, "%s - didReceiveTitle: %S\n", descriptionSuitableForTestResult(frame).c_str(), title);
 
     if (::gTestRunner->dumpTitleChanges() && !done)
-        printf("TITLE CHANGED: '%S'\n", title ? title : L"");
+        fprintf(testResult, "TITLE CHANGED: '%S'\n", title ? title : L"");
     return S_OK;
 }
 
@@ -252,7 +252,7 @@ void FrameLoadDelegate::locationChangeDone(IWebError*, IWebFrame* frame)
 HRESULT FrameLoadDelegate::didFinishLoadForFrame(_In_opt_ IWebView*, _In_opt_ IWebFrame* frame)
 {
     if (!done && gTestRunner->dumpFrameLoadCallbacks())
-        printf("%s - didFinishLoadForFrame\n", descriptionSuitableForTestResult(frame).c_str());
+        fprintf(testResult, "%s - didFinishLoadForFrame\n", descriptionSuitableForTestResult(frame).c_str());
 
     locationChangeDone(0, frame);
     return S_OK;
@@ -261,7 +261,7 @@ HRESULT FrameLoadDelegate::didFinishLoadForFrame(_In_opt_ IWebView*, _In_opt_ IW
 HRESULT FrameLoadDelegate::didFailLoadWithError(_In_opt_ IWebView*, _In_opt_ IWebError* error, _In_opt_ IWebFrame* frame)
 {
     if (!done && gTestRunner->dumpFrameLoadCallbacks())
-        printf("%s - didFailLoadWithError\n", descriptionSuitableForTestResult(frame).c_str());
+        fprintf(testResult, "%s - didFailLoadWithError\n", descriptionSuitableForTestResult(frame).c_str());
 
     locationChangeDone(error, frame);
     return S_OK;
@@ -270,7 +270,7 @@ HRESULT FrameLoadDelegate::didFailLoadWithError(_In_opt_ IWebView*, _In_opt_ IWe
 HRESULT FrameLoadDelegate::willPerformClientRedirectToURL(_In_opt_ IWebView*, _In_ BSTR url, double /*delaySeconds*/, DATE /*fireDate*/, _In_opt_ IWebFrame* frame)
 {
     if (!done && gTestRunner->dumpFrameLoadCallbacks())
-        printf("%s - willPerformClientRedirectToURL: %S \n", descriptionSuitableForTestResult(frame).c_str(),
+        fprintf(testResult, "%s - willPerformClientRedirectToURL: %S \n", descriptionSuitableForTestResult(frame).c_str(),
                 urlSuitableForTestResult(std::wstring(url, ::SysStringLen(url))).c_str());
 
     return S_OK;
@@ -279,7 +279,7 @@ HRESULT FrameLoadDelegate::willPerformClientRedirectToURL(_In_opt_ IWebView*, _I
 HRESULT FrameLoadDelegate::didCancelClientRedirectForFrame(_In_opt_ IWebView*, _In_opt_ IWebFrame* frame)
 {
     if (!done && gTestRunner->dumpFrameLoadCallbacks())
-        printf("%s - didCancelClientRedirectForFrame\n", descriptionSuitableForTestResult(frame).c_str());
+        fprintf(testResult, "%s - didCancelClientRedirectForFrame\n", descriptionSuitableForTestResult(frame).c_str());
 
     return S_OK;
 }
@@ -293,7 +293,7 @@ HRESULT FrameLoadDelegate::willCloseFrame(_In_opt_ IWebView*, _In_opt_ IWebFrame
 HRESULT FrameLoadDelegate::windowScriptObjectAvailable(IWebView*, JSContextRef, JSObjectRef)
 {
     if (!done && gTestRunner->dumpFrameLoadCallbacks())
-        printf("?? - windowScriptObjectAvailable\n");
+        fprintf(testResult, "?? - windowScriptObjectAvailable\n");
 
     ASSERT_NOT_REACHED();
 
@@ -375,7 +375,7 @@ void FrameLoadDelegate::didClearWindowObjectForFrameInStandardWorld(IWebFrame* f
 HRESULT FrameLoadDelegate::didFinishDocumentLoadForFrame(_In_opt_ IWebView* /*sender*/, _In_opt_ IWebFrame* frame)
 {
     if (!done && gTestRunner->dumpFrameLoadCallbacks())
-        printf("%s - didFinishDocumentLoadForFrame\n",
+        fprintf(testResult, "%s - didFinishDocumentLoadForFrame\n",
                 descriptionSuitableForTestResult(frame).c_str());
     if (!done) {
         COMPtr<IWebFramePrivate> webFramePrivate;
@@ -387,7 +387,7 @@ HRESULT FrameLoadDelegate::didFinishDocumentLoadForFrame(_In_opt_ IWebView* /*se
         if (FAILED(hr))
             return hr;
         if (pendingFrameUnloadEvents)
-            printf("%s - has %u onunload handler(s)\n",
+            fprintf(testResult, "%s - has %u onunload handler(s)\n",
                     descriptionSuitableForTestResult(frame).c_str(), pendingFrameUnloadEvents);
     }
 
@@ -397,7 +397,7 @@ HRESULT FrameLoadDelegate::didFinishDocumentLoadForFrame(_In_opt_ IWebView* /*se
 HRESULT FrameLoadDelegate::didHandleOnloadEventsForFrame(_In_opt_ IWebView* /*sender*/, _In_opt_ IWebFrame* frame)
 {
     if (!done && gTestRunner->dumpFrameLoadCallbacks())
-        printf("%s - didHandleOnloadEventsForFrame\n",
+        fprintf(testResult, "%s - didHandleOnloadEventsForFrame\n",
                 descriptionSuitableForTestResult(frame).c_str());
 
     return S_OK;
@@ -411,7 +411,7 @@ HRESULT FrameLoadDelegate::didFirstVisuallyNonEmptyLayoutInFrame(_In_opt_ IWebVi
 HRESULT FrameLoadDelegate::didDisplayInsecureContent(_In_opt_ IWebView* /*sender*/)
 {
     if (!done && gTestRunner->dumpFrameLoadCallbacks())
-        printf("didDisplayInsecureContent\n");
+        fprintf(testResult, "didDisplayInsecureContent\n");
 
     return S_OK;
 }
@@ -419,7 +419,7 @@ HRESULT FrameLoadDelegate::didDisplayInsecureContent(_In_opt_ IWebView* /*sender
 HRESULT FrameLoadDelegate::didRunInsecureContent(_In_opt_ IWebView* /*sender*/, _In_opt_ IWebSecurityOrigin* /*origin*/)
 {
     if (!done && gTestRunner->dumpFrameLoadCallbacks())
-        printf("didRunInsecureContent\n");
+        fprintf(testResult, "didRunInsecureContent\n");
 
     return S_OK;
 }
@@ -442,5 +442,5 @@ HRESULT FrameLoadDelegate::onNotify(_In_opt_ IWebNotification* notification)
 void FrameLoadDelegate::webViewProgressFinishedNotification()
 {
     if (!done && gTestRunner->dumpProgressFinishedCallback())
-        printf("postProgressFinishedNotification\n");
+        fprintf(testResult, "postProgressFinishedNotification\n");
 }
index a2ba25e..a1ec868 100644 (file)
@@ -140,7 +140,7 @@ HRESULT HistoryDelegate::didNavigateWithNavigationData(_In_opt_ IWebView* webVie
 
     bool wasFailure = hasSubstituteData || (httpResponse && statusCode >= 400);
         
-    printf("WebView navigated to url \"%S\" with title \"%s\" with HTTP equivalent method \"%s\".  The navigation was %s and was %s%S.\n", 
+    fprintf(testResult, "WebView navigated to url \"%S\" with title \"%s\" with HTTP equivalent method \"%s\".  The navigation was %s and was %s%S.\n", 
         url.c_str(), 
         static_cast<char*>(titleBSTR),
         static_cast<char*>(httpMethodBSTR),
@@ -164,7 +164,7 @@ HRESULT HistoryDelegate::didPerformClientRedirectFromURL(_In_opt_ IWebView*, _In
     if (destinationURL)
         destination = urlSuitableForTestResult(wstringFromBSTR(destinationURL));
 
-    printf("WebView performed a client redirect from \"%S\" to \"%S\".\n", source.c_str(), destination.c_str());
+    fprintf(testResult, "WebView performed a client redirect from \"%S\" to \"%S\".\n", source.c_str(), destination.c_str());
     return S_OK;
 }
     
@@ -181,7 +181,7 @@ HRESULT HistoryDelegate::didPerformServerRedirectFromURL(_In_opt_ IWebView* webV
     if (destinationURL)
         destination = urlSuitableForTestResult(wstringFromBSTR(destinationURL));
 
-    printf("WebView performed a server redirect from \"%S\" to \"%S\".\n", source.c_str(), destination.c_str());
+    fprintf(testResult, "WebView performed a server redirect from \"%S\" to \"%S\".\n", source.c_str(), destination.c_str());
     return S_OK;
 }
 
@@ -194,7 +194,7 @@ HRESULT HistoryDelegate::updateHistoryTitle(_In_opt_ IWebView* webView, _In_ BST
     if (urlBSTR)
         url = urlSuitableForTestResult(wstringFromBSTR(urlBSTR));
 
-    printf("WebView updated the title for history URL \"%S\" to \"%S\".\n", url.c_str(), titleBSTR ? titleBSTR : L"");
+    fprintf(testResult, "WebView updated the title for history URL \"%S\" to \"%S\".\n", url.c_str(), titleBSTR ? titleBSTR : L"");
     return S_OK;
 }
     
@@ -212,7 +212,7 @@ HRESULT HistoryDelegate::populateVisitedLinksForWebView(_In_opt_ IWebView* webVi
         url = urlSuitableForTestResult(wstringFromBSTR(urlBSTR));
 
     if (gTestRunner->dumpVisitedLinksCallback())
-        printf("Asked to populate visited links for WebView \"%S\"\n", url.c_str());
+        fprintf(testResult, "Asked to populate visited links for WebView \"%S\"\n", url.c_str());
 
     return S_OK;
 }
index be14134..23e0dde 100644 (file)
@@ -139,7 +139,7 @@ HRESULT PolicyDelegate::decidePolicyForNavigationAction(_In_opt_ IWebView*, _In_
         }
     }
 
-    printf("%S\n", message.c_str());
+    fprintf(testResult, "%S\n", message.c_str());
 
     if (m_permissiveDelegate)
         listener->use();
@@ -166,7 +166,7 @@ HRESULT PolicyDelegate::unableToImplementPolicyWithError(_In_opt_ IWebView*, _In
     _bstr_t frameName;
     frame->name(&frameName.GetBSTR());
     
-    printf("Policy delegate: unable to implement policy with error domain '%S', error code %d, in frame '%S'\n", static_cast<wchar_t*>(domainStr), code, static_cast<TCHAR*>(frameName));
+    fprintf(testResult, "Policy delegate: unable to implement policy with error domain '%S', error code %d, in frame '%S'\n", static_cast<wchar_t*>(domainStr), code, static_cast<TCHAR*>(frameName));
     
     return S_OK;
 }
index 0171693..eb14efc 100644 (file)
@@ -236,7 +236,7 @@ HRESULT ResourceLoadDelegate::willSendRequest(_In_opt_ IWebView* webView, unsign
     *newRequest = nullptr;
 
     if (!done && gTestRunner->dumpResourceLoadCallbacks()) {
-        printf("%S - willSendRequest %S redirectResponse %S\n", 
+        fprintf(testResult, "%S - willSendRequest %S redirectResponse %S\n", 
             descriptionSuitableForTestResult(identifier).c_str(),
             descriptionSuitableForTestResult(request).c_str(),
             descriptionSuitableForTestResult(redirectResponse).c_str());
@@ -246,13 +246,13 @@ HRESULT ResourceLoadDelegate::willSendRequest(_In_opt_ IWebView* webView, unsign
         return S_OK;
 
     if (!done && gTestRunner->willSendRequestReturnsNullOnRedirect() && redirectResponse) {
-        printf("Returning null for this redirect\n");
+        fprintf(testResult, "Returning null for this redirect\n");
         return S_OK;
     }
 
     _bstr_t urlBstr;
     if (FAILED(request->URL(&urlBstr.GetBSTR()))) {
-        printf("Request has no URL\n");
+        fprintf(testResult, "Request has no URL\n");
         return E_FAIL;
     }
 
@@ -274,7 +274,7 @@ HRESULT ResourceLoadDelegate::willSendRequest(_In_opt_ IWebView* webView, unsign
                 testHost = adoptCF(CFURLCopyHostName(testPathURL.get()));
             }
             if (!isLocalhost(host.get()) && !hostIsUsedBySomeTestsToGenerateError(host.get()) && (!testHost || isLocalhost(testHost.get()))) {
-                printf("Blocked access to external URL %s\n", static_cast<const char*>(urlBstr));
+                fprintf(testResult, "Blocked access to external URL %s\n", static_cast<const char*>(urlBstr));
                 return S_OK;
             }
         }
@@ -300,7 +300,7 @@ HRESULT ResourceLoadDelegate::didReceiveAuthenticationChallenge(_In_opt_ IWebVie
         return E_FAIL;
 
     if (!gTestRunner->handlesAuthenticationChallenges()) {
-        printf("%S - didReceiveAuthenticationChallenge - Simulating cancelled authentication sheet\n", descriptionSuitableForTestResult(identifier).c_str());
+        fprintf(testResult, "%S - didReceiveAuthenticationChallenge - Simulating cancelled authentication sheet\n", descriptionSuitableForTestResult(identifier).c_str());
         sender->continueWithoutCredentialForAuthenticationChallenge(challenge);
         return S_OK;
     }
@@ -308,7 +308,7 @@ HRESULT ResourceLoadDelegate::didReceiveAuthenticationChallenge(_In_opt_ IWebVie
     const char* user = gTestRunner->authenticationUsername().c_str();
     const char* password = gTestRunner->authenticationPassword().c_str();
 
-    printf("%S - didReceiveAuthenticationChallenge - Responding with %s:%s\n", descriptionSuitableForTestResult(identifier).c_str(), user, password);
+    fprintf(testResult, "%S - didReceiveAuthenticationChallenge - Responding with %s:%s\n", descriptionSuitableForTestResult(identifier).c_str(), user, password);
 
     COMPtr<IWebURLCredential> credential;
     if (FAILED(WebKitCreateInstance(CLSID_WebURLCredential, 0, IID_IWebURLCredential, (void**)&credential)))
@@ -323,7 +323,7 @@ HRESULT ResourceLoadDelegate::didReceiveResponse(_In_opt_ IWebView* webView, uns
     _In_opt_ IWebURLResponse* response, _In_opt_ IWebDataSource* dataSource)
 {
     if (!done && gTestRunner->dumpResourceLoadCallbacks()) {
-        printf("%S - didReceiveResponse %S\n",
+        fprintf(testResult, "%S - didReceiveResponse %S\n",
             descriptionSuitableForTestResult(identifier).c_str(),
             descriptionSuitableForTestResult(response).c_str());
     }
@@ -338,7 +338,7 @@ HRESULT ResourceLoadDelegate::didReceiveResponse(_In_opt_ IWebView* webView, uns
     
         wstring url = wstringFromBSTR(urlBSTR);
 
-        printf("%S has MIME type %S\n", lastPathComponent(url).c_str(), static_cast<wchar_t*>(mimeTypeBSTR));
+        fprintf(testResult, "%S has MIME type %S\n", lastPathComponent(url).c_str(), static_cast<wchar_t*>(mimeTypeBSTR));
     }
 
     return S_OK;
@@ -348,7 +348,7 @@ HRESULT ResourceLoadDelegate::didReceiveResponse(_In_opt_ IWebView* webView, uns
 HRESULT ResourceLoadDelegate::didFinishLoadingFromDataSource(_In_opt_ IWebView* webView, unsigned long identifier, _In_opt_ IWebDataSource* dataSource)
 {
     if (!done && gTestRunner->dumpResourceLoadCallbacks()) {
-        printf("%S - didFinishLoading\n",
+        fprintf(testResult, "%S - didFinishLoading\n",
             descriptionSuitableForTestResult(identifier).c_str());
     }
 
@@ -360,7 +360,7 @@ HRESULT ResourceLoadDelegate::didFinishLoadingFromDataSource(_In_opt_ IWebView*
 HRESULT ResourceLoadDelegate::didFailLoadingWithError(_In_opt_ IWebView* webView, unsigned long identifier, _In_opt_ IWebError* error, _In_opt_ IWebDataSource* dataSource)
 {
     if (!done && gTestRunner->dumpResourceLoadCallbacks()) {
-        printf("%S - didFailLoadingWithError: %S\n", 
+        fprintf(testResult, "%S - didFailLoadingWithError: %S\n", 
             descriptionSuitableForTestResult(identifier).c_str(),
             descriptionSuitableForTestResult(error, identifier).c_str());
     }
index 54e98ff..5f21cbf 100644 (file)
@@ -82,7 +82,7 @@ JSContextRef TestRunner::mainFrameJSContext()
 void TestRunner::addDisallowedURL(JSStringRef url)
 {
     // FIXME: Implement!
-    printf("ERROR: TestRunner::addDisallowedURL(JSStringRef) not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::addDisallowedURL(JSStringRef) not implemented\n");
 }
 
 bool TestRunner::callShouldCloseOnWebView()
@@ -149,7 +149,7 @@ void TestRunner::clearApplicationCacheForOrigin(JSStringRef origin)
 JSValueRef TestRunner::originsWithApplicationCache(JSContextRef context)
 {
     // FIXME: Implement to get origins that have application caches.
-    printf("ERROR: TestRunner::originsWithApplicationCache(JSContextRef) not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::originsWithApplicationCache(JSContextRef) not implemented\n");
     return JSValueMakeUndefined(context);
 }
 
@@ -175,13 +175,13 @@ void TestRunner::clearAllDatabases()
 void TestRunner::setStorageDatabaseIdleInterval(double)
 {
     // FIXME: Implement. Requires non-existant (on Windows) WebStorageManager
-    printf("ERROR: TestRunner::setStorageDatabaseIdleInterval(double) not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::setStorageDatabaseIdleInterval(double) not implemented\n");
 }
 
 void TestRunner::closeIdleLocalStorageDatabases()
 {
     // FIXME: Implement. Requires non-existant (on Windows) WebStorageManager
-    printf("ERROR: TestRunner::closeIdleLocalStorageDatabases(double) not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::closeIdleLocalStorageDatabases(double) not implemented\n");
 }
 
 void TestRunner::clearBackForwardList()
@@ -213,14 +213,14 @@ void TestRunner::clearBackForwardList()
 JSStringRef TestRunner::copyDecodedHostName(JSStringRef name)
 {
     // FIXME: Implement!
-    printf("ERROR: TestRunner::copyDecodedHostName(JSStringRef) not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::copyDecodedHostName(JSStringRef) not implemented\n");
     return 0;
 }
 
 JSStringRef TestRunner::copyEncodedHostName(JSStringRef name)
 {
     // FIXME: Implement!
-    printf("ERROR: TestRunner::copyEncodedHostName(JSStringRef) not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::copyEncodedHostName(JSStringRef) not implemented\n");
     return 0;
 }
 
@@ -248,14 +248,14 @@ void TestRunner::keepWebHistory()
 int TestRunner::numberOfPendingGeolocationPermissionRequests()
 {
     // FIXME: Implement for Geolocation layout tests.
-    printf("ERROR: TestRunner::numberOfPendingGeolocationPermissionRequests() not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::numberOfPendingGeolocationPermissionRequests() not implemented\n");
     return -1;
 }
 
 bool TestRunner::isGeolocationProviderActive()
 {
     // FIXME: Implement for Geolocation layout tests.
-    printf("ERROR: TestRunner::isGeolocationProviderActive() not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::isGeolocationProviderActive() not implemented\n");
     return false;
 }
 
@@ -304,7 +304,7 @@ JSStringRef TestRunner::pathToLocalResource(JSContextRef context, JSStringRef ur
 
     wstring localPath;
     if (!resolveCygwinPath(input, localPath)) {
-        printf("ERROR: Failed to resolve Cygwin path %S\n", input.c_str());
+        fprintf(testResult, "ERROR: Failed to resolve Cygwin path %S\n", input.c_str());
         return nullptr;
     }
 
@@ -457,21 +457,21 @@ void TestRunner::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bo
 {
     // FIXME: Implement for DeviceOrientation layout tests.
     // See https://bugs.webkit.org/show_bug.cgi?id=30335.
-    printf("ERROR: TestRunner::setMockDeviceOrientation() not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::setMockDeviceOrientation() not implemented\n");
 }
 
 void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
 {
     // FIXME: Implement for Geolocation layout tests.
     // See https://bugs.webkit.org/show_bug.cgi?id=28264.
-    printf("ERROR: TestRunner::setMockGeolocationPosition() not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::setMockGeolocationPosition() not implemented\n");
 }
 
 void TestRunner::setMockGeolocationPositionUnavailableError(JSStringRef message)
 {
     // FIXME: Implement for Geolocation layout tests.
     // See https://bugs.webkit.org/show_bug.cgi?id=28264.
-    printf("ERROR: TestRunner::setMockGeolocationPositionUnavailableError() not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::setMockGeolocationPositionUnavailableError() not implemented\n");
 }
 
 void TestRunner::setGeolocationPermission(bool allow)
@@ -533,7 +533,7 @@ void TestRunner::setXSSAuditorEnabled(bool enabled)
 void TestRunner::setSpatialNavigationEnabled(bool enabled)
 {
     // FIXME: Implement for SpatialNavigation layout tests.
-    printf("ERROR: TestRunner::setSpatialNavigationEnabled(bool) not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::setSpatialNavigationEnabled(bool) not implemented\n");
 }
 
 void TestRunner::setAllowUniversalAccessFromFileURLs(bool enabled)
@@ -633,7 +633,7 @@ void TestRunner::setJavaScriptCanAccessClipboard(bool enabled)
 void TestRunner::setAutomaticLinkDetectionEnabled(bool)
 {
     // FIXME: Implement this.
-    printf("ERROR: TestRunner::setAutomaticLinkDetectionEnabled(bool) not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::setAutomaticLinkDetectionEnabled(bool) not implemented\n");
 }
 
 void TestRunner::setTabKeyCyclesThroughElements(bool shouldCycle)
@@ -1036,7 +1036,7 @@ void TestRunner::setCacheModel(int cacheModel)
 
 bool TestRunner::isCommandEnabled(JSStringRef /*name*/)
 {
-    printf("ERROR: TestRunner::isCommandEnabled() not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::isCommandEnabled() not implemented\n");
     return false;
 }
 
@@ -1277,7 +1277,7 @@ void TestRunner::setWebViewEditable(bool editable)
 
 void TestRunner::authenticateSession(JSStringRef, JSStringRef, JSStringRef)
 {
-    printf("ERROR: TestRunner::authenticateSession() not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::authenticateSession() not implemented\n");
 }
 
 void TestRunner::abortModal()
@@ -1309,17 +1309,17 @@ void TestRunner::setTextDirection(JSStringRef direction)
 
 void TestRunner::addChromeInputField()
 {
-    printf("ERROR: TestRunner::addChromeInputField() not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::addChromeInputField() not implemented\n");
 }
 
 void TestRunner::removeChromeInputField()
 {
-    printf("ERROR: TestRunner::removeChromeInputField() not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::removeChromeInputField() not implemented\n");
 }
 
 void TestRunner::focusWebView()
 {
-    printf("ERROR: TestRunner::focusWebView() not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::focusWebView() not implemented\n");
 }
 
 void TestRunner::setBackingScaleFactor(double)
@@ -1363,22 +1363,22 @@ void TestRunner::setPageVisibility(const char* newVisibility)
 
 void TestRunner::grantWebNotificationPermission(JSStringRef origin)
 {
-    printf("ERROR: TestRunner::grantWebNotificationPermission(JSStringRef) not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::grantWebNotificationPermission(JSStringRef) not implemented\n");
 }
 
 void TestRunner::denyWebNotificationPermission(JSStringRef jsOrigin)
 {
-    printf("ERROR: TestRunner::denyWebNotificationPermission(JSStringRef) not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::denyWebNotificationPermission(JSStringRef) not implemented\n");
 }
 
 void TestRunner::removeAllWebNotificationPermissions()
 {
-    printf("ERROR: TestRunner::removeAllWebNotificationPermissions() not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::removeAllWebNotificationPermissions() not implemented\n");
 }
 
 void TestRunner::simulateWebNotificationClick(JSValueRef jsNotification)
 {
-    printf("ERROR: TestRunner::simulateWebNotificationClick() not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::simulateWebNotificationClick() not implemented\n");
 }
 
 void TestRunner::simulateLegacyWebNotificationClick(JSStringRef title)
@@ -1388,7 +1388,7 @@ void TestRunner::simulateLegacyWebNotificationClick(JSStringRef title)
 
 unsigned TestRunner::imageCountInGeneralPasteboard() const
 {
-    printf("ERROR: TestRunner::imageCountInGeneralPasteboard() not implemented\n");
+    fprintf(testResult, "ERROR: TestRunner::imageCountInGeneralPasteboard() not implemented\n");
     return 0;
 }
 
index e60d5e8..96138f5 100644 (file)
@@ -453,8 +453,8 @@ HRESULT UIDelegate::webViewFrame(_In_opt_ IWebView* /*sender*/, _Out_ RECT* fram
 HRESULT UIDelegate::runJavaScriptAlertPanelWithMessage(_In_opt_ IWebView* /*sender*/, _In_ BSTR message)
 {
     if (!done) {
-        printf("ALERT: %S\n", message ? message : L"");
-        fflush(stdout);
+        fprintf(testResult, "ALERT: %S\n", message ? message : L"");
+        fflush(testResult);
     }
 
     return S_OK;
@@ -463,7 +463,7 @@ HRESULT UIDelegate::runJavaScriptAlertPanelWithMessage(_In_opt_ IWebView* /*send
 HRESULT UIDelegate::runJavaScriptConfirmPanelWithMessage(_In_opt_ IWebView* /*sender*/, _In_ BSTR message, _Out_ BOOL* result)
 {
     if (!done)
-        printf("CONFIRM: %S\n", message ? message : L"");
+        fprintf(testResult, "CONFIRM: %S\n", message ? message : L"");
 
     *result = TRUE;
 
@@ -473,7 +473,7 @@ HRESULT UIDelegate::runJavaScriptConfirmPanelWithMessage(_In_opt_ IWebView* /*se
 HRESULT UIDelegate::runJavaScriptTextInputPanelWithPrompt(_In_opt_ IWebView* /*sender*/, _In_ BSTR message, _In_ BSTR defaultText, __deref_opt_out BSTR* result)
 {
     if (!done)
-        printf("PROMPT: %S, default text: %S\n", message ? message : L"", defaultText ? defaultText : L"");
+        fprintf(testResult, "PROMPT: %S, default text: %S\n", message ? message : L"", defaultText ? defaultText : L"");
 
     *result = SysAllocString(defaultText);
 
@@ -486,7 +486,7 @@ HRESULT UIDelegate::runBeforeUnloadConfirmPanelWithMessage(_In_opt_ IWebView* /*
         return E_POINTER;
 
     if (!done)
-        printf("CONFIRM NAVIGATION: %S\n", message ? message : L"");
+        fprintf(testResult, "CONFIRM NAVIGATION: %S\n", message ? message : L"");
 
     *result = !gTestRunner->shouldStayOnPageAfterHandlingBeforeUnload();
 
@@ -507,7 +507,7 @@ HRESULT UIDelegate::webViewAddMessageToConsole(_In_opt_ IWebView* /*sender*/, _I
             newMessage = newMessage.substr(0, fileProtocol) + lastPathComponent(newMessage.substr(fileProtocol + fileURL.size()));
     }
 
-    auto out = gTestRunner->dumpJSConsoleLogInStdErr() ? stderr : stdout;
+    auto out = gTestRunner->dumpJSConsoleLogInStdErr() ? stderr : testResult;
     fprintf(out, "CONSOLE MESSAGE: ");
     if (lineNumber)
         fprintf(out, "line %d: ", lineNumber);
@@ -594,7 +594,7 @@ HRESULT UIDelegate::exceededDatabaseQuota(_In_opt_ IWebView* sender, _In_opt_ IW
     origin->port(&port);
 
     if (!done && gTestRunner->dumpDatabaseCallbacks())
-        printf("UI DELEGATE DATABASE CALLBACK: exceededDatabaseQuotaForSecurityOrigin:{%s, %s, %i} database:%S\n", static_cast<const char*>(protocol), static_cast<const char*>(host), port, databaseIdentifier);
+        fprintf(testResult, "UI DELEGATE DATABASE CALLBACK: exceededDatabaseQuotaForSecurityOrigin:{%s, %s, %i} database:%S\n", static_cast<const char*>(protocol), static_cast<const char*>(host), port, databaseIdentifier);
 
     unsigned long long defaultQuota = 5 * 1024 * 1024;
     double testDefaultQuota = gTestRunner->databaseDefaultQuota();
@@ -626,7 +626,7 @@ HRESULT UIDelegate::exceededDatabaseQuota(_In_opt_ IWebView* sender, _In_opt_ IW
     if (maxQuota >= 0) {
         if (defaultQuota < expectedSize && expectedSize <= maxQuota) {
             newQuota = expectedSize;
-            printf("UI DELEGATE DATABASE CALLBACK: increased quota to %llu\n", newQuota);
+            fprintf(testResult, "UI DELEGATE DATABASE CALLBACK: increased quota to %llu\n", newQuota);
         }
     }
     origin->setQuota(newQuota);
@@ -660,7 +660,7 @@ HRESULT UIDelegate::webViewDidInvalidate(_In_opt_ IWebView* /*sender*/)
 HRESULT UIDelegate::setStatusText(_In_opt_ IWebView*, _In_ BSTR text)
 { 
     if (gTestRunner->dumpStatusCallbacks())
-        printf("UI DELEGATE STATUS CALLBACK: setStatusText:%S\n", text ? text : L"");
+        fprintf(testResult, "UI DELEGATE STATUS CALLBACK: setStatusText:%S\n", text ? text : L"");
     return S_OK;
 }
 
@@ -693,6 +693,6 @@ HRESULT UIDelegate::decidePolicyForGeolocationRequest(_In_opt_ IWebView* /*sende
 
 HRESULT UIDelegate::didPressMissingPluginButton(_In_opt_ IDOMElement* /*element*/)
 {
-    printf("MISSING PLUGIN BUTTON PRESSED\n");
+    fprintf(testResult, "MISSING PLUGIN BUTTON PRESSED\n");
     return S_OK;
 }