Changeset 270560 in webkit


Ignore:
Timestamp:
Dec 8, 2020 3:54:12 PM (3 years ago)
Author:
Chris Dumez
Message:

Unreviewed, reverting r269983.

Seems to have regressed PLT5

Reverted changeset:

"[iOS] beforeunload event does not fire in MobileSafari"
https://bugs.webkit.org/show_bug.cgi?id=219102
https://trac.webkit.org/changeset/269983

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r270557 r270560  
     12020-12-08  Chris Dumez  <cdumez@apple.com>
     2
     3        Unreviewed, reverting r269983.
     4
     5        Seems to have regressed PLT5
     6
     7        Reverted changeset:
     8
     9        "[iOS] beforeunload event does not fire in MobileSafari"
     10        https://bugs.webkit.org/show_bug.cgi?id=219102
     11        https://trac.webkit.org/changeset/269983
     12
    1132020-12-08  Simon Fraser  <simon.fraser@apple.com>
    214
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r270273 r270560  
    32353235    if (!page)
    32363236        return true;
     3237    if (!page->chrome().canRunBeforeUnloadConfirmPanel())
     3238        return true;
    32373239
    32383240    // Store all references to each subframe in advance since beforeunload's event handler may modify frame
     
    33643366        document->defaultEventHandler(beforeUnloadEvent.get());
    33653367
    3366     if (!chrome.canRunBeforeUnloadConfirmPanel() || !shouldAskForNavigationConfirmation(*document, beforeUnloadEvent))
     3368    if (!shouldAskForNavigationConfirmation(*document, beforeUnloadEvent))
    33673369        return true;
    33683370
  • trunk/Tools/ChangeLog

    r270559 r270560  
     12020-12-08  Chris Dumez  <cdumez@apple.com>
     2
     3        Unreviewed, reverting r269983.
     4
     5        Seems to have regressed PLT5
     6
     7        Reverted changeset:
     8
     9        "[iOS] beforeunload event does not fire in MobileSafari"
     10        https://bugs.webkit.org/show_bug.cgi?id=219102
     11        https://trac.webkit.org/changeset/269983
     12
    1132020-12-08  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/Tools/TestWebKitAPI/Tests/WebKit/beforeunload.html

    r269983 r270560  
    44<script>
    55onbeforeunload = (ev) => {
    6     if (window.webkit && webkit.messageHandlers.testHandler)
    7         webkit.messageHandlers.testHandler.postMessage("beforeunload called");
    86    ev.preventDefault();
    97    return "foo";
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ModalAlerts.mm

    r269983 r270560  
    314314
    315315#endif
    316 
    317 static bool wasBeforeUnloadEventHandlerCalled = false;
    318 
    319 @interface UIDelegateWithoutRunBeforeUnload : NSObject <WKUIDelegate>
    320 @end
    321 
    322 @implementation UIDelegateWithoutRunBeforeUnload
    323 
    324 - (void)webViewDidClose:(WKWebView *)webView
    325 {
    326     [webView _close];
    327 }
    328 
    329 @end
    330 
    331 @interface BeforeUnloadMessageHandler : NSObject <WKScriptMessageHandler>
    332 @end
    333 
    334 @implementation BeforeUnloadMessageHandler
    335 - (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
    336 {
    337     NSString *scriptMessage = [message body];
    338     EXPECT_WK_STREQ(@"beforeunload called", scriptMessage);
    339     wasBeforeUnloadEventHandlerCalled = true;
    340 }
    341 @end
    342 
    343 TEST(WebKit, BeforeUnloadEventWithoutRunBeforeUnloadConfirmPanelUIDelegate)
    344 {
    345     auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
    346     auto messageHandler = adoptNS([[BeforeUnloadMessageHandler alloc] init]);
    347     [[webViewConfiguration userContentController] addScriptMessageHandler:messageHandler.get() name:@"testHandler"];
    348 
    349     auto uiDelegate = adoptNS([[UIDelegateWithoutRunBeforeUnload alloc] init]);
    350     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
    351     [webView setUIDelegate:uiDelegate.get()];
    352 
    353     [webView synchronouslyLoadTestPageNamed:@"beforeunload"];
    354 
    355     TestWebKitAPI::Util::spinRunLoop(10);
    356 
    357     [webView _tryClose];
    358 
    359     // The beforeunload event handler should get called even if the client application does not
    360     // have a UIDelegate that can show the before unload prompt.
    361     TestWebKitAPI::Util::run(&wasBeforeUnloadEventHandlerCalled);
    362 
    363     // The view should get closed.
    364     while (![webView _isClosed])
    365         TestWebKitAPI::Util::sleep(0.1);
    366 }
Note: See TracChangeset for help on using the changeset viewer.