Skip to content

Commit

Permalink
fix(domworld): reset bindings when context changes (#6766) (#6836)
Browse files Browse the repository at this point in the history
  • Loading branch information
jschfflr committed Feb 8, 2021
1 parent 6fec36d commit 4e8d074
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/common/DOMWorld.ts
Expand Up @@ -115,6 +115,7 @@ export class DOMWorld {

async _setContext(context?: ExecutionContext): Promise<void> {
if (context) {
this._ctxBindings = new Set();
this._contextResolveCallback.call(null, context);
this._contextResolveCallback = null;
for (const waitTask of this._waitTasks) waitTask.rerun();
Expand Down
16 changes: 16 additions & 0 deletions test/ariaqueryhandler.spec.ts
Expand Up @@ -195,6 +195,22 @@ describeChromeOnly('AriaQueryHandler', () => {
await page.waitForSelector('aria/[role="button"]');
});

it('should persist query handler bindings across navigations', async () => {
const { page, server } = getTestState();

// Reset page but make sure that execution context ids start with 1.
await page.goto('data:text/html,');
await page.goto(server.EMPTY_PAGE);
await page.evaluate(addElement, 'button');
await page.waitForSelector('aria/[role="button"]');

// Reset page but again make sure that execution context ids start with 1.
await page.goto('data:text/html,');
await page.goto(server.EMPTY_PAGE);
await page.evaluate(addElement, 'button');
await page.waitForSelector('aria/[role="button"]');
});

it('should work independently of `exposeFunction`', async () => {
const { page, server } = getTestState();
await page.goto(server.EMPTY_PAGE);
Expand Down

0 comments on commit 4e8d074

Please sign in to comment.