Title: [279833] trunk
Revision
279833
Author
[email protected]
Date
2021-07-12 10:10:25 -0700 (Mon, 12 Jul 2021)

Log Message

[Cocoa] Incorrect deprecation declaration for -[WKWebView closeAllMediaPresentations:]
https://bugs.webkit.org/show_bug.cgi?id=227860
<rdar://80376777>

Reviewed by Sam Weinig.

Source/WebKit:

In r277645, we added a deprecation declaration for -closeAllMediaPresentations:completion, but
that API was never shipped in a release. The actual shipped API, -closeAllMediaPresentations,
was removed entirely, leading to bincompat crashes when binaries built against older SDKs are
run against newer OSs.

Correct the deprecated API declaration, and re-add support for -closeAllMediaPresentations.

* UIProcess/API/Cocoa/WKWebView.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView closeAllMediaPresentations]):

Tools:

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

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (279832 => 279833)


--- trunk/Source/WebKit/ChangeLog	2021-07-12 17:08:33 UTC (rev 279832)
+++ trunk/Source/WebKit/ChangeLog	2021-07-12 17:10:25 UTC (rev 279833)
@@ -1,3 +1,22 @@
+2021-07-12  Jer Noble  <[email protected]>
+
+        [Cocoa] Incorrect deprecation declaration for -[WKWebView closeAllMediaPresentations:]
+        https://bugs.webkit.org/show_bug.cgi?id=227860
+        <rdar://80376777>
+
+        Reviewed by Sam Weinig.
+
+        In r277645, we added a deprecation declaration for -closeAllMediaPresentations:completion, but
+        that API was never shipped in a release. The actual shipped API, -closeAllMediaPresentations,
+        was removed entirely, leading to bincompat crashes when binaries built against older SDKs are
+        run against newer OSs.
+
+        Correct the deprecated API declaration, and re-add support for -closeAllMediaPresentations.
+
+        * UIProcess/API/Cocoa/WKWebView.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView closeAllMediaPresentations]):
+
 2021-07-12  Wenson Hsieh  <[email protected]>
 
         [watchOS] Make a few additional adjustments to support system minimum layout margins

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.h (279832 => 279833)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.h	2021-07-12 17:08:33 UTC (rev 279832)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.h	2021-07-12 17:10:25 UTC (rev 279833)
@@ -343,9 +343,7 @@
  @discussion Includes picture-in-picture and fullscreen.
  */
 - (void)closeAllMediaPresentationsWithCompletionHandler:(void (^_Nullable)(void))completionHandler WK_API_AVAILABLE(macos(12.0), ios(15.0));
-#ifndef __swift__
-- (void)closeAllMediaPresentations:(void (^_Nullable)(void))completionHandler WK_API_DEPRECATED_WITH_REPLACEMENT("closeAllMediaPresentationsWithCompletionHandler:", macos(11.3, 12.0), ios(14.5, 15.0));
-#endif
+- (void)closeAllMediaPresentations WK_API_DEPRECATED_WITH_REPLACEMENT("closeAllMediaPresentationsWithCompletionHandler:", macos(11.3, 12.0), ios(14.5, 15.0));
 
 /*! @abstract Pauses media playback in WKWebView.
  @discussion Pauses media playback. Media in the page can be restarted by calling play() on a media element or resume() on an AudioContext in _javascript_. A user can also use media controls to play media content after it has been paused.

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (279832 => 279833)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2021-07-12 17:08:33 UTC (rev 279832)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2021-07-12 17:10:25 UTC (rev 279833)
@@ -934,6 +934,11 @@
     return false;
 }
 
+- (void)closeAllMediaPresentations
+{
+    [self closeAllMediaPresentationsWithCompletionHandler:^{ }];
+}
+
 - (void)closeAllMediaPresentations:(void (^)(void))completionHandler
 {
     [self closeAllMediaPresentationsWithCompletionHandler:completionHandler];

Modified: trunk/Tools/ChangeLog (279832 => 279833)


--- trunk/Tools/ChangeLog	2021-07-12 17:08:33 UTC (rev 279832)
+++ trunk/Tools/ChangeLog	2021-07-12 17:10:25 UTC (rev 279833)
@@ -1,3 +1,14 @@
+2021-07-12  Jer Noble  <[email protected]>
+
+        [Cocoa] Incorrect deprecation declaration for -[WKWebView closeAllMediaPresentations:]
+        https://bugs.webkit.org/show_bug.cgi?id=227860
+        <rdar://80376777>
+
+        Reviewed by Sam Weinig.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewCloseAllMediaPresentations.mm:
+        (TEST):
+
 2021-07-12  Wenson Hsieh  <[email protected]>
 
         [watchOS] Make a few additional adjustments to support system minimum layout margins

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewCloseAllMediaPresentations.mm (279832 => 279833)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewCloseAllMediaPresentations.mm	2021-07-12 17:08:33 UTC (rev 279832)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewCloseAllMediaPresentations.mm	2021-07-12 17:10:25 UTC (rev 279833)
@@ -209,4 +209,23 @@
     EXPECT_TRUE([webView _allMediaPresentationsClosed]);
 }
 
+TEST(WKWebViewCloseAllMediaPresentations, RemovedCloseAllMediaPresentationAPIs)
+{
+    // In r271970, we renamed -closeAllMediaPresentations to -closeAllMediaPresentations:completionHandler, which broke
+    // binary compatability of apps linked against older SDKs. Ensure calling the removed API does not crash.
+
+    auto *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals" configureJSCForTesting:YES];
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration addToWindow:YES]);
+
+    EXPECT_TRUE([webView respondsToSelector:@selector(closeAllMediaPresentations)]);
+
+    RetainPtr<NSException> exception;
+    @try {
+        [webView closeAllMediaPresentations];
+    } @catch(NSException *caught) {
+        exception = caught;
+    }
+    EXPECT_FALSE(exception);
+}
+
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to