mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
test: fix a race in the oopif test (#3211)
This commit is contained in:
parent
487bc589b0
commit
10225d1983
@ -303,12 +303,16 @@ describe.skip(!CHROMIUM)('OOPIF', function() {
|
|||||||
iframe.style.marginLeft = '42px';
|
iframe.style.marginLeft = '42px';
|
||||||
iframe.style.marginTop = '17px';
|
iframe.style.marginTop = '17px';
|
||||||
});
|
});
|
||||||
|
await page.frames()[1].goto(page.frames()[1].url());
|
||||||
|
|
||||||
expect(await countOOPIFs(browser)).toBe(1);
|
expect(await countOOPIFs(browser)).toBe(1);
|
||||||
const handle1 = await page.frames()[1].$('.box:nth-of-type(13)');
|
const handle1 = await page.frames()[1].$('.box:nth-of-type(13)');
|
||||||
expect(await handle1.boundingBox()).toEqual({ x: 100 + 42, y: 50 + 17, width: 50, height: 50 });
|
expect(await handle1.boundingBox()).toEqual({ x: 100 + 42, y: 50 + 17, width: 50, height: 50 });
|
||||||
|
|
||||||
await page.evaluate(() => goLocal());
|
await Promise.all([
|
||||||
|
page.frames()[1].waitForNavigation(),
|
||||||
|
page.evaluate(() => goLocal()),
|
||||||
|
]);
|
||||||
expect(await countOOPIFs(browser)).toBe(0);
|
expect(await countOOPIFs(browser)).toBe(0);
|
||||||
const handle2 = await page.frames()[1].$('.box:nth-of-type(13)');
|
const handle2 = await page.frames()[1].$('.box:nth-of-type(13)');
|
||||||
expect(await handle2.boundingBox()).toEqual({ x: 100 + 42, y: 50 + 17, width: 50, height: 50 });
|
expect(await handle2.boundingBox()).toEqual({ x: 100 + 42, y: 50 + 17, width: 50, height: 50 });
|
||||||
@ -323,6 +327,7 @@ describe.skip(!CHROMIUM)('OOPIF', function() {
|
|||||||
iframe.style.marginLeft = '102px';
|
iframe.style.marginLeft = '102px';
|
||||||
iframe.style.marginTop = '117px';
|
iframe.style.marginTop = '117px';
|
||||||
});
|
});
|
||||||
|
await page.frames()[1].goto(page.frames()[1].url());
|
||||||
|
|
||||||
expect(await countOOPIFs(browser)).toBe(1);
|
expect(await countOOPIFs(browser)).toBe(1);
|
||||||
const handle1 = await page.frames()[1].$('.box:nth-of-type(13)');
|
const handle1 = await page.frames()[1].$('.box:nth-of-type(13)');
|
||||||
|
|||||||
@ -19,6 +19,7 @@ const registerFixtures = require('./fixtures');
|
|||||||
const os = require('os');
|
const os = require('os');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const debug = require('debug');
|
||||||
const platform = os.platform();
|
const platform = os.platform();
|
||||||
const GoldenUtils = require('../../utils/testrunner/GoldenUtils');
|
const GoldenUtils = require('../../utils/testrunner/GoldenUtils');
|
||||||
const {installCoverageHooks} = require('./coverage');
|
const {installCoverageHooks} = require('./coverage');
|
||||||
@ -158,10 +159,12 @@ class PlaywrightEnvironment extends NodeEnvironment {
|
|||||||
if (event.name === 'test_start') {
|
if (event.name === 'test_start') {
|
||||||
const fn = event.test.fn;
|
const fn = event.test.fn;
|
||||||
event.test.fn = async () => {
|
event.test.fn = async () => {
|
||||||
|
debug('pw:test')(`start "${testOrSuiteName(event.test)}"`);
|
||||||
try {
|
try {
|
||||||
return await this.fixturePool.resolveParametersAndRun(fn);
|
await this.fixturePool.resolveParametersAndRun(fn);
|
||||||
} finally {
|
} finally {
|
||||||
await this.fixturePool.teardownScope('test');
|
await this.fixturePool.teardownScope('test');
|
||||||
|
debug('pw:test')(`finish "${testOrSuiteName(event.test)}"`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -196,6 +199,7 @@ class Fixture {
|
|||||||
let setupFenceReject;
|
let setupFenceReject;
|
||||||
const setupFence = new Promise((f, r) => { setupFenceFulfill = f; setupFenceReject = r; });
|
const setupFence = new Promise((f, r) => { setupFenceFulfill = f; setupFenceReject = r; });
|
||||||
const teardownFence = new Promise(f => this._teardownFenceCallback = f);
|
const teardownFence = new Promise(f => this._teardownFenceCallback = f);
|
||||||
|
debug('pw:test:hook')(`setup "${this.name}"`);
|
||||||
this._tearDownComplete = this.fn(params, async value => {
|
this._tearDownComplete = this.fn(params, async value => {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
setupFenceFulfill();
|
setupFenceFulfill();
|
||||||
@ -215,8 +219,10 @@ class Fixture {
|
|||||||
continue;
|
continue;
|
||||||
await fixture.teardown();
|
await fixture.teardown();
|
||||||
}
|
}
|
||||||
if (this._setup)
|
if (this._setup) {
|
||||||
|
debug('pw:test:hook')(`teardown "${this.name}"`);
|
||||||
this._teardownFenceCallback();
|
this._teardownFenceCallback();
|
||||||
|
}
|
||||||
await this._tearDownComplete;
|
await this._tearDownComplete;
|
||||||
this.pool.instances.delete(this.name);
|
this.pool.instances.delete(this.name);
|
||||||
}
|
}
|
||||||
@ -281,3 +287,12 @@ function valueFromEnv(name, defaultValue) {
|
|||||||
return defaultValue;
|
return defaultValue;
|
||||||
return JSON.parse(process.env[name]);
|
return JSON.parse(process.env[name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testOrSuiteName(o) {
|
||||||
|
if (o.name === 'ROOT_DESCRIBE_BLOCK')
|
||||||
|
return '';
|
||||||
|
let name = o.parent ? testOrSuiteName(o.parent) : '';
|
||||||
|
if (name && o.name)
|
||||||
|
name += ' ';
|
||||||
|
return name + o.name;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user