Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Issue 2300403003: DevTools: patch browser's Chrome version into Chrome user agents for emulation (Closed)

Created:
4 years, 3 months ago by luoe
Modified:
4 years, 3 months ago
Reviewers:
lushnikov, allada, pfeldman
CC:
chenwilliam, chromium-reviews, caseq+blink_chromium.org, lushnikov+blink_chromium.org, pfeldman+blink_chromium.org, apavlov+blink_chromium.org, devtools-reviews_chromium.org, blink-reviews, kozyatinskiy+blink_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

DevTools: patch browser's Chrome version into Chrome user agents for emulation User agents are defined by hard coded strings for emulation mode in DevTools. This CL patches all preset user agents in emulated_devices that include "Chrome/" and those in the "Chrome" section in the network conditions drawer to the version read from the browser's navigator.userAgent. BUG=460059 Committed: https://crrev.com/999f86be50685adb30c783cdf30e97f8044234a3 Cr-Commit-Position: refs/heads/master@{#419834}

Patch Set 1 #

Total comments: 4

Patch Set 2 : use sprintf, default chrome version for fallback #

Total comments: 4

Patch Set 3 : tests, escape, nullcheck #

Total comments: 5

Patch Set 4 : regex nit #

Patch Set 5 : Bake version at build time #

Patch Set 6 : Removed old stuff #

Total comments: 8

Patch Set 7 : address comments #

Total comments: 2

Patch Set 8 : reorder imports #

Patch Set 9 : address comments #

Patch Set 10 : rebase for nav.ua method #

Patch Set 11 : Simpler navigator.userAgent method #

Total comments: 14

Patch Set 12 : address comments #

Total comments: 8

Patch Set 13 : common > sdk, address comments #

Total comments: 1

Patch Set 14 : revert to sprintf %s #

Patch Set 15 : update test #

Patch Set 16 : renames #

Messages

Total messages: 49 (19 generated)
luoe
allada@: regex review lushnikov@: general review
4 years, 3 months ago (2016-09-02 17:46:20 UTC) #3
allada
The regex looks good though. https://codereview.chromium.org/2300403003/diff/1/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js File third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js (right): https://codereview.chromium.org/2300403003/diff/1/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js#newcode18 third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js:18: return uaString.replace(sectionRegex, "$1" + ...
4 years, 3 months ago (2016-09-02 18:16:26 UTC) #5
luoe
https://codereview.chromium.org/2300403003/diff/1/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js File third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js (right): https://codereview.chromium.org/2300403003/diff/1/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js#newcode18 third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js:18: return uaString.replace(sectionRegex, "$1" + currentVersion); Okay, it now uses ...
4 years, 3 months ago (2016-09-02 20:43:10 UTC) #6
allada
https://codereview.chromium.org/2300403003/diff/20001/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js File third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js (right): https://codereview.chromium.org/2300403003/diff/20001/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js#newcode16 third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js:16: if (!currentVersion || uaString.indexOf("%s") === -1) Can we add ...
4 years, 3 months ago (2016-09-02 21:08:05 UTC) #7
luoe
https://codereview.chromium.org/2300403003/diff/20001/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js File third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js (right): https://codereview.chromium.org/2300403003/diff/20001/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js#newcode16 third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js:16: if (!currentVersion || uaString.indexOf("%s") === -1) On 2016/09/02 21:08:05, ...
4 years, 3 months ago (2016-09-02 23:08:09 UTC) #8
dgozman
https://codereview.chromium.org/2300403003/diff/40001/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js File third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js (right): https://codereview.chromium.org/2300403003/diff/40001/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js#newcode29 third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js:29: // e.g. _getVersion("Chrome") === "1.2.3.4" when user agent is: ...
4 years, 3 months ago (2016-09-02 23:42:45 UTC) #10
allada
I think the regex is fine lgtm. https://codereview.chromium.org/2300403003/diff/40001/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js File third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js (right): https://codereview.chromium.org/2300403003/diff/40001/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js#newcode33 third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js:33: var sectionRegex ...
4 years, 3 months ago (2016-09-02 23:48:29 UTC) #11
luoe
https://codereview.chromium.org/2300403003/diff/40001/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js File third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js (right): https://codereview.chromium.org/2300403003/diff/40001/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js#newcode29 third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js:29: // e.g. _getVersion("Chrome") === "1.2.3.4" when user agent is: ...
4 years, 3 months ago (2016-09-03 00:08:15 UTC) #12
dgozman
https://codereview.chromium.org/2300403003/diff/40001/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js File third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js (right): https://codereview.chromium.org/2300403003/diff/40001/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js#newcode29 third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js:29: // e.g. _getVersion("Chrome") === "1.2.3.4" when user agent is: ...
4 years, 3 months ago (2016-09-03 01:17:42 UTC) #13
luoe
Redone at build time. CurrentBrowserVersion.js is the template that gets the substituted version numbers. BrowserVersionInfo.js ...
4 years, 3 months ago (2016-09-07 19:49:49 UTC) #14
dgozman
https://codereview.chromium.org/2300403003/diff/100001/third_party/WebKit/Source/devtools/BUILD.gn File third_party/WebKit/Source/devtools/BUILD.gn (right): https://codereview.chromium.org/2300403003/diff/100001/third_party/WebKit/Source/devtools/BUILD.gn#newcode7 third_party/WebKit/Source/devtools/BUILD.gn:7: import("//chrome/version.gni") This looks like a layering violation. Ain't any ...
4 years, 3 months ago (2016-09-07 22:06:28 UTC) #15
luoe
https://codereview.chromium.org/2300403003/diff/100001/third_party/WebKit/Source/devtools/BUILD.gn File third_party/WebKit/Source/devtools/BUILD.gn (right): https://codereview.chromium.org/2300403003/diff/100001/third_party/WebKit/Source/devtools/BUILD.gn#newcode7 third_party/WebKit/Source/devtools/BUILD.gn:7: import("//chrome/version.gni") On 2016/09/07 22:06:28, dgozman wrote: > This looks ...
4 years, 3 months ago (2016-09-07 22:46:32 UTC) #16
luoe
gentle ping
4 years, 3 months ago (2016-09-12 18:04:31 UTC) #17
luoe
brettw@: I want to let DevTools know about the Chrome version at build time by ...
4 years, 3 months ago (2016-09-12 18:22:58 UTC) #19
brettw
On 2016/09/12 18:22:58, luoe wrote: > brettw@: I want to let DevTools know about the ...
4 years, 3 months ago (2016-09-13 22:43:29 UTC) #20
brettw
https://codereview.chromium.org/2300403003/diff/120001/third_party/WebKit/Source/devtools/BUILD.gn File third_party/WebKit/Source/devtools/BUILD.gn (right): https://codereview.chromium.org/2300403003/diff/120001/third_party/WebKit/Source/devtools/BUILD.gn#newcode7 third_party/WebKit/Source/devtools/BUILD.gn:7: import("//chrome/version.gni") These should be sorted like we do in ...
4 years, 3 months ago (2016-09-13 22:43:47 UTC) #21
pfeldman
I'd take a shot at a one line fix :-)
4 years, 3 months ago (2016-09-14 00:53:48 UTC) #24
pfeldman
it is easy to show that regex-based solution is at least as reliable: if it ...
4 years, 3 months ago (2016-09-14 01:04:51 UTC) #25
luoe
@dgozman, @pfeldman: I rewrote BrowserVersionInfo.js to be simpler, PTAL. https://codereview.chromium.org/2300403003/diff/200001/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js https://codereview.chromium.org/2300403003/diff/120001/third_party/WebKit/Source/devtools/BUILD.gn File third_party/WebKit/Source/devtools/BUILD.gn (right): https://codereview.chromium.org/2300403003/diff/120001/third_party/WebKit/Source/devtools/BUILD.gn#newcode7 ...
4 years, 3 months ago (2016-09-14 21:16:05 UTC) #28
pfeldman
Let us shrink it further to a few lines. https://codereview.chromium.org/2300403003/diff/200001/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js File third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js (right): https://codereview.chromium.org/2300403003/diff/200001/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js#newcode5 third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js:5: ...
4 years, 3 months ago (2016-09-14 21:47:10 UTC) #30
luoe
Thanks for the review. Instead of marking locations with '%s', it now calls replace twice, ...
4 years, 3 months ago (2016-09-14 22:49:13 UTC) #31
luoe
Updated reviewer list.
4 years, 3 months ago (2016-09-15 21:06:19 UTC) #33
pfeldman
https://codereview.chromium.org/2300403003/diff/200001/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js File third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js (right): https://codereview.chromium.org/2300403003/diff/200001/third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js#newcode5 third_party/WebKit/Source/devtools/front_end/common/BrowserVersionInfo.js:5: WebInspector.BrowserVersionInfo = { "sdk" would be the common denominator ...
4 years, 3 months ago (2016-09-15 21:44:07 UTC) #34
luoe
I spoke with Blaise offline about explicitly marking '%s'. If it's important to be able ...
4 years, 3 months ago (2016-09-15 23:18:09 UTC) #35
pfeldman
https://codereview.chromium.org/2300403003/diff/240001/third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js File third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js (right): https://codereview.chromium.org/2300403003/diff/240001/third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js#newcode709 third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js:709: var chromeRegex = new RegExp("((?:^|\\W)Chrome/)(\\S+)"); So you want Opera ...
4 years, 3 months ago (2016-09-19 23:42:47 UTC) #36
luoe
After an offline discussion, returned to the explicit '%s' method of marking places that need ...
4 years, 3 months ago (2016-09-20 01:31:13 UTC) #37
pfeldman
lgtm
4 years, 3 months ago (2016-09-20 02:05:35 UTC) #38
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2300403003/300001
4 years, 3 months ago (2016-09-20 18:54:28 UTC) #45
commit-bot: I haz the power
Committed patchset #16 (id:300001)
4 years, 3 months ago (2016-09-20 19:04:05 UTC) #47
commit-bot: I haz the power
4 years, 3 months ago (2016-09-20 19:07:29 UTC) #49
Message was sent while issue was closed.
Patchset 16 (id:??) landed as
https://crrev.com/999f86be50685adb30c783cdf30e97f8044234a3
Cr-Commit-Position: refs/heads/master@{#419834}

Powered by Google App Engine
This is Rietveld 408576698