Merge remote-tracking branch 'origin/develop' into 219138ca4e-develop-into-10.0-release

This commit is contained in:
Zach Bloomquist
2022-02-02 15:08:51 -05:00
5 changed files with 59 additions and 22 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
{
"chrome:beta": "98.0.4758.74",
"chrome:stable": "97.0.4692.99"
"chrome:beta": "98.0.4758.80",
"chrome:stable": "98.0.4758.80"
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "cypress",
"version": "9.3.1",
"version": "9.4.1",
"description": "Cypress.io end to end testing tool",
"private": true,
"scripts": {
@@ -185,6 +185,18 @@ describe('src/cy/commands/actions/selectFile', () => {
})
})
it('uses the AUT\'s File constructor', () => {
cy.window().then(($autWindow) => {
cy.get('#basic').selectFile('@foo', { action: 'select' }).then((input) => {
expect(input[0].files[0]).to.be.instanceOf($autWindow.File)
})
cy.get('#basic').selectFile('@foo', { action: 'drag-drop' }).then((input) => {
expect(input[0].files[0]).to.be.instanceOf($autWindow.File)
})
})
})
describe('shorthands', () => {
const validJsonString = `{
"foo": 1,
@@ -35,8 +35,10 @@ const tryMockWebkit = (item) => {
return item
}
const createDataTransfer = (files: Cypress.FileReferenceObject[]): DataTransfer => {
const dataTransfer = new DataTransfer()
const createDataTransfer = (files: Cypress.FileReferenceObject[], eventTarget: JQuery<any>): DataTransfer => {
// obtain a reference to the `targetWindow` so we can use the right instances of the `File` and `DataTransfer` classes
const targetWindow = (eventTarget[0] as HTMLElement).ownerDocument.defaultView || window
const dataTransfer = new targetWindow.DataTransfer()
files.forEach(({
contents,
@@ -44,7 +46,7 @@ const createDataTransfer = (files: Cypress.FileReferenceObject[]): DataTransfer
mimeType = mime.lookup(fileName) || '',
lastModified = Date.now(),
}) => {
const file = new File([contents], fileName, { lastModified, type: mimeType })
const file = new targetWindow.File([contents], fileName, { lastModified, type: mimeType })
dataTransfer.items.add(file)
})
@@ -302,7 +304,7 @@ export default (Commands, Cypress, cy, state, config) => {
})
}
const dataTransfer = createDataTransfer(filesArray)
const dataTransfer = createDataTransfer(filesArray, eventTarget)
ACTIONS[options.action as string](eventTarget.get(0), dataTransfer, coords, state)
+38 -15
View File
@@ -275,30 +275,53 @@ export function start (name, options: StartOptions = {}) {
type OnProgress = (p: number) => void
export async function process (name, cname, videoCompression, ffmpegchaptersConfig, onProgress: OnProgress = function () {}) {
const metaFileName = `${name}.meta`
const maybeGenerateMetaFile = Bluebird.method(() => {
if (!ffmpegchaptersConfig) {
return false
}
// Writing the metadata to filesystem is necessary because fluent-ffmpeg is just a wrapper of ffmpeg command.
return fs.writeFile(metaFileName, ffmpegchaptersConfig).then(() => true)
})
const addChaptersMeta = await maybeGenerateMetaFile()
let total = null
const metaFileName = `${name}.meta`
const addChaptersMeta = ffmpegchaptersConfig && await fs.writeFile(metaFileName, ffmpegchaptersConfig).then(() => true)
return new Bluebird((resolve, reject) => {
debug('processing video from %s to %s video compression %o',
name, cname, videoCompression)
const command = ffmpeg()
.addOptions([
// These flags all serve to reduce initial buffering, especially important
// when dealing with very short videos (such as during component tests).
// See https://ffmpeg.org/ffmpeg-formats.html#Format-Options for details.
'-avioflags direct',
// Because we're passing in a slideshow of still frames, there's no
// fps metadata to be found in the video stream. This ensures that ffmpeg
// isn't buffering a lot of data waiting for information that's not coming.
'-fpsprobesize 0',
// Tells ffmpeg to read only the first 32 bytes of the stream for information
// (resolution, stream format, etc).
// Some videos can have long metadata (eg, lots of chapters) or spread out,
// but our streams are always predictable; No need to wait / buffer data before
// starting encoding
'-probesize 32',
// By default ffmpeg buffers the first 5 seconds of video to analyze it before
// it starts encoding. We're basically telling it "there is no metadata coming,
// start encoding as soon as we give you frames."
'-analyzeduration 0',
])
// See https://trac.ffmpeg.org/wiki/Encode/H.264 for details about h264 options.
const outputOptions = [
// Preset is a tradeoff between encoding speed and filesize. It does not determine video
// quality; It's just a tradeoff between CPU vs size.
'-preset fast',
`-crf ${videoCompression}`,
'-pix_fmt yuv420p',
// Compression Rate Factor is essentially the quality dial; 0 would be lossless
// (big files), while 51 (the maximum) would lead to low quality (and small files).
`-crf ${videoCompression}`,
// Discussion of pixel formats is beyond the scope of these comments. See
// https://en.wikipedia.org/wiki/Chroma_subsampling if you want the gritty details.
// Short version: yuv420p is a standard video format supported everywhere.
'-pix_fmt yuv420p',
]
if (addChaptersMeta) {