feat: use up2date Chromium user-agents for device descriptors (#6594)
This commit is contained in:
parent
1e6f899c82
commit
9592486225
|
|
@ -39,3 +39,5 @@ lib/**/injected/
|
|||
!browsers.json
|
||||
# Include commit info
|
||||
!commitinfo
|
||||
# Include generated devices descriptors
|
||||
!deviceDescriptorsSource.json
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
1144
src/server/deviceDescriptorsSource.json
Normal file
1144
src/server/deviceDescriptorsSource.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -50,14 +50,14 @@ test('should print the correct context options when using a device', async ({ br
|
|||
test.skip(browserName !== 'chromium');
|
||||
|
||||
const cli = runCLI(['--device=Pixel 2', '--target=java', emptyHTML]);
|
||||
await cli.waitFor(`setHasTouch(true));`);
|
||||
const expectedResult = `BrowserContext context = browser.newContext(new Browser.NewContextOptions()
|
||||
.setUserAgent("Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3765.0 Mobile Safari/537.36")
|
||||
.setUserAgent("Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/XXXX Mobile Safari/537.36")
|
||||
.setViewportSize(411, 731)
|
||||
.setDeviceScaleFactor(2.625)
|
||||
.setIsMobile(true)
|
||||
.setHasTouch(true));`;
|
||||
await cli.waitFor(expectedResult);
|
||||
expect(cli.text()).toContain(expectedResult);
|
||||
expect(cli.text().replace(/(.*Chrome\/)(.*?)( .*)/m, '$1XXXX$3')).toContain(expectedResult);
|
||||
});
|
||||
|
||||
test('should print the correct context options when using a device and additional options', async ({ browserName, runCLI }) => {
|
||||
|
|
|
|||
|
|
@ -12,8 +12,9 @@
|
|||
"declaration": false,
|
||||
"jsx": "react",
|
||||
"downlevelIteration": true,
|
||||
"resolveJsonModule": true,
|
||||
},
|
||||
"compileOnSave": true,
|
||||
"include": ["src/**/*.ts", "src/**/*.js"],
|
||||
"include": ["src/**/*.ts", "src/**/*.js", "src/server/deviceDescriptorsSource.json"],
|
||||
"exclude": ["node_modules", "src/.eslintrc.js", "src/web/**", "src/**/*webpack.config.js"]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ async function run() {
|
|||
documentation.filterForLanguage('js');
|
||||
|
||||
// Patch README.md
|
||||
const versions = await getBrowserVersions();
|
||||
{
|
||||
const versions = await getBrowserVersions();
|
||||
const params = new Map();
|
||||
const { chromium, firefox, webkit } = versions;
|
||||
params.set('chromium-version', chromium);
|
||||
|
|
@ -65,6 +65,20 @@ async function run() {
|
|||
writeAssumeNoop(path.join(PROJECT_DIR, 'README.md'), content, dirtyFiles);
|
||||
}
|
||||
|
||||
// Update device descriptors
|
||||
{
|
||||
const devicesDescriptorsSourceFile = path.join(PROJECT_DIR, 'src', 'server', 'deviceDescriptorsSource.json')
|
||||
const devicesDescriptors = require(devicesDescriptorsSourceFile)
|
||||
for (const deviceName of Object.keys(devicesDescriptors))
|
||||
if (devicesDescriptors[deviceName].defaultBrowserType === 'chromium') {
|
||||
devicesDescriptors[deviceName].userAgent = devicesDescriptors[deviceName].userAgent.replace(
|
||||
/(.*Chrome\/)(.*?)( .*)/,
|
||||
`$1${versions.chromium}$3`
|
||||
)
|
||||
}
|
||||
writeAssumeNoop(devicesDescriptorsSourceFile, JSON.stringify(devicesDescriptors, null, 2), dirtyFiles);
|
||||
}
|
||||
|
||||
// Validate links
|
||||
{
|
||||
for (const file of fs.readdirSync(path.join(PROJECT_DIR, 'docs', 'src'))) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue