packages icon indicating copy to clipboard operation
packages copied to clipboard

[webview_flutter_wkwebview] Add support for javaScriptCanOpenWindowsAutomatically

Open fummicc1 opened this issue 1 month ago • 0 comments

This PR adds support for WKPreferences.javaScriptCanOpenWindowsAutomatically to allow JavaScript's window.open() to work without user interaction on iOS and macOS.

Changes

  • Added javaScriptCanOpenWindowsAutomatically parameter to WebKitWebViewControllerCreationParams
  • Exposed setJavaScriptCanOpenWindowsAutomatically method via Pigeon API
  • The setting is applied when setJavaScriptMode is called

Usage

final controller = WebKitWebViewController(
  WebKitWebViewControllerCreationParams(
    javaScriptCanOpenWindowsAutomatically: true,
  ),
)
  ..setJavaScriptMode(JavaScriptMode.unrestricted)
  ..loadRequest(Uri.parse('https://example.com'));

Fixes flutter/flutter#112276

Pre-Review Checklist

[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.

fummicc1 avatar Dec 11 '25 19:12 fummicc1