Modified: trunk/LayoutTests/ChangeLog (202325 => 202326)
--- trunk/LayoutTests/ChangeLog 2016-06-22 05:52:52 UTC (rev 202325)
+++ trunk/LayoutTests/ChangeLog 2016-06-22 07:48:15 UTC (rev 202326)
@@ -1,3 +1,14 @@
+2016-06-22 Per Arne Vollan <[email protected]>
+
+ window.showModalDialog doesn't work in DumpRenderTree on Windows
+ https://bugs.webkit.org/show_bug.cgi?id=53675
+
+ Reviewed by Brent Fulgham.
+
+ Update test expectations for modal dialog tests.
+
+ * platform/win/TestExpectations:
+
2016-06-21 Alexey Proskuryakov <[email protected]>
Land test expectations for rdar://problem/26422051.
Modified: trunk/LayoutTests/platform/win/TestExpectations (202325 => 202326)
--- trunk/LayoutTests/platform/win/TestExpectations 2016-06-22 05:52:52 UTC (rev 202325)
+++ trunk/LayoutTests/platform/win/TestExpectations 2016-06-22 07:48:15 UTC (rev 202326)
@@ -308,12 +308,7 @@
webkit.org/b/140234 fast/text/midword-break-before-surrogate-pair-2.html [ Failure ]
webkit.org/b/140234 fast/text/narrow-non-breaking-space.html [ ImageOnlyFailure ]
-# TODO DRT doesn't support showModalDialog
-webkit.org/b/53675 fast/events/show-modal-dialog-onblur-onfocus.html [ Skip ]
-webkit.org/b/53675 fast/harness/show-modal-dialog.html [ Skip ]
-webkit.org/b/53675 fast/events/scroll-event-during-modal-dialog.html [ Skip ]
-webkit.org/b/53675 fast/dom/Window/open-window-min-size.html [ Skip ]
-webkit.org/b/53675 js/dom/function-length.html [ Skip ]
+fast/events/scroll-event-during-modal-dialog.html [ Failure ]
webkit.org/b/151506 fast/events/beforeunload-showModalDialog.html [ Skip ]
webkit.org/b/151506 fast/events/pagehide-showModalDialog.html [ Skip ]
Modified: trunk/Tools/ChangeLog (202325 => 202326)
--- trunk/Tools/ChangeLog 2016-06-22 05:52:52 UTC (rev 202325)
+++ trunk/Tools/ChangeLog 2016-06-22 07:48:15 UTC (rev 202326)
@@ -1,3 +1,21 @@
+2016-06-22 Per Arne Vollan <[email protected]>
+
+ window.showModalDialog doesn't work in DumpRenderTree on Windows
+ https://bugs.webkit.org/show_bug.cgi?id=53675
+
+ Reviewed by Brent Fulgham.
+
+ Implement modal dialog support in DumpRenderTree.
+
+ * DumpRenderTree/win/UIDelegate.cpp:
+ (UIDelegate::canRunModal):
+ (getHandleFromWebView):
+ (UIDelegate::createModalDialog):
+ (findTopLevelParent):
+ (UIDelegate::runModal):
+ (UIDelegate::webViewClose):
+ * DumpRenderTree/win/UIDelegate.h:
+
2016-06-21 Aakash Jain <[email protected]>
Fix formatting issues reported by check-webkit-style
Modified: trunk/Tools/DumpRenderTree/win/UIDelegate.cpp (202325 => 202326)
--- trunk/Tools/DumpRenderTree/win/UIDelegate.cpp 2016-06-22 05:52:52 UTC (rev 202325)
+++ trunk/Tools/DumpRenderTree/win/UIDelegate.cpp 2016-06-22 07:48:15 UTC (rev 202326)
@@ -313,24 +313,112 @@
return E_NOTIMPL;
}
-HRESULT UIDelegate::canRunModal(_In_opt_ IWebView*, _Out_ BOOL* /*canRunBoolean*/)
+HRESULT UIDelegate::canRunModal(_In_opt_ IWebView*, _Out_ BOOL* canRunBoolean)
{
- return E_NOTIMPL;
+ if (!canRunBoolean)
+ return E_POINTER;
+ *canRunBoolean = TRUE;
+ return S_OK;
}
-HRESULT UIDelegate::createModalDialog(_In_opt_ IWebView* /*sender*/, _In_opt_ IWebURLRequest* /*request*/, _COM_Outptr_opt_ IWebView** newWebView)
+static HWND getHandleFromWebView(IWebView* webView)
{
+ COMPtr<IWebViewPrivate2> webViewPrivate;
+ HRESULT hr = webView->QueryInterface(&webViewPrivate);
+ if (FAILED(hr))
+ return nullptr;
+
+ HWND webViewWindow = nullptr;
+ hr = webViewPrivate->viewWindow(&webViewWindow);
+ if (FAILED(hr))
+ return nullptr;
+
+ return webViewWindow;
+}
+
+HRESULT UIDelegate::createModalDialog(_In_opt_ IWebView* sender, _In_opt_ IWebURLRequest*, _COM_Outptr_opt_ IWebView** newWebView)
+{
if (!newWebView)
return E_POINTER;
- *newWebView = nullptr;
- return E_NOTIMPL;
+
+ COMPtr<IWebView> webView;
+ HRESULT hr = WebKitCreateInstance(CLSID_WebView, 0, IID_IWebView, (void**)&webView);
+ if (FAILED(hr))
+ return hr;
+
+ m_modalDialogParent = ::CreateWindow(L"STATIC", L"ModalDialog", WS_OVERLAPPED | WS_VISIBLE, 0, 0, 0, 0, getHandleFromWebView(sender), nullptr, nullptr, nullptr);
+
+ hr = webView->setHostWindow(m_modalDialogParent);
+ if (FAILED(hr))
+ return hr;
+
+ RECT clientRect = { 0, 0, 0, 0 };
+ hr = webView->initWithFrame(clientRect, 0, _bstr_t(L""));
+ if (FAILED(hr))
+ return hr;
+
+ COMPtr<IWebUIDelegate> uiDelegate;
+ hr = sender->uiDelegate(&uiDelegate);
+ if (FAILED(hr))
+ return hr;
+
+ hr = webView->setUIDelegate(uiDelegate.get());
+ if (FAILED(hr))
+ return hr;
+
+ COMPtr<IWebFrameLoadDelegate> frameLoadDelegate;
+ hr = sender->frameLoadDelegate(&frameLoadDelegate);
+ if (FAILED(hr))
+ return hr;
+
+ hr = webView.get()->setFrameLoadDelegate(frameLoadDelegate.get());
+ if (FAILED(hr))
+ return hr;
+
+ *newWebView = webView.leakRef();
+
+ return S_OK;
}
-HRESULT UIDelegate::runModal(_In_opt_ IWebView*)
+static HWND findTopLevelParent(HWND window)
{
- return E_NOTIMPL;
+ if (!window)
+ return nullptr;
+
+ HWND current = window;
+ for (HWND parent = GetParent(current); current; current = parent, parent = GetParent(parent)) {
+ if (!parent)
+ return current;
+ }
+ ASSERT_NOT_REACHED();
+ return nullptr;
}
+HRESULT UIDelegate::runModal(_In_opt_ IWebView* webView)
+{
+ COMPtr<IWebView> protector(webView);
+
+ auto topLevelParent = findTopLevelParent(::GetWindow(m_modalDialogParent, GW_OWNER));
+
+ ::EnableWindow(topLevelParent, FALSE);
+
+ while (::IsWindow(getHandleFromWebView(webView))) {
+#if USE(CF)
+ CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true);
+#endif
+ MSG msg;
+ if (!::GetMessage(&msg, 0, 0, 0))
+ break;
+
+ ::TranslateMessage(&msg);
+ ::DispatchMessage(&msg);
+ }
+
+ ::EnableWindow(topLevelParent, TRUE);
+
+ return S_OK;
+}
+
HRESULT UIDelegate::isMenuBarVisible(_In_opt_ IWebView*, _Out_ BOOL* visible)
{
if (!visible)
@@ -483,6 +571,8 @@
HWND hostWindow;
sender->hostWindow(&hostWindow);
DestroyWindow(hostWindow);
+ if (hostWindow == m_modalDialogParent)
+ m_modalDialogParent = nullptr;
return S_OK;
}
Modified: trunk/Tools/DumpRenderTree/win/UIDelegate.h (202325 => 202326)
--- trunk/Tools/DumpRenderTree/win/UIDelegate.h 2016-06-22 05:52:52 UTC (rev 202325)
+++ trunk/Tools/DumpRenderTree/win/UIDelegate.h 2016-06-22 07:48:15 UTC (rev 202326)
@@ -144,6 +144,7 @@
std::unique_ptr<DRTUndoManager> m_undoManager;
COMPtr<IWebDesktopNotificationsDelegate> m_desktopNotifications;
+ HWND m_modalDialogParent { nullptr };
};
#endif