Skip to content

Commit

Permalink
Cherry-pick 7900c68. rdar://122974809
Browse files Browse the repository at this point in the history
    Exception in WebKit::WebExtensionTab::processes().
    https://webkit.org/b/269409
    rdar://122974809

    Reviewed by Jeff Miller and Brian Weinstein.

    When mainWebView() is nil, we need to be careful. Use [NSArray arrayWithObjects:]
    instead of [NSArray arrayWithObject:] since that will make a zero item array
    if the web view is nil, instead of throwing an exception.

    * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionTabCocoa.mm:
    (WebKit::WebExtensionTab::processes const):

    Canonical link: https://commits.webkit.org/274669@main

Canonical link: https://commits.webkit.org/274594.3@safari-7619.1.4-branch
  • Loading branch information
xeenon authored and Dan Robson committed Feb 16, 2024
1 parent 6fafb52 commit 9973435
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,8 @@
if (!isValid())
return { };

auto *webViews = mainWebViewOnly == MainWebViewOnly::Yes ? [NSArray arrayWithObject:mainWebView()] : this->webViews();
// This approach is nil-safe, unlike using @[ mainWebView() ] or [NSArray arrayWithObject:].
auto *webViews = mainWebViewOnly == MainWebViewOnly::Yes ? [NSArray arrayWithObjects:mainWebView(), nil] : this->webViews();

WebProcessProxySet result;
for (WKWebView *webView in webViews) {
Expand Down

0 comments on commit 9973435

Please sign in to comment.