Enable MutationObserver attributes (#499)

This patch fixes page.waitForSelector to resolve on
attribute changes. 

Fixes #474.
This commit is contained in:
Dan Schuman 2017-08-23 13:25:40 -07:00 committed by Andrey Lushnikov
parent a756bc868f
commit 8fe2477850
2 changed files with 11 additions and 1 deletions

View File

@ -497,7 +497,8 @@ async function waitForPredicatePageFunction(predicateBody, polling, timeout) {
});
observer.observe(document, {
childList: true,
subtree: true
subtree: true,
attributes: true
});
return result;
}

View File

@ -451,6 +451,15 @@ describe('Page', function() {
expect(error).toBeTruthy();
expect(error.message).toContain('waiting failed: timeout');
}));
it('should respond to node attribute mutation', SX(async function() {
let divFound = false;
const waitForSelector = page.waitForSelector('.zombo').then(() => divFound = true);
await page.setContent(`<div class='notZombo'></div>`);
expect(divFound).toBe(false);
await page.evaluate(() => document.querySelector('div').className = 'zombo');
expect(await waitForSelector).toBe(true);
}));
});
describe('Page.waitFor', function() {