Repository: flutter
Issue: popup_failed_to_open error on Safari with google_identity_services_web
Labels: platform-web,package,browser: safari-macos,P2,browser: safari-ios,team-web,triaged-web,p: google_identity_services_web

### Steps to reproduce

Use the above code with Google Identity Services Web (google_identity_services_web).
Attempt to request an access token by calling client.requestAccessToken on Safari.
The error popup_failed_to_open appears in the console, indicating that the popup window failed to open.

### Expected results

The popup should open correctly in Safari, allowing the user to grant consent and proceed with the Google sign-in process.

### Actual results

In Safari, the popup fails to open, and the error message popup_failed_to_open is thrown.

Workarounds Attempted:
I tried the following workarounds, but the issue persists:

Ensuring that the popup blocker is disabled.
Trying different configurations for the token request.
Affected Platforms:
Safari (macOS, iOS)
Other browsers (e.g., Chrome, Firefox) work fine.

### Code sample

<details open><summary>Code sample</summary>

```dart
void googleSignIn(
    Function(String token) onSuccess, VoidCallback onError) async {
  await gis.loadWebSdk();
  
  final TokenClientConfig config = TokenClientConfig(
    client_id: '',
    scope: scopes,
    enable_granular_consent: true,
    callback: (token) => onTokenResponse(token, onSuccess, onError),
    error_callback: (error) => onErrorResponse.call(error, onError),
  );
  
  final OverridableTokenClientConfig overridableCfg = OverridableTokenClientConfig(
    scope: scopes + myConnectionsScopes,
  );
  
  final TokenClient client = oauth2.initTokenClient(config);
  
  // Disable the Popup Blocker for this to work, or move this to a Button press.
  client.requestAccessToken(overridableCfg);
}

Future<void> onErrorResponse(
    GoogleIdentityServicesError? error, VoidCallback onError) async {
  onError.call();
}

Future<void> onTokenResponse(TokenResponse token,
    Function(String token) onSuccess, VoidCallback onError) async {
  if (token.error != null) {
    onError.call();
    return;
  }
  await onSuccess.call(token.access_token ?? '');
  oauth2.revoke(token.access_token!, (TokenRevocationResponse response) {
   
  });
}

```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.24.2, on macOS 14.5 23F79 darwin-x64, locale en-IR)
    • Flutter version 3.24.2 on channel stable at /Users/alireza/Library/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4cf269e36d (5 weeks ago), 2024-09-03 14:30:00 -0700
    • Engine revision a6bd3f1de1
    • Dart version 3.5.2
    • DevTools version 2.37.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/alireza/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.93.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.88.0

[✓] Connected device (3 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554                        • android-x64    • Android 13 (API 33) (emulator)
    • iPhone 15 (mobile)           • 5C53B2B6-8755-45AC-A6EF-AD9483448B69 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-17-2 (simulator)
    • Chrome (web)                 • chrome                               • web-javascript • Google Chrome 129.0.6668.90

[✓] Network resources
    • All expected network resources are available.

```

</details>