Skip to content

test: fix a race in the oopif test #3211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion test/chromium/oopif.jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,16 @@ describe.skip(!CHROMIUM)('OOPIF', function() {
iframe.style.marginLeft = '42px';
iframe.style.marginTop = '17px';
});
await page.frames()[1].goto(page.frames()[1].url());

expect(await countOOPIFs(browser)).toBe(1);
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 });

await page.evaluate(() => goLocal());
await Promise.all([
page.frames()[1].waitForNavigation(),
page.evaluate(() => goLocal()),
]);
expect(await countOOPIFs(browser)).toBe(0);
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 });
Expand All @@ -323,6 +327,7 @@ describe.skip(!CHROMIUM)('OOPIF', function() {
iframe.style.marginLeft = '102px';
iframe.style.marginTop = '117px';
});
await page.frames()[1].goto(page.frames()[1].url());

expect(await countOOPIFs(browser)).toBe(1);
const handle1 = await page.frames()[1].$('.box:nth-of-type(13)');
Expand Down
19 changes: 17 additions & 2 deletions test/jest/playwrightEnvironment.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const registerFixtures = require('./fixtures');
const os = require('os');
const path = require('path');
const fs = require('fs');
const debug = require('debug');
const platform = os.platform();
const GoldenUtils = require('../../utils/testrunner/GoldenUtils');
const {installCoverageHooks} = require('./coverage');
Expand Down Expand Up @@ -158,10 +159,12 @@ class PlaywrightEnvironment extends NodeEnvironment {
if (event.name === 'test_start') {
const fn = event.test.fn;
event.test.fn = async () => {
debug('pw:test')(`start "${testOrSuiteName(event.test)}"`);
try {
return await this.fixturePool.resolveParametersAndRun(fn);
await this.fixturePool.resolveParametersAndRun(fn);
} finally {
await this.fixturePool.teardownScope('test');
debug('pw:test')(`finish "${testOrSuiteName(event.test)}"`);
}
};
}
Expand Down Expand Up @@ -196,6 +199,7 @@ class Fixture {
let setupFenceReject;
const setupFence = new Promise((f, r) => { setupFenceFulfill = f; setupFenceReject = r; });
const teardownFence = new Promise(f => this._teardownFenceCallback = f);
debug('pw:test:hook')(`setup "${this.name}"`);
this._tearDownComplete = this.fn(params, async value => {
this.value = value;
setupFenceFulfill();
Expand All @@ -215,8 +219,10 @@ class Fixture {
continue;
await fixture.teardown();
}
if (this._setup)
if (this._setup) {
debug('pw:test:hook')(`teardown "${this.name}"`);
this._teardownFenceCallback();
}
await this._tearDownComplete;
this.pool.instances.delete(this.name);
}
Expand Down Expand Up @@ -281,3 +287,12 @@ function valueFromEnv(name, defaultValue) {
return defaultValue;
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;
}