Bug 11522 - In the WebUIDelegate protocol, allow JavaScript alert panels to be sheets so that JavaScript cannot hijack your application
Summary: In the WebUIDelegate protocol, allow JavaScript alert panels to be sheets so ...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-05 08:54 PST by Alexandre
Modified: 2018-01-16 06:21 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandre 2006-11-05 08:54:33 PST
Replace the following three WebUIDelegate protocol methods with versions which use a listener to indicate the result of user interaction (like the related WebUIDelegate protocol method webView:runOpenPanelForFileButtonWithResultListener: does) instead of a return value:

webView:runJavaScriptAlertPanelWithMessage:
webView:runJavaScriptConfirmPanelWithMessage:
webView:runJavaScriptTextInputPanelWithPrompt:defaultText:

This would allow the JavaScript alert, confirmation, and text input panels to be implemented as sheets rather than modal dialogs.

Firefox, for example, implements JavaScript alerts as sheets rather than modal dialogs, which I think is more sensible and has several advantages over Safari's implementation.

With the current WebUIDelegate protocol, when a modal dialog is used for JavaScript alerts, malicious (or buggy) JavaScript can hijack your entire application by programmatically spewing forth an endlesss sequence of alert boxes, not even allowing you the opportunity to quit your application.
Comment 1 Alexandre 2006-11-05 11:30:33 PST
Sorry for posting again, but I found a little bit of information I missed before.

It seems that there are already plans to deprecate the three methods I mentioned in favour of replacements, as noted here:
http://www.opendarwin.org/pipermail/webkit-changes/2005-November/001409.html

Perhaps their replacements can be changed to work more like webView:runOpenPanelForFileButtonWithResultListener: (by using a listener instead of a return value)?

I find it highly undesirable that an application that uses a WebView can be completely taken over by that WebView, even if the WebView is only used as a very minor part of the application.
Comment 2 mitz 2017-06-16 22:25:44 PDT
This is resolved in the Modern WebKit API, where the equivalent WKUIDelegate methods all pass the delegate a completion handler.
Comment 3 mitz 2017-06-16 22:25:44 PDT
This is resolved in the Modern WebKit API, where the equivalent WKUIDelegate methods all pass the delegate a completion handler.