Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Edge browser based on Chromium not recognized correctly #113

Open
3 tasks done
mark-veenstra opened this issue Dec 19, 2019 · 4 comments · May be fixed by #115
Open
3 tasks done

New Edge browser based on Chromium not recognized correctly #113

mark-veenstra opened this issue Dec 19, 2019 · 4 comments · May be fixed by #115

Comments

@mark-veenstra
Copy link

Bug Report

Problem

What is expected to happen?

The device.model which will execute this code, now detects the new Edge browser which is based on Chromium and released on 15th January as Chrome, which would be incorrect.

What does actually happen?

It detects the new Edge browser as Chrome.

Information

I think it should also not detect this new browser as Edge, but maybe as EdgeChromium? Because there are big difference between the "old" Edge en the new Chromium Edge. And maybe you would like to block the old Edge, but the new Edge is ok! Therefore the detection should return a different browser name I would suggest.

When the "old" Edge was released the following issue solved this check for the old Edge: https://issues.apache.org/jira/browse/CB-12105.

The new Chromium based Edge exposed the following userAgent string:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36 Edg/79.0.309.54

Command or Code

This code has the issue: https://github.com/apache/cordova-plugin-device/blob/master/src/browser/DeviceProxy.js#L35

It could be updated to the next code to see a difference between the old and the new Edge.

function getBrowserInfo (getModel) {
    var userAgent = navigator.userAgent;
    var returnVal = '';
    var offset;

    if ((offset = userAgent.indexOf('Edge')) !== -1) {
        returnVal = (getModel) ? 'Edge' : userAgent.substring(offset + 5);
    } else if ((offset = userAgent.indexOf('Edg')) !== -1) {
        returnVal = (getModel) ? 'EdgeChromium' : userAgent.substring(offset + 4);
    } else if ((offset = userAgent.indexOf('Chrome')) !== -1) {
        returnVal = (getModel) ? 'Chrome' : userAgent.substring(offset + 7);
    } else if ((offset = userAgent.indexOf('Safari')) !== -1) {
        if (getModel) {
            returnVal = 'Safari';
        } else {
            returnVal = userAgent.substring(offset + 7);

            if ((offset = userAgent.indexOf('Version')) !== -1) {
                returnVal = userAgent.substring(offset + 8);
            }
        }
    } else if ((offset = userAgent.indexOf('Firefox')) !== -1) {
        returnVal = (getModel) ? 'Firefox' : userAgent.substring(offset + 8);
    } else if ((offset = userAgent.indexOf('MSIE')) !== -1) {
        returnVal = (getModel) ? 'MSIE' : userAgent.substring(offset + 5);
    } else if ((offset = userAgent.indexOf('Trident')) !== -1) {
        returnVal = (getModel) ? 'MSIE' : '11';
    }

    if ((offset = returnVal.indexOf(';')) !== -1 || (offset = returnVal.indexOf(' ')) !== -1) {
        returnVal = returnVal.substring(0, offset);
    }

    return returnVal;
}

Environment, Platform, Device

The new Edge released on 15th January

Version information

N/A

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@timbru31
Copy link
Member

Pull Requests are very welcome! 😉

@mark-veenstra
Copy link
Author

@timbru31 No Problem, but are you guys happy with the new name or not? Is it okay to identify the browser as EdgeChromium?

@mark-veenstra
Copy link
Author

Or would it be better to keep the browser name Edge and that people check if it is version >79, then it is a Chromium based Edge, otherwise a non-Chromium based.

See: https://en.wikipedia.org/wiki/Microsoft_Edge

@breautek
Copy link
Contributor

I feel like it is important to make a distinction between between old edge vs chromium edge as I think anybody is doing that check are doing it for backwards compatibility reasons (some things even if the browser supports it, just simply doesn't work very well, or isn't very efficient/performant compared to other browsers).

If it is easy enough to make that distinction with just a version check, then I think I would prefer to keep the browser name Edge.

mark-veenstra added a commit to Mediapioniers/cordova-plugin-device that referenced this issue Jan 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants