-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure that chromium based browsers do not send out a lot of fon…
…t requests when global styles change (#28217)
- Loading branch information
1 parent
8c4a106
commit 5dbebe6
Showing
17 changed files
with
286 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
system-tests/lib/protocol-stubs/protocolStubFontFlooding.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import path from 'path' | ||
import fs from 'fs-extra' | ||
import type { AppCaptureProtocolInterface, ResponseEndedWithEmptyBodyOptions, ResponseStreamOptions, ResponseStreamTimedOutOptions } from '@packages/types' | ||
import type { Readable } from 'stream' | ||
|
||
const getFilePath = (filename) => { | ||
return path.join( | ||
path.resolve(__dirname), | ||
'cypress', | ||
'system-tests-protocol-dbs', | ||
`${filename}.json`, | ||
) | ||
} | ||
|
||
export class AppCaptureProtocol implements AppCaptureProtocolInterface { | ||
private filename: string | ||
private events = { | ||
numberOfFontRequests: 0, | ||
} | ||
private cdpClient: any | ||
|
||
getDbMetadata (): { offset: number, size: number } { | ||
return { | ||
offset: 0, | ||
size: 0, | ||
} | ||
} | ||
|
||
responseStreamReceived (options: ResponseStreamOptions): Readable { | ||
return options.responseStream | ||
} | ||
|
||
connectToBrowser = async (cdpClient) => { | ||
if (cdpClient) { | ||
this.cdpClient = cdpClient | ||
} | ||
|
||
this.cdpClient.on('Network.requestWillBeSent', (params) => { | ||
// For the font flooding test, we want to count the number of font requests. | ||
// There should only be 2 requests. One for each test in the spec. | ||
if (params.type === 'Font') { | ||
this.events.numberOfFontRequests += 1 | ||
} | ||
}) | ||
} | ||
|
||
addRunnables = (runnables) => { | ||
return Promise.resolve() | ||
} | ||
|
||
beforeSpec = ({ archivePath, db }) => { | ||
this.filename = getFilePath(path.basename(db.name)) | ||
|
||
if (!fs.existsSync(archivePath)) { | ||
// If a dummy file hasn't been created by the test, write a tar file so that it can be fake uploaded | ||
fs.writeFileSync(archivePath, '') | ||
} | ||
} | ||
|
||
async afterSpec (): Promise<void> { | ||
try { | ||
fs.outputFileSync(this.filename, JSON.stringify(this.events, null, 2)) | ||
} catch (e) { | ||
console.log('error writing protocol events', e) | ||
} | ||
} | ||
|
||
beforeTest = (test) => { | ||
return Promise.resolve() | ||
} | ||
|
||
commandLogAdded = (log) => { | ||
} | ||
|
||
commandLogChanged = (log) => { | ||
} | ||
|
||
viewportChanged = (input) => { | ||
} | ||
|
||
urlChanged = (input) => { | ||
} | ||
|
||
pageLoading = (input) => { | ||
} | ||
|
||
preAfterTest = (test, options) => { | ||
return Promise.resolve() | ||
} | ||
|
||
afterTest = (test) => { | ||
return Promise.resolve() | ||
} | ||
|
||
responseEndedWithEmptyBody = (options: ResponseEndedWithEmptyBodyOptions) => { | ||
} | ||
|
||
responseStreamTimedOut (options: ResponseStreamTimedOutOptions): void { | ||
} | ||
|
||
resetTest (testId: string): void { | ||
} | ||
} |
Oops, something went wrong.
5dbebe6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
5dbebe6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
5dbebe6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
5dbebe6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
5dbebe6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
win32 x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally: