Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[web] Resolve OS as iOs for iDevice Safari requesting desktop version of app.#25957

Merged
fluttergithubbot merged 2 commits intoflutter:masterfrom
ditman:fix-ipad-ua-detection
May 11, 2021
Merged

[web] Resolve OS as iOs for iDevice Safari requesting desktop version of app.#25957
fluttergithubbot merged 2 commits intoflutter:masterfrom
ditman:fix-ipad-ua-detection

Conversation

@ditman
Copy link
Member

@ditman ditman commented May 5, 2021

This PR tweaks the OS detection code in Flutter web, so iDevices requesting flutter apps in "desktop mode" (spoofing their navigator attributes) are still correctly identified as iDevices, and not confused with "Macs".

I've also added tests for the OS detection code.

Fixes flutter/flutter#81918

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.
  • The reviewer has submitted any presubmit flakes in this PR using the engine presubmit flakes form before re-triggering the failure.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added the platform-web Code specifically for the web engine label May 5, 2021
@google-cla google-cla bot added the cla: yes label May 5, 2021
Copy link
Contributor

@yjbanov yjbanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

OperatingSystem _detectOperatingSystem() {
final String platform = html.window.navigator.platform!;
final String userAgent = html.window.navigator.userAgent;
@visibleForTesting
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I stopped using @visibleForTesting. Making things public in the engine code is fine because the entire library becomes private later in the process (dart:_engine).

Copy link
Member Author

@ditman ditman May 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file hasn't been cleaned up yet, it uses @visibleForTesting for the other tested method, I'm going to leave this here until we remove all. Also, if we ever move to import/export we don't have to touch this again :P

@ditman ditman added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label May 11, 2021
@fluttergithubbot fluttergithubbot merged commit 3c93ad4 into flutter:master May 11, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 11, 2021
@ditman ditman deleted the fix-ipad-ua-detection branch May 11, 2021 23:54
fluttergithubbot pushed a commit to flutter/flutter that referenced this pull request May 12, 2021
naudzghebre pushed a commit to naudzghebre/engine that referenced this pull request May 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes platform-web Code specifically for the web engine waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[web] iPad Safari on iPadOS >= 13 incorrectly identified as "desktop"

3 participants