Diff
Modified: trunk/Tools/ChangeLog (174795 => 174796)
--- trunk/Tools/ChangeLog 2014-10-16 22:02:16 UTC (rev 174795)
+++ trunk/Tools/ChangeLog 2014-10-16 22:08:12 UTC (rev 174796)
@@ -1,3 +1,38 @@
+2014-10-16 Brent Fulgham <[email protected]>
+
+ [Win] Update DRT to match Mac Logic
+ https://bugs.webkit.org/show_bug.cgi?id=137787
+
+ Reviewed by Dean Jackson.
+
+ * DumpRenderTree/win/DumpRenderTree.cpp:
+ (initialize): 0 -> nullptr
+ (runTest): Initialize MSG structure before using.
+ (main): Add CRT debug flags if building DRT with debug malloc on Windows.
+ Also, cleanly shut down COM when exiting.
+ * DumpRenderTree/win/FrameLoadDelegate.cpp:
+ (FrameLoadDelegate::didChangeLocationWithinPageForFrame): Move from
+ header and add printf to match Mac.
+ (FrameLoadDelegate::windowScriptObjectAvailable): Ditto.
+ * DumpRenderTree/win/FrameLoadDelegate.h:
+ (FrameLoadDelegate::didChangeLocationWithinPageForFrame): Deleted.
+ (FrameLoadDelegate::windowScriptObjectAvailable): Deleted.
+ * DumpRenderTree/win/ResourceLoadDelegate.cpp:
+ (isLocalhost): Added.
+ (hostIsUsedBySomeTestsToGenerateError): Added.
+ (ResourceLoadDelegate::willSendRequest): Add logic to mimic Mac's use
+ of certain error and redirect host names.
+ * DumpRenderTree/win/UIDelegate.cpp:
+ (UIDelegate::runJavaScriptAlertPanelWithMessage): Use 'done' flag to decide if
+ anything should be output to the console. This modifies behavior to match the Mac.
+ (UIDelegate::runJavaScriptConfirmPanelWithMessage): Ditto.
+ (UIDelegate::runJavaScriptTextInputPanelWithPrompt): Ditto.
+ (UIDelegate::runBeforeUnloadConfirmPanelWithMessage): Ditto.
+ (UIDelegate::webViewAddMessageToConsole): Ditto.
+ * WinLauncher/PageLoadTestClient.cpp:
+ (PageLoadTestClient::pageLoadEndedAtTime): Drive-by-fix for an assertion that I
+ added last week.
+
2014-10-16 Commit Queue <[email protected]>
Unreviewed, rolling out r174754.
Modified: trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp (174795 => 174796)
--- trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp 2014-10-16 22:02:16 UTC (rev 174795)
+++ trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp 2014-10-16 22:08:12 UTC (rev 174796)
@@ -309,7 +309,7 @@
dllRegisterServer();
// Init COM
- OleInitialize(0);
+ OleInitialize(nullptr);
static LPCTSTR fontsToInstall[] = {
TEXT("AHEM____.ttf"),
@@ -1064,6 +1064,7 @@
WorkQueue::shared()->clear();
WorkQueue::shared()->setFrozen(false);
+ MSG msg = { 0 };
HWND hostWindow;
webView->hostWindow(&hostWindow);
@@ -1077,7 +1078,6 @@
request->setHTTPMethod(methodBStr);
frame->loadRequest(request.get());
- MSG msg;
while (true) {
#if USE(CF)
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true);
@@ -1241,6 +1241,11 @@
int main(int argc, const char* argv[])
{
+#ifdef _CRTDBG_MAP_ALLOC
+ _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
+ _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
+#endif
+
// Cygwin calls ::SetErrorMode(SEM_FAILCRITICALERRORS), which we will inherit. This is bad for
// testing/debugging, as it causes the post-mortem debugger not to be invoked. We reset the
// error mode here to work around Cygwin's behavior. See <http://webkit.org/b/55222>.
@@ -1399,7 +1404,12 @@
#endif
shutDownWebKit();
+#ifdef _CRTDBG_MAP_ALLOC
+ _CrtDumpMemoryLeaks();
+#endif
+ ::OleUninitialize();
+
return 0;
}
Modified: trunk/Tools/DumpRenderTree/win/FrameLoadDelegate.cpp (174795 => 174796)
--- trunk/Tools/DumpRenderTree/win/FrameLoadDelegate.cpp 2014-10-16 22:02:16 UTC (rev 174795)
+++ trunk/Tools/DumpRenderTree/win/FrameLoadDelegate.cpp 2014-10-16 22:08:12 UTC (rev 174796)
@@ -139,6 +139,14 @@
return S_OK;
}
+HRESULT FrameLoadDelegate::didChangeLocationWithinPageForFrame(IWebView* , IWebFrame* frame)
+{
+ if (!done && gTestRunner->dumpFrameLoadCallbacks())
+ printf("%s - didChangeLocationWithinPageForFrame\n", descriptionSuitableForTestResult(frame).c_str());
+
+ return S_OK;
+}
+
HRESULT FrameLoadDelegate::didFailProvisionalLoadWithError(IWebView* /*webView*/, IWebError* error, IWebFrame* frame)
{
if (!done && gTestRunner->dumpFrameLoadCallbacks())
@@ -282,6 +290,16 @@
return E_NOTIMPL;
}
+HRESULT FrameLoadDelegate::windowScriptObjectAvailable(IWebView*, JSContextRef, JSObjectRef)
+{
+ if (!done && gTestRunner->dumpFrameLoadCallbacks())
+ printf("?? - windowScriptObjectAvailable\n");
+
+ ASSERT_NOT_REACHED();
+
+ return S_OK;
+}
+
HRESULT FrameLoadDelegate::didClearWindowObject(IWebView*, JSContextRef, JSObjectRef, IWebFrame*)
{
return E_NOTIMPL;
Modified: trunk/Tools/DumpRenderTree/win/FrameLoadDelegate.h (174795 => 174796)
--- trunk/Tools/DumpRenderTree/win/FrameLoadDelegate.h 2014-10-16 22:02:16 UTC (rev 174795)
+++ trunk/Tools/DumpRenderTree/win/FrameLoadDelegate.h 2014-10-16 22:08:12 UTC (rev 174796)
@@ -89,9 +89,7 @@
/* [in] */ IWebError *error,
/* [in] */ IWebFrame *forFrame);
- virtual HRESULT STDMETHODCALLTYPE didChangeLocationWithinPageForFrame(
- /* [in] */ IWebView *webView,
- /* [in] */ IWebFrame *frame) { return E_NOTIMPL; }
+ virtual HRESULT STDMETHODCALLTYPE didChangeLocationWithinPageForFrame(IWebView*, IWebFrame*);
virtual HRESULT STDMETHODCALLTYPE willPerformClientRedirectToURL(
/* [in] */ IWebView *webView,
@@ -108,16 +106,10 @@
/* [in] */ IWebView *webView,
/* [in] */ IWebFrame *frame);
- virtual HRESULT STDMETHODCALLTYPE windowScriptObjectAvailable(
- /* [in] */ IWebView *sender,
- /* [in] */ JSContextRef context,
- /* [in] */ JSObjectRef windowObject) { return E_NOTIMPL; }
+ virtual HRESULT STDMETHODCALLTYPE windowScriptObjectAvailable(IWebView*,
+JSContextRef, JSObjectRef windowObject);
- virtual /* [local] */ HRESULT STDMETHODCALLTYPE didClearWindowObject(
- /* [in] */ IWebView* webView,
- /* [in] */ JSContextRef context,
- /* [in] */ JSObjectRef windowObject,
- /* [in] */ IWebFrame* frame);
+ virtual /* [local] */ HRESULT STDMETHODCALLTYPE didClearWindowObject(IWebView*, JSContextRef, JSObjectRef windowObject, IWebFrame*);
// IWebFrameLoadDelegatePrivate
virtual HRESULT STDMETHODCALLTYPE didFinishDocumentLoadForFrame(
Modified: trunk/Tools/DumpRenderTree/win/ResourceLoadDelegate.cpp (174795 => 174796)
--- trunk/Tools/DumpRenderTree/win/ResourceLoadDelegate.cpp 2014-10-16 22:02:16 UTC (rev 174795)
+++ trunk/Tools/DumpRenderTree/win/ResourceLoadDelegate.cpp 2014-10-16 22:08:12 UTC (rev 174796)
@@ -35,6 +35,7 @@
#include <comutil.h>
#include <sstream>
#include <tchar.h>
+#include <wtf/RetainPtr.h>
#include <wtf/Vector.h>
using namespace std;
@@ -217,6 +218,17 @@
return S_OK;
}
+static bool isLocalhost(CFStringRef host)
+{
+ return kCFCompareEqualTo == CFStringCompare(host, CFSTR("127.0.0.1"), 0)
+ || kCFCompareEqualTo == CFStringCompare(host, CFSTR("localhost"), 0);
+}
+
+static bool hostIsUsedBySomeTestsToGenerateError(CFStringRef host)
+{
+ return kCFCompareEqualTo == CFStringCompare(host, CFSTR("255.255.255.255"), 0);
+}
+
HRESULT ResourceLoadDelegate::willSendRequest(IWebView* webView, unsigned long identifier, IWebURLRequest* request,
IWebURLResponse* redirectResponse, IWebDataSource* dataSource, IWebURLRequest** newRequest)
{
@@ -229,22 +241,56 @@
if (!done && !gTestRunner->deferMainResourceDataLoad()) {
COMPtr<IWebDataSourcePrivate> dataSourcePrivate(Query, dataSource);
- if (!dataSourcePrivate)
+ if (!dataSourcePrivate) {
+ *newRequest = nullptr;
return E_FAIL;
+ }
dataSourcePrivate->setDeferMainResourceDataLoad(FALSE);
}
if (!done && gTestRunner->willSendRequestReturnsNull()) {
- *newRequest = 0;
+ *newRequest = nullptr;
return S_OK;
}
if (!done && gTestRunner->willSendRequestReturnsNullOnRedirect() && redirectResponse) {
printf("Returning null for this redirect\n");
- *newRequest = 0;
+ *newRequest = nullptr;
return S_OK;
}
+ _bstr_t urlBstr;
+ if (FAILED(request->URL(&urlBstr.GetBSTR()))) {
+ printf("Request has no URL\n");
+ *newRequest = nullptr;
+ return E_FAIL;
+ }
+
+ RetainPtr<CFStringRef> str = adoptCF(CFStringCreateWithCString(0, static_cast<const char*>(urlBstr), kCFStringEncodingWindowsLatin1));
+ RetainPtr<CFURLRef> url = "" str.get(), nullptr));
+ if (url) {
+ RetainPtr<CFStringRef> host = adoptCF(CFURLCopyHostName(url.get()));
+ RetainPtr<CFStringRef> scheme = adoptCF(CFURLCopyScheme(url.get()));
+
+ if (host && ((kCFCompareEqualTo == CFStringCompare(scheme.get(), CFSTR("http"), kCFCompareCaseInsensitive))
+ || (kCFCompareEqualTo == CFStringCompare(scheme.get(), CFSTR("https"), kCFCompareCaseInsensitive)))) {
+ RetainPtr<CFStringRef> testPathOrURL = adoptCF(CFStringCreateWithCString(kCFAllocatorDefault, gTestRunner->testPathOrURL().c_str(), kCFStringEncodingWindowsLatin1));
+ RetainPtr<CFMutableStringRef> lowercaseTestPathOrURL = adoptCF(CFStringCreateMutableCopy(kCFAllocatorDefault, CFStringGetLength(testPathOrURL.get()), testPathOrURL.get()));
+ RetainPtr<CFLocaleRef> locale = CFLocaleCopyCurrent();
+ CFStringLowercase(lowercaseTestPathOrURL.get(), locale.get());
+ RetainPtr<CFStringRef> testHost;
+ if (CFStringHasPrefix(lowercaseTestPathOrURL.get(), CFSTR("http:")) || CFStringHasPrefix(lowercaseTestPathOrURL.get(), CFSTR("https:"))) {
+ RetainPtr<CFURLRef> testPathURL = adoptCF(CFURLCreateWithString(kCFAllocatorDefault, lowercaseTestPathOrURL.get(), nullptr));
+ 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));
+ *newRequest = nullptr;
+ return S_OK;
+ }
+ }
+ }
+
IWebMutableURLRequest* requestCopy = 0;
request->mutableCopy(&requestCopy);
const set<string>& clearHeaders = gTestRunner->willSendRequestClearHeaders();
Modified: trunk/Tools/DumpRenderTree/win/UIDelegate.cpp (174795 => 174796)
--- trunk/Tools/DumpRenderTree/win/UIDelegate.cpp 2014-10-16 22:02:16 UTC (rev 174795)
+++ trunk/Tools/DumpRenderTree/win/UIDelegate.cpp 2014-10-16 22:08:12 UTC (rev 174796)
@@ -367,15 +367,19 @@
HRESULT UIDelegate::runJavaScriptAlertPanelWithMessage(IWebView* /*sender*/, BSTR message)
{
- printf("ALERT: %S\n", message ? message : L"");
- fflush(stdout);
+ if (!done) {
+ printf("ALERT: %S\n", message ? message : L"");
+ fflush(stdout);
+ }
return S_OK;
}
HRESULT UIDelegate::runJavaScriptConfirmPanelWithMessage(IWebView* /*sender*/, BSTR message, BOOL* result)
{
- printf("CONFIRM: %S\n", message ? message : L"");
+ if (!done)
+ printf("CONFIRM: %S\n", message ? message : L"");
+
*result = TRUE;
return S_OK;
@@ -383,7 +387,9 @@
HRESULT UIDelegate::runJavaScriptTextInputPanelWithPrompt(IWebView* /*sender*/, BSTR message, BSTR defaultText, BSTR* result)
{
- printf("PROMPT: %S, default text: %S\n", message ? message : L"", defaultText ? defaultText : L"");
+ if (!done)
+ printf("PROMPT: %S, default text: %S\n", message ? message : L"", defaultText ? defaultText : L"");
+
*result = SysAllocString(defaultText);
return S_OK;
@@ -393,13 +399,20 @@
{
if (!result)
return E_POINTER;
- printf("CONFIRM NAVIGATION: %S\n", message ? message : L"");
+
+ if (!done)
+ printf("CONFIRM NAVIGATION: %S\n", message ? message : L"");
+
*result = !gTestRunner->shouldStayOnPageAfterHandlingBeforeUnload();
+
return S_OK;
}
HRESULT UIDelegate::webViewAddMessageToConsole(IWebView* /*sender*/, BSTR message, int lineNumber, BSTR url, BOOL isError)
{
+ if (done)
+ return S_OK;
+
wstring newMessage;
if (message) {
newMessage = message;
Modified: trunk/Tools/WinLauncher/PageLoadTestClient.cpp (174795 => 174796)
--- trunk/Tools/WinLauncher/PageLoadTestClient.cpp 2014-10-16 22:02:16 UTC (rev 174795)
+++ trunk/Tools/WinLauncher/PageLoadTestClient.cpp 2014-10-16 22:08:12 UTC (rev 174796)
@@ -121,7 +121,7 @@
void PageLoadTestClient::pageLoadEndedAtTime(CFAbsoluteTime endTime)
{
- ASSERT(m_endTimes.size() == m_currentRepetition);
+ ASSERT(!m_pageLoadTesting || m_endTimes.size() == m_currentRepetition);
m_endTimes.append(endTime);
if (m_currentRepetition) {