Detecting “Tablet/Touch Mode” in Edge using JavaScript on Windows 10? - windows-10

This question was asked before, but the answers are not exactly what I need.
I need to distinguish in Microsoft Edge if it's a tablet or not (Desktop).
1) The following thread:
Can you detect "Tablet Mode" in Edge and IE11 using JavaScript on Windows 10?
worked indeed, but I'm afraid that in the next version Microsoft will change the behavior.
How can I be sure that they won't?
Answers with if condition of window.PointerEvent do not work at all, since it's defined in Desktop.
I can't use CSS Media Queries Interaction media features as suggested here:
Is there any way to detect if user has launched microsoft edge tablet or desktop browser?

Here are the hardware specific differences in the Edge browser capabilities:
The only differences are due to certain device-specific qualities – for example, codec support may be different on phones due to missing hardware acceleration, and Flash is not supported on Windows 10 Mobile. Because Windows 10 Mobile has a different background model, RTC (Real-Time Communications) APIs are also currently not supported. Finally, Windows 10 Mobile does not support Flash in order to provide a modern, touch-focused, and power-efficient experience appropriate for a mobile device. Because of this, Flash is not supported in Microsoft Edge in Continuum.
To detect RTC capabilities, use the following code:
if (RTCRtpCapabilities)
{
initRTC();
}
function initRTC()
{
var recvAudioCaps = RTCRtpReceiver.getCapabilities("audio");
var recvVideoCaps = RTCRtpReceiver.getCapabilities("video");
var sendAudioCaps = RTCRtpSender.getCapabilities("audio");
var sendVideoCaps = RTCRtpSender.getCapabilities("video");
}
Embedding a Flash movie which uses an ExternalInterface call would be the easiest way to detect Flash.
The properties of the navigator object should be able to distinguish tablet from phone. For example:
navigator.cpuClass
should return x86 for Surface devices, but other for phones.
Also, the user agent changes when casting a phone display to a TV. It goes from:
Microsoft Edge UA (Mobile)
Mozilla/5.0 (Windows Phone 10.0; Android 6.0.1; Microsoft; <Device>) AppleWebKit/<Rev (KHTML, like Gecko) Chrome/<Rev> Mobile Safari/<Rev> Edge/<Rev>
to:
Microsoft Edge UA (Continuum)
Mozilla/5.0 (Windows NT 10.0; ARM) AppleWebKit/<Rev> (KHTML, like Gecko) Chrome/<Rev> Safari/<Rev> Edge/<Rev>
compared to the desktop:
Microsoft Edge UA (Desktop)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/<Rev> (KHTML, like Gecko) Chrome/<Rev> Safari/<Rev> Edge/<Rev>
References
Microsoft Edge and Continuum: Your desktop browser on Mobile
Microsoft Edge Dev Guide: Object RTC API
ORTC Specification: dictionary RTCRtpCapabilities
Flash Player guidance for Internet Explorer 11 and Microsoft Edge
Minimum Hardware Requirements: Windows 10
Continuum for Phones FAQ
clientInformation object
Device Fingerprint Help
Security Error when trying to call ActionScript function from JS
The Windows 10 Browser Conundrum
how to tell if android user came from home screen app
Configuring Web Applications

Related

Azure AD authentication error AADSTS50005 on Linux

I'm using Chromium and FireFox browser on Linux. Out of blue my application started throwing Azure Active Directory Authentication error AADSTS50005.
Error definition AADSTS50005 states:
DevicePolicyError -User tried to log in to a device from a platform that's currently not supported through Conditional Access policy.*
The message is clear Linux platform is not supported. How to fix it?
Solution for this problem was to run Chromium in supported platform (iOS, Android, Mac or Windows) firefox Add-On
Chromium:
Execute below steps in Chromium browser.
Press F12 key.
Press Esc key.
Click Network conditions tab, and unchecked User browser default checkbox. Choose Chrome on supported by Azure AD platform e.g. Windows. Choose Chrome --Windows
FireFox:
Execute below steps in FireFox browser, or install User-Agent Switcher and Manager add-on.
Press Ctl+l, type about:config and click Accept the Risk and Continue button.
In search type general.useragent.override make sure String radio button is selected, next click Add button (plus icon).
From User Agent by OS list click OS that you want to emulate, e.g. Windows. and select agent that interests you the most. I chose Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36. Copy it, and paste it to general.useragent.override and click Save button.

Why chrome sends all agent names as part of user-agent header

Is there any reason why chrome browser (71 probably earlier version too) sends all browser names as part of its user agent parameter ?
This is what i see in the console. Is this expected, Will this affect the client information if the server wants to know/log the agent names ?
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
They all have Mozilla in beginning of their Useragent because they follow standard mozilla rendering back in 2000 era. Most browsers share some of each other rendering engines, that's why their useragent often consist of similar values.
Browsers have came a long way to reach their current state. Current user-agents have to do with a little bit of browsers history. When there was a fight between Firefox and Internet Explorer, Chrome appeared. Some websites would ask Firefox users to switch to Internet Explorer for better rendering (because their website was old and not compatible with Firefox) and some would advice Internet Explorer users to switch to Firefox for modern rendering and better performance.
There was some forks of Firefox which also used similar user agent, "Gecko/####" which say this browser is using Gecko engine.
Websites check if a browser have "Gecko" in its user agent and decide to show modern design. Chrome is using Apple WebKit engine to render HTML, but in order to avoid those websites show recommendation for Internet Explorer, added "Like Gecko" to it's useragent.
Now that Chrome is top browser, have a look at Microsoft Edge 14: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14931
As Internet Explorer reputation got very bad, Microsoft could not use any user agent string that could make websites think Edge is Internet Explorer. therefor, by putting Chrome, Safari, AppleWebKit, "Like Gecko" is satisfy websites that are looking for this strings to avoid showing a message to switch to Chrome. Microsoft is using "AppleWebKit" in it's useragent even when they are not using AppleWebKit yet. (They will start using in next versions of Edge)

iOS8 Simulator user agent

While investigating why I have a bug on iOS8 webview I discovered that WebView's User-Agent is:
Mozilla/5.0 (iPhone; CPU iPhone OS 10_9_5 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12A365 (2072607680)
Whereas since I'm running for iOS8, it rather should be:
Mozilla/5.0 (iPhone; CPU iPhone OS 8_0_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12A405kalturaNativeCordovaPlayer (350612576)
Of Course there's no iPhone running version 10.10 as yet, so Xcode6 is somehow picking up version from Mac OS X. For iOS < iOS8 simulators, it works just fine.
So do you have a solution for me how to discover if it's iOS8 simulator or not
For now this is my javascript method:
isIOS8 = function(){
return ( /OS 8_/.test( userAgent ) || /Version\/8/.test( userAgent ) ) && isIOS();
};
This issue was fixed in the iOS 8.3 Simulator Runtime. That version and newer versions do not suffer from this issue any more.
I suggest you look for the "iPhone OS" and "AppleWebKit/600.1.4" substrings if you really need to determine that you're running on iOS 8, but you should probably not be approaching the problem this way. Instead, you're probably better off making a determination based on capabilities rather than version numbers.

What is the browser engine of the Sogou browser?

Title pretty much says it all. I am developing for a client that serves a large customer base in China, so I need to make sure the site works in local Chinese browsers. I am experiencing issues with Sogou browser (which I'd never even heard about before today). In order to troubleshoot these issues in an environment I am more familiar with, I wanted to see if I could reproduce these issues in another browser which uses the same engine. If only I knew what engine that was…
Update:
As far as I've been able to find out, Sogou is a dual-engine browser. One engine is Webkit and the other supposedly is Trident, specifically the version that's in IE9. This however, does not correspond to what I am seeing, as the page is clearly rendered differently from what it is in IE9. Maybe it's IE9 in quirks mode?
I've seen a couple references to a dual Trident/Webkit engine. Apparently it can do both; Trident might be either their own build, or the most recent version included with Windows. I have IE9 installed but it's behaving like IE7, which came default on my computer. Sogou-based browsers can be detected and offered to switch to the Webkit engine, like in this code example.
From the Trident useragent string:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; InfoPath.3; Media Center PC 6.0; SE 2.X MetaSr 1.0
Now I'm just guessing this means it uses the IE7 standards mode as default when it's rendering webpages. But then again IE doesn't like reporting the same useragent all the time either...
From the Webkit useragent string (looks Sogou-branded):
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.802.30 Safari/535.1 SE 2.X MetaSr 1.0
I was able to change user agents pretty easily here. "高速" translates roughly to "high speed".
I don't know how reliable the information is, but channel9.msdn.com has a page that suggest it is (or will be?) the Webkit engine.
Chinese dual engine browsers have webkit and Trident. They use webkit by default and use Trident for compatibility mode. Apparently there were a lot of issues reguarding IE-centric websites. I think that has largely passed. For instance, Maxthon dropped the Trident engine in version 3+

webbrowser control version

I've read somewhere that the webbrowser control in MS visual studio uses the same engine as the IE installed on my pc. Despite that I found out that this is not correct. And to prove my assumption I used various online browser detecting sites. I present the results here:
(1) IE installed on my pc (both 64-bit and 32-bit):
Browser Information: .
Browser: Microsoft Internet Explorer
Browser Version: 9.0
User Agent String: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
(2) webbrowser control (C#):
Browser Information:
Browser: Microsoft Internet Explorer
Browser Version: 7.0
User Agent String: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
I began to search about it because I had compatibility problems with the webbrowser control whenever I tried to access a specific site (which works fine despite the warnings).
I used gecko 12 to simulate firefox but the site detected that I wasn't using the firefox and I got the warning message again...
So the question is: how can I "cheat" and by-pass detection so that I won't get warning messages after every click? I'm looking for a programmatic way to do so.
It seems that there is no easy way to do this with programming. It's all in the registry.
I can't understand why...
Anyway, the answer is here.
The webbrowser control uses the compatibility mode by default. Even if IE won't use the compatibility mode, the control will.
Webbrowser control uses IE installed on machine. By default it is running in IE 7 compatability mode.
To set your compatability mode you need to list your application in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION with desired compatability mode.

Resources