Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: fix a race in the oopif test (#3211)

Dmitry Gozman10225d1983b0
diff --git a/test/chromium/oopif.jest.js b/test/chromium/oopif.jest.js
index 0da4bee20e..539644f890 100644
--- a/test/chromium/oopif.jest.js
+++ b/test/chromium/oopif.jest.js
@@ -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 });
@@ -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)');
diff --git a/test/jest/playwrightEnvironment.js b/test/jest/playwrightEnvironment.js
index 8f53ea698a..b89d753e18 100644
--- a/test/jest/playwrightEnvironment.js
+++ b/test/jest/playwrightEnvironment.js
@@ -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');
@@ -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)}"`);
}
};
}
@@ -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();
@@ -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);
}
@@ -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;
+}