Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/goto/test/unit/evasions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ test('media codecs are present', async t => {
}
})

t.deepEqual(await videoCodecs(), { ogg: 'probably', h264: 'probably', webm: 'probably' })
t.deepEqual(await videoCodecs(), { ogg: '', h264: 'probably', webm: 'probably' })

t.deepEqual(await audioCodecs(), {
ogg: 'probably',
Expand Down
8 changes: 6 additions & 2 deletions packages/screenshot/src/is-white-screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ module.exports = async buffer => {
const height = image.getHeight()
const width = image.getWidth()

for (let i = 0; i < height; i++) {
for (let j = 0; j < width; j++) {
const samplePercentage = 0.25 // Sample 25% of the image
const sampleSize = Math.floor(width * height * samplePercentage) // Calculate sample size based on percentage
const stepSize = Math.max(1, Math.floor((width * height) / sampleSize)) // Calculate step size based on sample size

for (let i = 0; i < height; i += stepSize) {
for (let j = 0; j < width; j += stepSize) {
if (firstPixel !== image.getPixelColor(j, i)) return false
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/screenshot/test/fixtures/white-5k.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/screenshot/test/fixtures/white-5k.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions packages/screenshot/test/is-white-screenshot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict'

const test = require('ava')
const { readFile } = require('fs/promises')

const isWhite = require('../src/is-white-screenshot')

test('true', async t => {
t.true(await isWhite(await readFile('./test/fixtures/white-5k.jpg')))
t.true(await isWhite(await readFile('./test/fixtures/white-5k.png')))
})

test('false', async t => {
t.false(await isWhite(await readFile('./test/fixtures/no-white-5k.jpg')))
t.false(await isWhite(await readFile('./test/fixtures/no-white-5k.png')))
})