|
|
@ -77,16 +77,17 @@ tests.push(async ({ page, eq, bodyBgRgb, random }) => { |
|
|
|
tests.push(async ({ page, eq, bodyBgRgb, random }) => { |
|
|
|
tests.push(async ({ page, eq, bodyBgRgb, random }) => { |
|
|
|
// check that the hsl value is copied in the clipboard on click
|
|
|
|
// check that the hsl value is copied in the clipboard on click
|
|
|
|
for (const move of generateCoords(random)) { |
|
|
|
for (const move of generateCoords(random)) { |
|
|
|
await page.mouse.click(...move) |
|
|
|
await page.evaluate(() => { |
|
|
|
const clipboard = await page.evaluate(() => { |
|
|
|
|
|
|
|
// mock clipboard
|
|
|
|
|
|
|
|
let clipboardText = null |
|
|
|
let clipboardText = null |
|
|
|
window["navigator"]["clipboard"] = { |
|
|
|
window.navigator.clipboard.readText = () => |
|
|
|
writeText: (text) => new Promise((resolve) => (clipboardText = text)), |
|
|
|
new Promise((resolve) => resolve(clipboardText)) |
|
|
|
readText: () => new Promise((resolve) => resolve(clipboardText)), |
|
|
|
window.navigator.clipboard.writeText = (text) => |
|
|
|
} |
|
|
|
new Promise(() => (clipboardText = text)) |
|
|
|
return navigator.clipboard.readText() |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
await page.mouse.click(...move) |
|
|
|
|
|
|
|
const clipboard = await page.evaluate(() => |
|
|
|
|
|
|
|
window.navigator.clipboard.readText() |
|
|
|
|
|
|
|
) |
|
|
|
const hslValue = await page.$eval(".hsl", (hsl) => hsl.textContent) |
|
|
|
const hslValue = await page.$eval(".hsl", (hsl) => hsl.textContent) |
|
|
|
eq(hslValue, clipboard) |
|
|
|
eq(hslValue, clipboard) |
|
|
|
} |
|
|
|
} |
|
|
|