Commit 7a0ed6f9 authored by Mike Jackson's avatar Mike Jackson Committed by Commit Bot

DevTools: Update Microsoft Edge User Agents

Update the list of devices for Microsoft Edge. This includes:

 - Adding Microsoft Edge for all supported platforms
 - Clarified which ones are based upon EdgeHTML vs Chromium
 - Ensured that appVersion and Chromium version are patched similar to Chrome.

Change-Id: I59c5287799c6e9bd6950c76323a867c012951323
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1709693Reviewed-by: default avatarJoel Einbinder <einbinder@chromium.org>
Commit-Queue: Mike Jackson <mjackson@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#685388}
parent 3c1f7d52
......@@ -223,26 +223,6 @@ Network.NetworkConfigView._userAgentGroups = [
}
]
},
{
title: 'Edge',
values: [
{
title: 'Edge \u2014 Windows',
value:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240'
},
{
title: 'Edge \u2014 Mobile',
value:
'Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 640 XL LTE) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Mobile Safari/537.36 Edge/12.10166'
},
{
title: 'Edge \u2014 XBox',
value:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; Xbox; Xbox One) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/13.10586'
}
]
},
{
title: 'Firefox',
values: [
......@@ -294,6 +274,51 @@ Network.NetworkConfigView._userAgentGroups = [
{title: 'Internet Explorer 7', value: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'}
]
},
{
title: 'Microsoft Edge',
values: [
{
title: 'Microsoft Edge (Chromium) \u2014 Windows',
value:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36 Edg/%s'
},
{
title: 'Microsoft Edge (Chromium) \u2014 Mac',
value:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36 Edg/%s'
},
{
title: 'Microsoft Edge \u2014 iPhone',
value:
'Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 EdgiOS/44.5.0.10 Mobile/15E148 Safari/604.1'
},
{
title: 'Microsoft Edge \u2014 iPad',
value:
'Mozilla/5.0 (iPad; CPU OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 EdgiOS/44.5.2 Mobile/15E148 Safari/605.1.15'
},
{
title: 'Microsoft Edge \u2014 Android Mobile',
value:
'Mozilla/5.0 (Linux; Android 8.1.0; Pixel Build/OPM4.171019.021.D1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.109 Mobile Safari/537.36 EdgA/42.0.0.2057'
},
{
title: 'Microsoft Edge \u2014 Android Tablet',
value:
'Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.109 Safari/537.36 EdgA/42.0.0.2057'
},
{
title: 'Microsoft Edge (EdgeHTML) \u2014 Windows',
value:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362'
},
{
title: 'Microsoft Edge (EdgeHTML) \u2014 XBox',
value:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; Xbox; Xbox One) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362'
}
]
},
{
title: 'Opera',
values: [
......
......@@ -952,10 +952,15 @@ SDK.MultitargetNetworkManager = class extends Common.Object {
*/
static patchUserAgentWithChromeVersion(uaString) {
// Patches Chrome/CriOS version from user agent ("1.2.3.4" when user agent is: "Chrome/1.2.3.4").
// Edge also contains an appVersion which should be patched to match the Chrome major version.
// Otherwise, ignore it. This assumes additional appVersions appear after the Chrome version.
const chromeRegex = new RegExp('(?:^|\\W)Chrome/(\\S+)');
const chromeMatch = navigator.userAgent.match(chromeRegex);
if (chromeMatch && chromeMatch.length > 1)
return String.sprintf(uaString, chromeMatch[1]);
if (chromeMatch && chromeMatch.length > 1) {
// "1.2.3.4" becomes "1.0.100.0"
const additionalAppVersion = chromeMatch[1].split('.', 1)[0] + '.0.100.0';
return String.sprintf(uaString, chromeMatch[1], additionalAppVersion);
}
return uaString;
}
......
......@@ -3,6 +3,7 @@ Test user agent setting
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.77.34.5 Safari/537.36
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0
GoogleChrome/99.77.34.5 Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Safari/537.36
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.77.34.5 Safari/537.36 Edg/99.0.100.0
Manually setting custom user agent
foobar with %s inside
......
Test user agent setting
Detected Chrome user agent version: 99.77.34.5
Generated app version: 99.0.100.0
Android (4.0.2) Browser — Galaxy Nexus: PASSED
Android (2.3) Browser — Nexus S: PASSED
BlackBerry — BB10: PASSED
BlackBerry — PlayBook 2.1: PASSED
BlackBerry — 9900: PASSED
Chrome — Android Mobile: PASSED
Chrome — Android Tablet: PASSED
Chrome — iPhone: PASSED
Chrome — iPad: PASSED
Chrome — Chrome OS: PASSED
Chrome — Mac: PASSED
Chrome — Windows: PASSED
Firefox — Android Mobile: PASSED
Firefox — Android Tablet: PASSED
Firefox — iPhone: PASSED
Firefox — iPad: PASSED
Firefox — Mac: PASSED
Firefox — Windows: PASSED
Googlebot: PASSED
Googlebot Smartphone: PASSED
Internet Explorer 11: PASSED
Internet Explorer 10: PASSED
Internet Explorer 9: PASSED
Internet Explorer 8: PASSED
Internet Explorer 7: PASSED
Microsoft Edge (Chromium) — Windows: PASSED
Microsoft Edge (Chromium) — Mac: PASSED
Microsoft Edge — iPhone: PASSED
Microsoft Edge — iPad: PASSED
Microsoft Edge — Android Mobile: PASSED
Microsoft Edge — Android Tablet: PASSED
Microsoft Edge (EdgeHTML) — Windows: PASSED
Microsoft Edge (EdgeHTML) — XBox: PASSED
Opera — Mac: PASSED
Opera — Windows: PASSED
Opera (Presto) — Mac: PASSED
Opera (Presto) — Windows: PASSED
Opera Mobile — Android Mobile: PASSED
Opera Mini — iOS: PASSED
Safari — iPad iOS 9: PASSED
Safari — iPhone iOS 9: PASSED
Safari — Mac: PASSED
UC Browser — Android Mobile: PASSED
UC Browser — iOS: PASSED
UC Browser — Windows Phone: PASSED
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function() {
TestRunner.addResult(`Test user agent setting\n`);
await TestRunner.loadModule('network_test_runner');
await TestRunner.showPanel('network');
const chromeRegex = new RegExp('(?:^|\\W)Chrome/(\\S+)');
const chromeUserAgentVersion = navigator.userAgent.match(chromeRegex)[1];
const additionalAppVersion = chromeUserAgentVersion.split('.', 1)[0] + '.0.100.0';
TestRunner.addResult('Detected Chrome user agent version: ' + chromeUserAgentVersion);
TestRunner.addResult('Generated app version: ' + additionalAppVersion);
for (const userAgentDescriptor of Network.NetworkConfigView._userAgentGroups) {
for (const userAgentVersion of userAgentDescriptor.values) {
function failTest(reason) {
TestRunner.addResult(userAgentVersion.title + ': FAILED TEST because ' + reason);
TestRunner.addResult('=== DO NOT COMMIT THIS INTO -expected.txt ===');
TestRunner.completeTest();
}
// Split the original user agent string by %s
// If the returned array has length === 1, then no subsitutions will occur
// If the returned array has length === 2, then Chrome user agent version is substituted
// If the returned array has length === 3, then validate Chrome user agent version, and
// the generated app version are subsituted (in that order)
// Otherwise fail the test
const splitUserAgentVersion = userAgentVersion.value.split('%s');
if (splitUserAgentVersion.length > 3)
failTest('Too many %s in user agent string.');
let testPatchedUserAgentVersion = splitUserAgentVersion[0];
if (splitUserAgentVersion.length >= 2) {
// The first split user agent must end with either Chrome/ or CriOS/
if (!(testPatchedUserAgentVersion.endsWith('Chrome/') || testPatchedUserAgentVersion.endsWith('CriOS/')))
failTest('First %s match was not prefixed with either Chrome/ or CriOS/');
testPatchedUserAgentVersion += chromeUserAgentVersion + splitUserAgentVersion[1];
}
if (splitUserAgentVersion.length === 3)
testPatchedUserAgentVersion += additionalAppVersion + splitUserAgentVersion[2];
const patchedUserAgentVersion = SDK.MultitargetNetworkManager.patchUserAgentWithChromeVersion(userAgentVersion.value);
if (patchedUserAgentVersion !== testPatchedUserAgentVersion)
failTest('Computed user agent strings are not equal.');
else
TestRunner.addResult(userAgentVersion.title + ': PASSED');
}
}
TestRunner.completeTest();
})();
......@@ -10,6 +10,7 @@
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36',
'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0',
'GoogleChrome/%s Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Safari/537.36',
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36 Edg/%s',
];
for (var i = 0; i < cases.length; i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment