WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
74961
window.prompt() returns empty string instead of null when Cancel is pressed
https://bugs.webkit.org/show_bug.cgi?id=74961
Summary
window.prompt() returns empty string instead of null when Cancel is pressed
Paul Wieland
Reported
2011-12-20 15:02:49 PST
JavaScript window.prompt() should return null when the user clicks the cancel button. Instead an empty string is returned. This seems to be a newly introduced bug with Safari version 5.1. Sample: console.log(null != window.prompt('this is a test')); Pressing escape / clicking cancel should log false. Hitting enter / clicking OK should log true. Instead, window.prompt() returns true no matter which button is pressed.
Attachments
Add attachment
proposed patch, testcase, etc.
Daniel Bates
Comment 1
2012-01-10 15:58:46 PST
From briefly debugging, m_client.runJavaScriptPrompt() (*) in WebUIClient::runJavaScriptPrompt() returns the empty string when the Cancel button is pressed in the NSAlert dialog. Concatenating the multi-process call chains into one chain, the call chain leading up to WebUIClient::runJavaScriptPrompt() has the form: ... => DOMWindow::prompt() => Chrome::runJavaScriptPrompt() => WebChromeClient::runJavaScriptPrompt() => ... => WebUIClient::runJavaScriptPrompt() Ultimately WebUIClient::runJavaScriptPrompt() returns the empty string through this chain (in reverse order) to JavaScript. Therefore we return the empty string when the Cancel button is pressed in the JavaScript prompt() dialog. (*) <
http://trac.webkit.org/browser/trunk/Source/WebKit2/UIProcess/WebUIClient.cpp?rev=102935#L142
> For completeness, this bug doesn't occur in single-process mode in Mac Safari Version 5.1.2 (7534.52.7). That is, window.prompt() returns null when the Cancel button is pressed in the JavaScript prompt() dialog.
Alexey Proskuryakov
Comment 2
2012-01-11 11:10:53 PST
<
rdar://problem/10677480
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug