From c4bb4d1af89e1ef5f57ef1b1cf7b65ce62c30ba5 Mon Sep 17 00:00:00 2001 From: Chris Dumez Date: Sat, 23 Jul 2022 08:58:11 -0700 Subject: [PATCH] Stop exposing showModalDialog(), behind a linked-on-after check https://bugs.webkit.org/show_bug.cgi?id=243099 Reviewed by Ryosuke Niwa and Darin Adler. Now that we support the dialog element, drop support for showModalDialog(), behind a linked-on-after check. Blink and Gecko have already dropped their support for showModalDialog() a long time ago. * LayoutTests/editing/execCommand/show-modal-dialog-during-execCommand.html: * LayoutTests/fast/animation/request-animation-frame-during-modal.html: * LayoutTests/fast/dom/Window/delete-operations.html: * LayoutTests/fast/dom/Window/forbid-showModalDialog.html: * LayoutTests/fast/dom/Window/open-window-min-size.html: * LayoutTests/fast/dom/Window/showModalDialog-mandatory-parameter.html: * LayoutTests/fast/dom/Window/window-function-frame-getter-precedence.html: * LayoutTests/fast/dom/Window/window-function-name-getter-precedence.html: * LayoutTests/fast/dom/Window/window-lookup-precedence.html: * LayoutTests/fast/dom/Window/window-property-shadowing.html: * LayoutTests/fast/dom/null-page-show-modal-dialog-crash.html: * LayoutTests/fast/dom/wrapper-identity.html: * LayoutTests/fast/events/beforeunload-showModalDialog.html: * LayoutTests/fast/events/pagehide-showModalDialog.html: * LayoutTests/fast/events/scroll-event-during-modal-dialog.html: * LayoutTests/fast/events/show-modal-dialog-onblur-onfocus.html: * LayoutTests/fast/events/unload-showModalDialog.html: * LayoutTests/fast/harness/show-modal-dialog.html: * LayoutTests/http/tests/cookies/document-cookie-after-showModalDialog.html: * LayoutTests/http/tests/security/cross-frame-access-call.html: * LayoutTests/http/tests/security/cross-frame-access-get.html: * LayoutTests/http/tests/security/cross-frame-access-getOwnPropertyDescriptor.html: * LayoutTests/http/tests/security/cross-frame-access-put.html: * LayoutTests/http/tests/security/cross-origin-modal-dialog-base.html: * LayoutTests/http/tests/security/navigate-when-restoring-cached-page.html: * LayoutTests/http/tests/security/showModalDialog-sync-cross-origin-page-load.html: * LayoutTests/http/tests/security/showModalDialog-sync-cross-origin-page-load2.html: * LayoutTests/js/dom/function-length.html: * Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml: * Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h: * Source/WebCore/bindings/js/JSDOMWindowBase.cpp: (WebCore::JSDOMWindowBase::finishCreation): * Source/WebKit/Shared/WebPreferencesDefaultValues.cpp: (WebKit::defaultShowModalDialogEnabled): * Source/WebKit/Shared/WebPreferencesDefaultValues.h: * Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.h: * Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.mm: (WebKit::defaultShowModalDialogEnabled): * Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm: (-[ModalDelegate _webViewRunModal:]): Deleted. (-[ModalDelegate _webView:setResizable:]): Deleted. (-[ModalDelegate webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:]): Deleted. * Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp: (beforeAll): (testWebViewAllowModalDialogs): Deleted. (testWebViewDisallowModalDialogs): Deleted. * Tools/WebKitTestRunner/TestOptions.cpp: (WTR::TestOptions::defaults): Canonical link: https://commits.webkit.org/252759@main --- .../show-modal-dialog-during-execCommand.html | 1 + .../request-animation-frame-during-modal.html | 1 + .../fast/dom/Window/delete-operations.html | 1 + .../dom/Window/forbid-showModalDialog.html | 1 + .../fast/dom/Window/open-window-min-size.html | 1 + .../showModalDialog-mandatory-parameter.html | 1 + ...ndow-function-frame-getter-precedence.html | 1 + ...indow-function-name-getter-precedence.html | 1 + .../dom/Window/window-lookup-precedence.html | 1 + .../dom/Window/window-property-shadowing.html | 1 + .../null-page-show-modal-dialog-crash.html | 1 + LayoutTests/fast/dom/wrapper-identity.html | 1 + .../events/beforeunload-showModalDialog.html | 1 + .../fast/events/pagehide-showModalDialog.html | 1 + .../scroll-event-during-modal-dialog.html | 1 + .../show-modal-dialog-onblur-onfocus.html | 1 + .../fast/events/unload-showModalDialog.html | 1 + .../fast/harness/show-modal-dialog.html | 1 + ...document-cookie-after-showModalDialog.html | 1 + .../security/cross-frame-access-call.html | 1 + .../security/cross-frame-access-get.html | 1 + ...frame-access-getOwnPropertyDescriptor.html | 1 + .../security/cross-frame-access-put.html | 2 +- .../cross-origin-modal-dialog-base.html | 1 + .../navigate-when-restoring-cached-page.html | 2 +- ...dalDialog-sync-cross-origin-page-load.html | 1 + ...alDialog-sync-cross-origin-page-load2.html | 1 + .../historical.window-expected.txt | 2 +- LayoutTests/js/dom/function-length.html | 1 + .../js/dom/global-function-resolve.html | 1 + LayoutTests/platform/win/TestExpectations | 11 +++++ .../Preferences/WebPreferencesInternal.yaml | 13 ++++++ .../wtf/cocoa/RuntimeApplicationChecksCocoa.h | 1 + .../WebCore/bindings/js/JSDOMWindowBase.cpp | 7 +++- .../Shared/WebPreferencesDefaultValues.cpp | 10 +++++ .../Shared/WebPreferencesDefaultValues.h | 2 + .../mac/WebView/WebPreferencesDefaultValues.h | 1 + .../WebView/WebPreferencesDefaultValues.mm | 6 +++ .../Tests/WebKitCocoa/UIDelegate.mm | 41 ------------------- .../Tests/WebKitGLib/TestUIClient.cpp | 33 --------------- Tools/WebKitTestRunner/TestOptions.cpp | 1 + 41 files changed, 81 insertions(+), 78 deletions(-) diff --git a/LayoutTests/editing/execCommand/show-modal-dialog-during-execCommand.html b/LayoutTests/editing/execCommand/show-modal-dialog-during-execCommand.html index 7db3581da723..8c1551db2775 100644 --- a/LayoutTests/editing/execCommand/show-modal-dialog-during-execCommand.html +++ b/LayoutTests/editing/execCommand/show-modal-dialog-during-execCommand.html @@ -1,3 +1,4 @@ + diff --git a/LayoutTests/fast/animation/request-animation-frame-during-modal.html b/LayoutTests/fast/animation/request-animation-frame-during-modal.html index 11657166c894..f61ab7e14bee 100644 --- a/LayoutTests/fast/animation/request-animation-frame-during-modal.html +++ b/LayoutTests/fast/animation/request-animation-frame-during-modal.html @@ -1,3 +1,4 @@ + diff --git a/LayoutTests/fast/dom/Window/delete-operations.html b/LayoutTests/fast/dom/Window/delete-operations.html index 3a757e05658f..f0bdd6c18c0c 100644 --- a/LayoutTests/fast/dom/Window/delete-operations.html +++ b/LayoutTests/fast/dom/Window/delete-operations.html @@ -1,3 +1,4 @@ + diff --git a/LayoutTests/fast/dom/Window/forbid-showModalDialog.html b/LayoutTests/fast/dom/Window/forbid-showModalDialog.html index 74981de9bff8..866bcf889d09 100644 --- a/LayoutTests/fast/dom/Window/forbid-showModalDialog.html +++ b/LayoutTests/fast/dom/Window/forbid-showModalDialog.html @@ -1,3 +1,4 @@ + diff --git a/LayoutTests/fast/dom/Window/open-window-min-size.html b/LayoutTests/fast/dom/Window/open-window-min-size.html index 5a8e0a51b6a6..86c119a9efb0 100644 --- a/LayoutTests/fast/dom/Window/open-window-min-size.html +++ b/LayoutTests/fast/dom/Window/open-window-min-size.html @@ -1,3 +1,4 @@ + diff --git a/LayoutTests/fast/dom/Window/showModalDialog-mandatory-parameter.html b/LayoutTests/fast/dom/Window/showModalDialog-mandatory-parameter.html index 9e41b3bcad46..88ea2ba936d3 100644 --- a/LayoutTests/fast/dom/Window/showModalDialog-mandatory-parameter.html +++ b/LayoutTests/fast/dom/Window/showModalDialog-mandatory-parameter.html @@ -1,3 +1,4 @@ + diff --git a/LayoutTests/fast/dom/Window/window-property-shadowing.html b/LayoutTests/fast/dom/Window/window-property-shadowing.html index ef9bd9993679..e4efbde008ad 100644 --- a/LayoutTests/fast/dom/Window/window-property-shadowing.html +++ b/LayoutTests/fast/dom/Window/window-property-shadowing.html @@ -1,3 +1,4 @@ + diff --git a/LayoutTests/fast/dom/null-page-show-modal-dialog-crash.html b/LayoutTests/fast/dom/null-page-show-modal-dialog-crash.html index 91a6d349063e..b00f001caecb 100644 --- a/LayoutTests/fast/dom/null-page-show-modal-dialog-crash.html +++ b/LayoutTests/fast/dom/null-page-show-modal-dialog-crash.html @@ -1,3 +1,4 @@ + This is a test for https://bugs.webkit.org/show_bug.cgi?id=19541 RBug 19541: Null pointer in showModalDialog() diff --git a/LayoutTests/fast/dom/wrapper-identity.html b/LayoutTests/fast/dom/wrapper-identity.html index e680abd802a1..f73b6c6e8aa6 100644 --- a/LayoutTests/fast/dom/wrapper-identity.html +++ b/LayoutTests/fast/dom/wrapper-identity.html @@ -1,3 +1,4 @@ + diff --git a/LayoutTests/fast/events/beforeunload-showModalDialog.html b/LayoutTests/fast/events/beforeunload-showModalDialog.html index ee8f3524864c..973673beaf03 100644 --- a/LayoutTests/fast/events/beforeunload-showModalDialog.html +++ b/LayoutTests/fast/events/beforeunload-showModalDialog.html @@ -1,3 +1,4 @@ + diff --git a/LayoutTests/fast/events/show-modal-dialog-onblur-onfocus.html b/LayoutTests/fast/events/show-modal-dialog-onblur-onfocus.html index 95d3d9f1acbf..651f0f5d2644 100644 --- a/LayoutTests/fast/events/show-modal-dialog-onblur-onfocus.html +++ b/LayoutTests/fast/events/show-modal-dialog-onblur-onfocus.html @@ -1,3 +1,4 @@ + diff --git a/LayoutTests/http/tests/security/cross-frame-access-get.html b/LayoutTests/http/tests/security/cross-frame-access-get.html index 35d5b9fd29e0..c750213000d3 100644 --- a/LayoutTests/http/tests/security/cross-frame-access-get.html +++ b/LayoutTests/http/tests/security/cross-frame-access-get.html @@ -1,3 +1,4 @@ + diff --git a/LayoutTests/http/tests/security/cross-frame-access-getOwnPropertyDescriptor.html b/LayoutTests/http/tests/security/cross-frame-access-getOwnPropertyDescriptor.html index ea1ad7ad6582..be8e7aa323c3 100644 --- a/LayoutTests/http/tests/security/cross-frame-access-getOwnPropertyDescriptor.html +++ b/LayoutTests/http/tests/security/cross-frame-access-getOwnPropertyDescriptor.html @@ -1,3 +1,4 @@ + diff --git a/LayoutTests/http/tests/security/cross-frame-access-put.html b/LayoutTests/http/tests/security/cross-frame-access-put.html index 840afdcbd70d..fd6430f38593 100644 --- a/LayoutTests/http/tests/security/cross-frame-access-put.html +++ b/LayoutTests/http/tests/security/cross-frame-access-put.html @@ -1,4 +1,4 @@ - +

This test checks cross-frame access security of window attribute setters (rdar://problem/5326791).


diff --git a/LayoutTests/http/tests/security/cross-origin-modal-dialog-base.html b/LayoutTests/http/tests/security/cross-origin-modal-dialog-base.html
index 33412cc84401..ddebff0b542e 100644
--- a/LayoutTests/http/tests/security/cross-origin-modal-dialog-base.html
+++ b/LayoutTests/http/tests/security/cross-origin-modal-dialog-base.html
@@ -1,3 +1,4 @@
+
 
 
 
diff --git a/LayoutTests/http/tests/security/navigate-when-restoring-cached-page.html b/LayoutTests/http/tests/security/navigate-when-restoring-cached-page.html
index e4d5b34b5a84..ff2941312c74 100644
--- a/LayoutTests/http/tests/security/navigate-when-restoring-cached-page.html
+++ b/LayoutTests/http/tests/security/navigate-when-restoring-cached-page.html
@@ -1,4 +1,4 @@
-
+
 
 
 
diff --git a/LayoutTests/http/tests/security/showModalDialog-sync-cross-origin-page-load.html b/LayoutTests/http/tests/security/showModalDialog-sync-cross-origin-page-load.html
index 7ceec17d4f5a..417d445fac73 100644
--- a/LayoutTests/http/tests/security/showModalDialog-sync-cross-origin-page-load.html
+++ b/LayoutTests/http/tests/security/showModalDialog-sync-cross-origin-page-load.html
@@ -1,3 +1,4 @@
+
 
 
 
diff --git a/LayoutTests/http/tests/security/showModalDialog-sync-cross-origin-page-load2.html b/LayoutTests/http/tests/security/showModalDialog-sync-cross-origin-page-load2.html
index 137db92015ed..b5fe41c35c93 100644
--- a/LayoutTests/http/tests/security/showModalDialog-sync-cross-origin-page-load2.html
+++ b/LayoutTests/http/tests/security/showModalDialog-sync-cross-origin-page-load2.html
@@ -1,3 +1,4 @@
+
 
 
 
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/historical.window-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/historical.window-expected.txt
index 950713a464e6..c609b00c743c 100644
--- a/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/historical.window-expected.txt
+++ b/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/historical.window-expected.txt
@@ -1,3 +1,3 @@
 
-FAIL showModalDialog() has been removed from the platform assert_false: expected false got true
+PASS showModalDialog() has been removed from the platform
 
diff --git a/LayoutTests/js/dom/function-length.html b/LayoutTests/js/dom/function-length.html
index ae8b8dede937..482865154033 100644
--- a/LayoutTests/js/dom/function-length.html
+++ b/LayoutTests/js/dom/function-length.html
@@ -1,3 +1,4 @@
+
 
 
 
diff --git a/LayoutTests/js/dom/global-function-resolve.html b/LayoutTests/js/dom/global-function-resolve.html
index 9baa4398df2b..b5f9d4228671 100644
--- a/LayoutTests/js/dom/global-function-resolve.html
+++ b/LayoutTests/js/dom/global-function-resolve.html
@@ -1,3 +1,4 @@
+
 
 
 
diff --git a/LayoutTests/platform/win/TestExpectations b/LayoutTests/platform/win/TestExpectations
index 8b09c81b0767..70c057f1e3e5 100644
--- a/LayoutTests/platform/win/TestExpectations
+++ b/LayoutTests/platform/win/TestExpectations
@@ -618,6 +618,17 @@ webkit.org/b/151506 fast/events/beforeunload-showModalDialog.html [ Skip ]
 webkit.org/b/151506 fast/events/pagehide-showModalDialog.html [ Skip ]
 webkit.org/b/151506 fast/events/unload-showModalDialog.html [ Skip ]
 
+# ShowModalDialog preference currently cannot be enabled on Windows.
+fast/dom/Window/delete-operations.html [ Skip ]
+fast/dom/Window/forbid-showModalDialog.html [ Skip ]
+fast/dom/Window/showModalDialog-mandatory-parameter.html [ Skip ]
+fast/dom/Window/window-function-frame-getter-precedence.html [ Skip ]
+fast/dom/Window/window-function-name-getter-precedence.html [ Skip ]
+fast/events/show-modal-dialog-onblur-onfocus.html [ Skip ]
+http/tests/cookies/document-cookie-after-showModalDialog.html [ Skip ]
+js/dom/function-length.html [ Skip ]
+js/dom/global-function-resolve.html [ Skip ]
+
 # TODO Color input is not yet enabled.
 fast/forms/color/ [ Skip ]
 
diff --git a/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml b/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml
index 181185a844ef..12a15c9a4cce 100644
--- a/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml
+++ b/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml
@@ -853,6 +853,19 @@ ServiceWorkersUserGestureEnabled:
     WebCore:
       default: true
 
+ShowModalDialogEnabled:
+  type: bool
+  humanReadableName: "Legacy showModalDialog() API"
+  humanReadableDescription: "Legacy showModalDialog() API"
+  defaultValue:
+    WebKitLegacy:
+      "PLATFORM(IOS_FAMILY)": WebKit::defaultShowModalDialogEnabled()
+      default: false
+    WebKit:
+      default: WebKit::defaultShowModalDialogEnabled()
+    WebCore:
+      default: false
+
 # FIXME: Is this implemented for WebKitLegacy? If not, this should be excluded from WebKitLegacy entirely.
 SpeakerSelectionRequiresUserGesture:
   type: bool
diff --git a/Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h b/Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h
index 88eac1043aa2..284a7a1b73a3 100644
--- a/Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h
+++ b/Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h
@@ -67,6 +67,7 @@ enum class SDKAlignedBehavior {
     NoLaBanquePostaleQuirks,
     NoMoviStarPlusCORSPreflightQuirk,
     NoPokerBrosBuiltInTagQuirk,
+    NoShowModalDialog,
     NoTheSecretSocietyHiddenMysteryWindowOpenQuirk,
     NoTypedArrayAPIQuirk,
     NoUnconditionalUniversalSandboxExtension,
diff --git a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp b/Source/WebCore/bindings/js/JSDOMWindowBase.cpp
index 4d644483df45..3e569c493644 100644
--- a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp
+++ b/Source/WebCore/bindings/js/JSDOMWindowBase.cpp
@@ -64,6 +64,10 @@
 #include "ChromeClient.h"
 #endif
 
+#if PLATFORM(COCOA)
+#include 
+#endif
+
 
 namespace WebCore {
 using namespace JSC;
@@ -128,7 +132,8 @@ void JSDOMWindowBase::finishCreation(VM& vm, JSWindowProxy* proxy)
     if (m_wrapped && m_wrapped->frame() && m_wrapped->frame()->settings().needsSiteSpecificQuirks())
         setNeedsSiteSpecificQuirks(true);
 
-    putDirectCustomAccessor(vm, builtinNames(vm).showModalDialogPublicName(), CustomGetterSetter::create(vm, showModalDialogGetter, nullptr), static_cast(PropertyAttribute::CustomValue));
+    if (m_wrapped && m_wrapped->frame() && m_wrapped->frame()->settings().showModalDialogEnabled())
+        putDirectCustomAccessor(vm, builtinNames(vm).showModalDialogPublicName(), CustomGetterSetter::create(vm, showModalDialogGetter, nullptr), static_cast(PropertyAttribute::CustomValue));
 }
 
 void JSDOMWindowBase::destroy(JSCell* cell)
diff --git a/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp b/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp
index bc338aff1bd6..a7cc914639da 100644
--- a/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp
+++ b/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp
@@ -163,4 +163,14 @@ bool defaultMediaSessionCoordinatorEnabled()
 }
 #endif
 
+bool defaultShowModalDialogEnabled()
+{
+#if PLATFORM(COCOA)
+    static bool newSDK = linkedOnOrAfterSDKWithBehavior(SDKAlignedBehavior::NoShowModalDialog);
+    return !newSDK;
+#else
+    return false;
+#endif
+}
+
 } // namespace WebKit
diff --git a/Source/WebKit/Shared/WebPreferencesDefaultValues.h b/Source/WebKit/Shared/WebPreferencesDefaultValues.h
index 1981a9195f4b..a2ea0252d74a 100644
--- a/Source/WebKit/Shared/WebPreferencesDefaultValues.h
+++ b/Source/WebKit/Shared/WebPreferencesDefaultValues.h
@@ -83,4 +83,6 @@ bool defaultVisualTranslationEnabled();
 bool defaultRemoveBackgroundEnabled();
 #endif
 
+bool defaultShowModalDialogEnabled();
+
 } // namespace WebKit
diff --git a/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.h b/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.h
index b00880ce68f5..7ac0adb38055 100644
--- a/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.h
+++ b/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.h
@@ -43,6 +43,7 @@ bool defaultInlineMediaPlaybackRequiresPlaysInlineAttribute();
 bool defaultJavaScriptCanOpenWindowsAutomatically();
 bool defaultPassiveTouchListenersAsDefaultOnDocument();
 bool defaultRequiresUserGestureToLoadVideo();
+bool defaultShowModalDialogEnabled();
 bool defaultWebSQLEnabled();
 bool defaultAllowContentSecurityPolicySourceStarToMatchAnyProtocol();
 #endif
diff --git a/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.mm b/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.mm
index 754eb6673dee..cfdce6ab6860 100644
--- a/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.mm
+++ b/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.mm
@@ -75,6 +75,12 @@ bool defaultPassiveTouchListenersAsDefaultOnDocument()
     return result;
 }
 
+bool defaultShowModalDialogEnabled()
+{
+    static bool newSDK = linkedOnOrAfterSDKWithBehavior(SDKAlignedBehavior::NoShowModalDialog);
+    return !newSDK;
+}
+
 bool defaultRequiresUserGestureToLoadVideo()
 {
     static bool shouldRequireUserGestureToLoadVideo = linkedOnOrAfterSDKWithBehavior(SDKAlignedBehavior::RequiresUserGestureToLoadVideo);
diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm
index 5d0c6e11d234..c5e9739a948d 100644
--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm
+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm
@@ -623,47 +623,6 @@ - (void)_webViewDidRequestPointerLock:(WKWebView *)webView completionHandler:(vo
     TestWebKitAPI::Util::run(&done);
 }
 
-static bool resizableSet;
-
-@interface ModalDelegate : NSObject 
-@end
-
-@implementation ModalDelegate
-
-- (void)_webViewRunModal:(WKWebView *)webView
-{
-    EXPECT_TRUE(resizableSet);
-    EXPECT_EQ(webView, createdWebView.get());
-    done = true;
-}
-
-- (void)_webView:(WKWebView *)webView setResizable:(BOOL)isResizable
-{
-    EXPECT_FALSE(isResizable);
-    resizableSet = true;
-}
-
-- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
-{
-    createdWebView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration]);
-    [createdWebView setUIDelegate:self];
-    return createdWebView.get();
-}
-
-@end
-
-TEST(WebKit, RunModal)
-{
-    auto delegate = adoptNS([[ModalDelegate alloc] init]);
-    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
-    [webView setUIDelegate:delegate.get()];
-    NSURL *url = [[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
-    NSString *html = [NSString stringWithFormat:@"%@%@%@", @" "];
-    [webView synchronouslyLoadHTMLString:html];
-    [webView sendClicksAtPoint:NSMakePoint(20, 600 - 20) numberOfClicks:1];
-    TestWebKitAPI::Util::run(&done);
-}
-
 static bool receivedWindowFrame;
 
 @interface WindowFrameDelegate : NSObject 
diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp
index d85508a5d32e..a754c94dfa97 100644
--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp
+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp
@@ -630,37 +630,6 @@ class ModalDialogsTest: public UIClientTest {
     }
 };
 
-static void testWebViewAllowModalDialogs(ModalDialogsTest* test, gconstpointer)
-{
-    WebKitSettings* settings = webkit_web_view_get_settings(test->m_webView);
-    webkit_settings_set_allow_modal_dialogs(settings, TRUE);
-    webkit_settings_set_allow_top_navigation_to_data_urls(settings, TRUE);
-
-    test->loadHtml("')\">", 0);
-    test->waitUntilMainLoopFinishes();
-
-    Vector& events = test->m_webViewEvents;
-    g_assert_cmpint(events.size(), ==, 4);
-    g_assert_cmpint(events[0], ==, UIClientTest::Create);
-    g_assert_cmpint(events[1], ==, UIClientTest::ReadyToShow);
-    g_assert_cmpint(events[2], ==, UIClientTest::RunAsModal);
-    g_assert_cmpint(events[3], ==, UIClientTest::Close);
-}
-
-static void testWebViewDisallowModalDialogs(ModalDialogsTest* test, gconstpointer)
-{
-    WebKitSettings* settings = webkit_web_view_get_settings(test->m_webView);
-    webkit_settings_set_allow_modal_dialogs(settings, FALSE);
-
-    test->loadHtml("')\">", 0);
-    // We need to use a timeout here because the viewClose() function
-    // won't ever be called as the dialog won't be created.
-    test->wait(1);
-
-    Vector& events = test->m_webViewEvents;
-    g_assert_cmpint(events.size(), ==, 0);
-}
-
 static void testWebViewJavaScriptDialogs(UIClientTest* test, gconstpointer)
 {
     test->showInWindow();
@@ -1488,8 +1457,6 @@ void beforeAll()
 #if PLATFORM(GTK)
     CreateNavigationDataTest::add("WebKitWebView", "create-navigation-data", testWebViewCreateNavigationData);
 #endif
-    ModalDialogsTest::add("WebKitWebView", "allow-modal-dialogs", testWebViewAllowModalDialogs);
-    ModalDialogsTest::add("WebKitWebView", "disallow-modal-dialogs", testWebViewDisallowModalDialogs);
     UIClientTest::add("WebKitWebView", "javascript-dialogs", testWebViewJavaScriptDialogs);
     UIClientTest::add("WebKitWebView", "window-properties", testWebViewWindowProperties);
 #if PLATFORM(GTK)
diff --git a/Tools/WebKitTestRunner/TestOptions.cpp b/Tools/WebKitTestRunner/TestOptions.cpp
index da60d924959f..23d0c6e532d4 100644
--- a/Tools/WebKitTestRunner/TestOptions.cpp
+++ b/Tools/WebKitTestRunner/TestOptions.cpp
@@ -118,6 +118,7 @@ const TestFeatures& TestOptions::defaults()
             { "RequiresUserGestureForAudioPlayback", false },
             { "RequiresUserGestureForMediaPlayback", false },
             { "RequiresUserGestureForVideoPlayback", false },
+            { "ShowModalDialogEnabled", false },
             { "SpeakerSelectionRequiresUserGesture", false },
             { "SubpixelAntialiasedLayerTextEnabled", false },
             { "TabsToLinks", false },