Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
feat: test for console.debug
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed Apr 28, 2023
1 parent a01f995 commit 3f140b8
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions plugins/default-browser-emulator/test/detection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,36 @@ test('should not recurse the toString function', async () => {
expect(isHeadless).toBe(false);
});

test('should not call evaluate on a stack getter in debug', async () => {
const agent = pool.createAgent({
logger,
});
Helpers.needsClosing.push(agent);
const page = await agent.newPage();
page.on('console', console.log);
koaServer.get('/debug', ctx => {
ctx.body = `<html lang='en'><body><h1>Hi</h1><div id='result'>no result</div></body>
<script>
window.didCallGetter = false;
const error = new Error();
window.Object.defineProperty(error, 'stack', {
configurable: false,
enumerable: false,
get: function () {
window.didCallGetter = true;
document.querySelector('#result').innerText = 'called';
return '';
}
});
console.debug(error);
</script></html>`;
});
await page.goto(`${koaServer.baseUrl}/debug`);
await page.waitForLoad('DomContentLoaded');
const allowStackGetter = await page.evaluate<boolean>('window.didCallGetter');
expect(allowStackGetter).toBe(false);
});

test('should be able to post message', async () => {
const agent = pool.createAgent({
logger,
Expand Down

0 comments on commit 3f140b8

Please sign in to comment.