Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.

Commit 50a2ae0

Browse files
12wrigjacopybara-github
authored andcommitted
Client Hints: use fullVersionList in Chromium >=98.
RELNOTES[NEW]: Client Hints: use fullVersionList in Chromium >=98. PiperOrigin-RevId: 469771294 Change-Id: I4a41a9c3a715021ce0cc39de406d71b775d03420
1 parent da7658d commit 50a2ae0

3 files changed

Lines changed: 13 additions & 40 deletions

File tree

closure/goog/labs/useragent/browser.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const googAsserts = goog.require('goog.asserts');
1919
const util = goog.require('goog.labs.userAgent.util');
2020
const {AsyncValue, Version} = goog.require('goog.labs.userAgent.highEntropy.highEntropyValue');
2121
const {compareVersions} = goog.require('goog.string.internal');
22-
const {fullVersionList, hasFullVersionList} = goog.require('goog.labs.userAgent.highEntropy.highEntropyData');
22+
const {fullVersionList} = goog.require('goog.labs.userAgent.highEntropy.highEntropyData');
2323

2424
// TODO(nnaze): Refactor to remove excessive exclusion logic in matching
2525
// functions.
@@ -96,6 +96,18 @@ function useUserAgentDataBrand() {
9696
return !!userAgentData && userAgentData.brands.length > 0;
9797
}
9898

99+
/**
100+
* @return {boolean} Whether this browser is likely to have the fullVersionList
101+
* high-entropy Client Hint.
102+
*/
103+
function hasFullVersionList() {
104+
// https://chromiumdash.appspot.com/commits?commit=1eb643c3057e64ff4d22468432ad16c4cab12879&platform=Linux
105+
// indicates that for all platforms Chromium 98 shipped this feature.
106+
// See also
107+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-CH-UA-Full-Version-List#browser_compatibility
108+
return isAtLeast(Brand.CHROMIUM, 98);
109+
}
110+
99111
/**
100112
* @return {boolean} Whether the user's browser is Opera. Note: Chromium based
101113
* Opera (Opera 15+) is detected as Chrome to avoid unnecessary special

closure/goog/labs/useragent/browser_test.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ testSuite({
315315
util.setUserAgent('');
316316
util.setUserAgentData(null);
317317
highEntropyData.resetAllForTesting();
318-
highEntropyData.setHasFullVersionListForTesting(false);
319318
},
320319

321320
async testOpera10() {
@@ -990,7 +989,6 @@ testSuite({
990989
]
991990
});
992991
util.setUserAgentData(userAgentDataWithVersion);
993-
highEntropyData.setHasFullVersionListForTesting(true);
994992

995993
assertBrowser(Browser.CHROME);
996994
assertNonChromeChromiumBrowser(NonChromeChromiumBrowser.OPERA_CHROMIUM);
@@ -1028,7 +1026,6 @@ testSuite({
10281026
]
10291027
});
10301028
util.setUserAgentData(userAgentDataWithVersion);
1031-
highEntropyData.setHasFullVersionListForTesting(true);
10321029

10331030
assertBrowser(Browser.CHROME);
10341031
assertNonChromeChromiumBrowser(NonChromeChromiumBrowser.EDGE_CHROMIUM);
@@ -1100,7 +1097,6 @@ testSuite({
11001097
testAgentData.CHROME_USERAGENT_DATA_LINUX,
11011098
{fullVersionList: [{brand: 'Chromium', version: '101.0.4472.77'}]});
11021099
util.setUserAgentData(userAgentDataWithVersion);
1103-
highEntropyData.setHasFullVersionListForTesting(true);
11041100

11051101
assertBrowser(Browser.CHROME);
11061102
assertTrue(userAgentBrowser.isChrome());
@@ -1151,7 +1147,6 @@ testSuite({
11511147

11521148
async testChromeUserAgentDataWithRejectedHighEntropyValues() {
11531149
util.setUserAgentData(testAgentData.CHROME_USERAGENT_DATA_LINUX);
1154-
highEntropyData.setHasFullVersionListForTesting(true);
11551150

11561151
const fullChromeVersion =
11571152
userAgentBrowser.fullVersionOf(userAgentBrowser.Brand.CHROMIUM);
@@ -1173,7 +1168,6 @@ testSuite({
11731168
testAgentData.CHROME_USERAGENT_DATA_LINUX,
11741169
{fullVersionList: [{brand: 'Chromium', version: '101.0.4472.77'}]});
11751170
util.setUserAgentData(userAgentDataWithVersion);
1176-
highEntropyData.setHasFullVersionListForTesting(true);
11771171

11781172
const fullChromeVersion =
11791173
userAgentBrowser.fullVersionOf(userAgentBrowser.Brand.CHROMIUM);

closure/goog/labs/useragent/highentropy/highentropydata.js

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,6 @@ goog.module('goog.labs.userAgent.highEntropy.highEntropyData');
1212

1313
const {HighEntropyValue} = goog.require('goog.labs.userAgent.highEntropy.highEntropyValue');
1414

15-
/**
16-
* fullVersionList is currently not implemented in Chromium.
17-
* TODO(user): When fullVersionList is added, remove this value.
18-
*/
19-
let fullVersionListAvailable = false;
20-
21-
/**
22-
* A helper function to check whether fullVersionList is available in the
23-
* current browser.
24-
* TODO(user): When fullVersionList is added, move hasFullVersionList()
25-
* to browser.js, and inline the browser version check. For example, if it is
26-
* implemented in Chromium 101, have hasFullVersionList simply return
27-
* `browser.isAtLeast(browser.Brand.CHROMIUM, 101)`.
28-
* @return {boolean}
29-
*/
30-
function hasFullVersionList() {
31-
return fullVersionListAvailable;
32-
}
33-
exports.hasFullVersionList = hasFullVersionList;
34-
35-
/**
36-
* A test-only function to set whether it should be assumed fullVersionList is
37-
* available in the browser.
38-
* TODO(user): When fullVersionList is added, remove this function, as
39-
* behavior when fullVersionList is either present or absent would be testable
40-
* by setting the user agent and user agent data accordingly.
41-
* @param {boolean} value
42-
*/
43-
function setHasFullVersionListForTesting(value) {
44-
fullVersionListAvailable = value;
45-
}
46-
exports.setHasFullVersionListForTesting = setHasFullVersionListForTesting;
47-
4815
/**
4916
* @type {!HighEntropyValue<!Array<!NavigatorUABrandVersion>>}
5017
*/

0 commit comments

Comments
 (0)