Re: [webkit-dev] Support for showModalDialog in WebKit
Hi Darin - I have a tiny CL related to this, sitting around for a couple of days now - https://bugs.webkit.org/show_bug.cgi?id=40036. Would you be able to review it? Thanks, Prasad On Mon, May 24, 2010 at 10:29 AM, Prasad Tammana pras...@google.com wrote: On Fri, May 21, 2010 at 8:29 PM, Darin Adler da...@apple.com wrote: On May 21, 2010, at 6:40 PM, Prasad Tammana wrote: 2) Added code to invoke abortModal from NSWindowWillCloseNotification notification. I didn’t tell you do do that, and I don’t know why you’re calling abortModal. Sorry, you didn't tell me about the second step. That's part of my description of the scenario in my original mail. I call abortModal to end the modal loop created by runModalForWindow. Prasad ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Support for showModalDialog in WebKit
On Wed, May 19, 2010 at 6:04 PM, Darin Adler da...@apple.com wrote: On May 19, 2010, at 3:00 PM, Prasad Tammana wrote: I'm trying to add support for testing scenarios in the presence of modal dialogs to DumpRenderTree (DRT) and I'm running into an apparent limitation of WebKit support for showModalDialog JavaScript function. Here is what I'm trying to do: 1) I added webViewRunModal function to DRT's UIDelegate implementation and invoked runModalForWindow from it. 2) I added an observer for NSWindowWillCloseNotification and invoked abortModal from it. The issue I'm running into is that the observer is not getting invoked. This is what I figured after debugging: 1) window.close on the modal dialog ends up in WebChromeClient::closeWindowSoon() 2) This calls [m_webView performSelector:@selector(_closeWindow) withObject:nil afterDelay:0.0]; As per documentation, performSelector afterDelay sets a timer that'll only run in NSDefaultRunLoopMode, whereas the runModal sets the loop to be in NSModalPanelRunLoopMode and that message never gets dispatch and close() never gets called. The only work-around I can come up with is to add an abortModal() method to LayoutTestController and make it available to JavaScript. Is that what the WebKit apps are expected to do to support showModalDialog()? Or is there some other hook that I'm missing to make this work? DumpRenderTree can subclass NSApplication and do this: - (NSEvent *)nextEventMatchingMask:(NSUInteger)mask untilDate:(NSDate *)expiration inMode:(NSString *)mode dequeue:(BOOL)dequeue { if (mode == NSModalPanelRunLoopMode) mode = NSDefaultRunLoopMode; return [super nextEventMatchingMask:mask untilDate:expiration inMode:mode dequeue:dequeue]; } As far as the broader question is concerned abut other applications, not sure of the answer. Darin - Thanks for the response. This still doesn't seem like a clean way for an app built on top of WebKit to support showModalDialog. This code will affect the entire app and that doesn't seem desirable at an intuitive. Wondering if there is a cleaner way to support showModalDialog. It'd be great if someone could share how this is done for Safari or any other browser/app. Thanks, Prasad ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Support for showModalDialog in WebKit
Darin, I tried your suggestion: 1) We already have DumpRenderTreeApplication deriving from NSApplication. So I added the nextEventMatchingMask method as you've listed above to that. 2) Added code to invoke abortModal from NSWindowWillCloseNotification notification. Now it works sometimes but crashes with EXC_BAD_ACCESS the other times with the following call stack: #0 0x976ea688 in objc_msgSend #1 0x902a5c7e in runModalCleanup #2 0x903c9b04 in -[NSApplication runModalForWindow:] #3 0x0002a470 in -[UIDelegate webViewRunModal:] at UIDelegate.mm:84 webViewRunModal is my observer for NSWindowWillCloseNotification. I've tried switching from runModalForWindow to beginModelSessionForWindow and got the same exact result. Seems to me like faking the NSDefaultRunLoopMode is interacting badly with something. Please let me know if you have any suggestions. Thanks, Prasad On Fri, May 21, 2010 at 11:18 AM, Prasad Tammana pras...@chromium.orgwrote: On Wed, May 19, 2010 at 6:04 PM, Darin Adler da...@apple.com wrote: On May 19, 2010, at 3:00 PM, Prasad Tammana wrote: I'm trying to add support for testing scenarios in the presence of modal dialogs to DumpRenderTree (DRT) and I'm running into an apparent limitation of WebKit support for showModalDialog JavaScript function. Here is what I'm trying to do: 1) I added webViewRunModal function to DRT's UIDelegate implementation and invoked runModalForWindow from it. 2) I added an observer for NSWindowWillCloseNotification and invoked abortModal from it. The issue I'm running into is that the observer is not getting invoked. This is what I figured after debugging: 1) window.close on the modal dialog ends up in WebChromeClient::closeWindowSoon() 2) This calls [m_webView performSelector:@selector(_closeWindow) withObject:nil afterDelay:0.0]; As per documentation, performSelector afterDelay sets a timer that'll only run in NSDefaultRunLoopMode, whereas the runModal sets the loop to be in NSModalPanelRunLoopMode and that message never gets dispatch and close() never gets called. The only work-around I can come up with is to add an abortModal() method to LayoutTestController and make it available to JavaScript. Is that what the WebKit apps are expected to do to support showModalDialog()? Or is there some other hook that I'm missing to make this work? DumpRenderTree can subclass NSApplication and do this: - (NSEvent *)nextEventMatchingMask:(NSUInteger)mask untilDate:(NSDate *)expiration inMode:(NSString *)mode dequeue:(BOOL)dequeue { if (mode == NSModalPanelRunLoopMode) mode = NSDefaultRunLoopMode; return [super nextEventMatchingMask:mask untilDate:expiration inMode:mode dequeue:dequeue]; } As far as the broader question is concerned abut other applications, not sure of the answer. Darin - Thanks for the response. This still doesn't seem like a clean way for an app built on top of WebKit to support showModalDialog. This code will affect the entire app and that doesn't seem desirable at an intuitive. Wondering if there is a cleaner way to support showModalDialog. It'd be great if someone could share how this is done for Safari or any other browser/app. Thanks, Prasad ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Support for showModalDialog in WebKit
On May 21, 2010, at 6:40 PM, Prasad Tammana wrote: 2) Added code to invoke abortModal from NSWindowWillCloseNotification notification. I didn’t tell you do do that, and I don’t know why you’re calling abortModal. -- Darin ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Support for showModalDialog in WebKit
On May 19, 2010, at 3:00 PM, Prasad Tammana wrote: I'm trying to add support for testing scenarios in the presence of modal dialogs to DumpRenderTree (DRT) and I'm running into an apparent limitation of WebKit support for showModalDialog JavaScript function. Here is what I'm trying to do: 1) I added webViewRunModal function to DRT's UIDelegate implementation and invoked runModalForWindow from it. 2) I added an observer for NSWindowWillCloseNotification and invoked abortModal from it. The issue I'm running into is that the observer is not getting invoked. This is what I figured after debugging: 1) window.close on the modal dialog ends up in WebChromeClient::closeWindowSoon() 2) This calls [m_webView performSelector:@selector(_closeWindow) withObject:nil afterDelay:0.0]; As per documentation, performSelector afterDelay sets a timer that'll only run in NSDefaultRunLoopMode, whereas the runModal sets the loop to be in NSModalPanelRunLoopMode and that message never gets dispatch and close() never gets called. The only work-around I can come up with is to add an abortModal() method to LayoutTestController and make it available to JavaScript. Is that what the WebKit apps are expected to do to support showModalDialog()? Or is there some other hook that I'm missing to make this work? DumpRenderTree can subclass NSApplication and do this: - (NSEvent *)nextEventMatchingMask:(NSUInteger)mask untilDate:(NSDate *)expiration inMode:(NSString *)mode dequeue:(BOOL)dequeue { if (mode == NSModalPanelRunLoopMode) mode = NSDefaultRunLoopMode; return [super nextEventMatchingMask:mask untilDate:expiration inMode:mode dequeue:dequeue]; } As far as the broader question is concerned abut other applications, not sure of the answer. -- Darin ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev