Skip to content

Instantly share code, notes, and snippets.

@juliandescottes
Created July 1, 2019 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliandescottes/1b3e52ade0efd9f6cf80a8e5c3c4ac62 to your computer and use it in GitHub Desktop.
Save juliandescottes/1b3e52ade0efd9f6cf80a8e5c3c4ac62 to your computer and use it in GitHub Desktop.
// 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