Skip to content

Commit

Permalink
12
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKamaev committed Dec 27, 2021
1 parent b501cc3 commit a2b2d26
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
6 changes: 1 addition & 5 deletions src/browser/connection/gateway.ts
Expand Up @@ -188,13 +188,9 @@ export default class BrowserConnectionGateway {

private static _onCloseWindowRequest (req: IncomingMessage, res: ServerResponse, connection: BrowserConnection): void {
if (BrowserConnectionGateway._ensureConnectionReady(res, connection)) {
debugger;

connection.provider.closeBrowserChildWindow(connection.id)
.then(() => {
setTimeout(() => {
respondWithJSON(res);
}, 2000);
respondWithJSON(res);
});
}
}
Expand Down
14 changes: 10 additions & 4 deletions src/browser/provider/built-in/dedicated/chrome/cdp-client/index.ts
Expand Up @@ -234,6 +234,9 @@ export class BrowserClient {
}

public async setClientInactive (): Promise<void> {
// NOTE: ensure client exists
await this.getActiveClient();

const client = this._clients[this._clientKey];

if (client)
Expand All @@ -243,7 +246,8 @@ export class BrowserClient {
public async getActiveClient (): Promise<remoteChrome.ProtocolApi | void> {
try {
if (!this._clients[this._clientKey])
this._clients[this._clientKey] = new ProtocolApiInfo(await this._createClient());
await this._createClient();
// this._clients[this._clientKey] = new ProtocolApiInfo(await this._createClient());
}
catch (err) {
debugLog(err);
Expand Down Expand Up @@ -295,7 +299,7 @@ export class BrowserClient {
const client = await this.getActiveClient();

if (!client) {
await delay(1);
await delay(0);

return Buffer.alloc(0);
}
Expand Down Expand Up @@ -412,7 +416,9 @@ export class BrowserClient {
ExecutionContext.switchToMainWindow();
}

public closeBrowserChildWindow (): Promise<void> {
return this.setClientInactive();
public async closeBrowserChildWindow (): Promise<void> {
await this.setClientInactive();

await delay(100);
}
}
Expand Up @@ -4,11 +4,10 @@ const child = 'http://localhost:3000/fixtures/multiple-windows/pages/api/child-2
fixture('Should not hang on close window whide video is recording')
.page(parent);

for (let i = 0; i < 5; i++) {
for (let i = 0; i < 30; i++) {
test(`attempt ${i}`, async t => {
await t
.openWindow(child)
.wait(1000)
.closeWindow();
});
}
Expand Up @@ -28,15 +28,7 @@ fixture('Two windows - expect bug')
for (let i = 0; i < 10; i++) {
test('Open website page in 2 windows and expect', async t => {
await t
// .click(Selector('button[name="submitAll"]'))
.openWindow('http://google.com')
// .resizeWindow(1200, 700)
// .pressKey('enter')
// .expect(Selector('a[href="https://www.dr.dk/"]').exists).ok({ timeout: 5000 })
.wait(1000)
.closeWindow()
// .switchToParentWindow()
.wait(1000);
// .pressKey('enter')
.closeWindow();
});
}

0 comments on commit a2b2d26

Please sign in to comment.