ASSERTION FAILED: [weakThis->m_view window] == weakThis->m_targetWindowForMovePreparation
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 May 2019 21:22:30 +0000 (21:22 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 May 2019 21:22:30 +0000 (21:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197574
<rdar://problem/50453181>

Reviewed by Tim Horton.

Source/WebKit:

Tweak the assertion so that it holds even if the WebView gets closed because the completion
handler has been called.

* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::prepareForMoveToWindow):

Tools:

Add API test coverage.

* TestWebKitAPI/Tests/WebKitCocoa/PrepareForMoveToWindow.mm:
(TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244920 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/PrepareForMoveToWindow.mm

index 5200b51..b71ab65 100644 (file)
@@ -1,3 +1,17 @@
+2019-05-03  Chris Dumez  <cdumez@apple.com>
+
+        ASSERTION FAILED: [weakThis->m_view window] == weakThis->m_targetWindowForMovePreparation
+        https://bugs.webkit.org/show_bug.cgi?id=197574
+        <rdar://problem/50453181>
+
+        Reviewed by Tim Horton.
+
+        Tweak the assertion so that it holds even if the WebView gets closed because the completion
+        handler has been called.
+
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::prepareForMoveToWindow):
+
 2019-05-03  Brent Fulgham  <bfulgham@apple.com>
 
         Use more efficient path resolution logic
index eebe02c..0044be5 100644 (file)
@@ -2375,7 +2375,7 @@ void WebViewImpl::prepareForMoveToWindow(NSWindow *targetWindow, WTF::Function<v
         if (!weakThis)
             return;
 
-        ASSERT([weakThis->m_view window] == weakThis->m_targetWindowForMovePreparation);
+        ASSERT(![weakThis->m_view window] || [weakThis->m_view window] == weakThis->m_targetWindowForMovePreparation);
         weakThis->m_targetWindowForMovePreparation = nil;
     });
 
index ffab314..ab70f49 100644 (file)
@@ -1,3 +1,16 @@
+2019-05-03  Chris Dumez  <cdumez@apple.com>
+
+        ASSERTION FAILED: [weakThis->m_view window] == weakThis->m_targetWindowForMovePreparation
+        https://bugs.webkit.org/show_bug.cgi?id=197574
+        <rdar://problem/50453181>
+
+        Reviewed by Tim Horton.
+
+        Add API test coverage.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/PrepareForMoveToWindow.mm:
+        (TEST):
+
 2019-05-03  Yusuke Suzuki  <ysuzuki@apple.com>
 
         [JSC] Generator CodeBlock generation should be idempotent
index 88014ac..f10dd38 100644 (file)
@@ -55,4 +55,25 @@ TEST(WKWebView, PrepareForMoveToWindow)
     TestWebKitAPI::Util::run(&isDone);
 }
 
+
+TEST(WKWebView, PrepareForMoveToWindowThenClose)
+{
+    auto webView = adoptNS([[WKWebView alloc] init]);
+
+    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+    [webView loadRequest:request];
+
+    [webView _test_waitForDidFinishNavigation];
+
+    RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
+
+    [webView _prepareForMoveToWindow:window.get() completionHandler:[webView, window] {
+        isDone = true;
+    }];
+
+    [webView _close];
+
+    TestWebKitAPI::Util::run(&isDone);
+}
+
 #endif