Created
July 1, 2019 20:19
-
-
Save juliandescottes/1b3e52ade0efd9f6cf80a8e5c3c4ac62 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Content page script | |
window.value = "init-value"; | |
document.querySelector("input").addEventListener("input", () => { | |
// Slow down the handler a bit | |
for (var i = 0 ; i < 1000; i++) { | |
console.log(i); | |
} | |
// Update the value that will be checked by the test | |
window.value = document.querySelector("input").value; | |
}); | |
// Puppeteer test | |
const text = 'text'; | |
for (let i = 1 ; i < 500 ; i++) { | |
await page.type('input', text + i); | |
const windowValue = await page.evaluate(() => window.value); | |
if (windowValue != (text + i)) { | |
throw new Error('Wrong value: ' + windowValue); | |
} | |
await page.evaluate(() => document.querySelector('input').value = ''); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment