test: dont race against the mutation observer (#2016)

This commit is contained in:
JoelEinbinder 2018-02-13 11:00:38 -08:00 committed by Andrey Lushnikov
parent 1b6ee37137
commit 700244a29a

View File

@ -816,12 +816,12 @@ describe('Page', function() {
const frame1 = page.frames()[1]; const frame1 = page.frames()[1];
const frame2 = page.frames()[2]; const frame2 = page.frames()[2];
let added = false; let added = false;
frame2.waitForSelector('div').then(() => added = true); const waitForSelectorPromise = frame2.waitForSelector('div').then(() => added = true);
expect(added).toBe(false); expect(added).toBe(false);
await frame1.evaluate(addElement, 'div'); await frame1.evaluate(addElement, 'div');
expect(added).toBe(false); expect(added).toBe(false);
await frame2.evaluate(addElement, 'div'); await frame2.evaluate(addElement, 'div');
expect(added).toBe(true); await waitForSelectorPromise;
}); });
it('should throw if evaluation failed', async({page, server}) => { it('should throw if evaluation failed', async({page, server}) => {
@ -942,12 +942,12 @@ describe('Page', function() {
const frame1 = page.frames()[1]; const frame1 = page.frames()[1];
const frame2 = page.frames()[2]; const frame2 = page.frames()[2];
let added = false; let added = false;
frame2.waitForXPath('//div').then(() => added = true); const waitForXPathPromise = frame2.waitForXPath('//div').then(() => added = true);
expect(added).toBe(false); expect(added).toBe(false);
await frame1.evaluate(addElement, 'div'); await frame1.evaluate(addElement, 'div');
expect(added).toBe(false); expect(added).toBe(false);
await frame2.evaluate(addElement, 'div'); await frame2.evaluate(addElement, 'div');
expect(added).toBe(true); await waitForXPathPromise;
}); });
it('should throw if evaluation failed', async({page, server}) => { it('should throw if evaluation failed', async({page, server}) => {
await page.evaluateOnNewDocument(function() { await page.evaluateOnNewDocument(function() {