Issue 1:
How I can just check URL in new tab opened after link clicking, and at once abort all traffic to avoid not needed network traffic generation.

I tried with below test but it is not working.

System info

Playwright Version: [v1.34]

Operating System: [Windows 11]

Browser: [Chromium]

Other info:

Source code

[ x] I provided exact source code that allows reproducing the issue locally.

Using default config

import { expect, test } from '@playwright/test';

test('verify link in new tab', async ({ page }) => {
await page.goto('https://playwright.dev/');
const popupPromise = page.waitForEvent('popup');

await page.getByRole('link', { name: 'GitHub repository' }).click();
const popup = await popupPromise;

//synchronous below - will not fully work
await popup.route('**/*', (route) => route.abort());
await popup.waitForLoadState();

await expect(popup).toHaveURL('https://github.com/microsoft/playwright');
});

Issue 2:
System info

Playwright Version: v1.32.2

Operating System: Windows 10

Browser: chromium, firefox, webkit

Other info: Node v16.14.0

Source code

I provided exact source code that allows reproducing the issue locally.

package.json

{
"name": "testcase",
"version": "1.0.0",
"type": "module",
"dependencies": {
"playwright": "1.32.2"
}
}

Test file (self-contained)

// index.js
import playwright from "playwright";

for (let i = 0; i < 1000; ++i) {
console.log(i);
const browser = await playwright.chromium.launch({ slowMo: 250 });
const context = await browser.newContext();
const page = await context.newPage();
page.on("framenavigated", async (frame) => {
await frame.locator("span").evaluateAll(() => {});
await frame.addStyleTag({ content: "div {}" });
});
await page.goto("https://playwright.dev/docs/api/class-browser");
await context.close();
await browser.close();
}

Steps

Unzip testcase.zip

npm install

DEBUG=pw:api,pw:channel:command,pw:channel:response node index.js

Expected

No error.

Actual

0
pw:api => browserType.launch started +0ms
pw:channel:command {
pw:channel:command id: 1,
pw:channel:command guid: 'browser-type@217bc1acf01e8ab60147d89d2aafcd1a',
pw:channel:command method: 'launch',
pw:channel:command params: { ignoreAllDefaultArgs: false, slowMo: 250 }
pw:channel:command } +0ms
pw:channel:response {
pw:channel:response id: 1,
pw:channel:response result: { browser: { guid: 'browser@457c5f62717d2b86635a9c36c4b2a3a2' } }
pw:channel:response } +0ms
pw:api <= browserType.launch succeeded +412ms
pw:api => browser.newContext started +2ms
pw:channel:command {
pw:channel:command id: 2,
pw:channel:command guid: 'browser@457c5f62717d2b86635a9c36c4b2a3a2',
pw:channel:command method: 'newContext',
pw:channel:command params: { noDefaultViewport: false }
pw:channel:command } +413ms
pw:channel:response {
pw:channel:response id: 2,
pw:channel:response result: {
pw:channel:response context: { guid: 'browser-context@c2725438de82db711cab1d84e6966c97' }
pw:channel:response }
pw:channel:response } +11ms
pw:api <= browser.newContext succeeded +9ms
pw:api => browserContext.newPage started +1ms
pw:channel:command {
pw:channel:command id: 3,
pw:channel:command guid: 'browser-context@c2725438de82db711cab1d84e6966c97',
pw:channel:command method: 'newPage',
pw:channel:command params: undefined
pw:channel:command } +10ms
pw:channel:response {
pw:channel:response id: 3,
pw:channel:response result: { page: { guid: 'page@b84a8ba8e6e23aa2528953cbf97dc5c3' } }
pw:channel:response } +155ms
pw:api <= browserContext.newPage succeeded +153ms
pw:api => page.goto started +1ms
pw:channel:command {
pw:channel:command id: 4,
pw:channel:command guid: 'frame@3ee5e10621a15eaf80cb985dbccb9a28',
pw:channel:command method: 'goto',
pw:channel:command params: {
pw:channel:command url: 'https://playwright.dev/docs/api/class-browser',
pw:channel:command waitUntil: 'load'
pw:channel:command }
pw:channel:command } +154ms
pw:api navigating to "https://playwright.dev/docs/api/class-browser", waiting until "load" +2ms
pw:api "commit" event fired +45ms
pw:api navigated to "https://playwright.dev/docs/api/class-browser" +1ms
pw:api => locator.evaluateAll started +3ms
pw:channel:command {
pw:channel:command id: 5,
pw:channel:command guid: 'frame@3ee5e10621a15eaf80cb985dbccb9a28',
pw:channel:command method: 'evalOnSelectorAll',
pw:channel:command params: {
pw:channel:command selector: 'span',
pw:channel:command expression: '() => {}',
pw:channel:command isFunction: true,
pw:channel:command arg: { value: [Object], handles: [] }
pw:channel:command }
pw:channel:command } +51ms
pw:api "domcontentloaded" event fired +189ms
pw:api "load" event fired +117ms
pw:channel:response { id: 5, result: { value: { v: 'undefined' } } } +512ms
pw:api <= locator.evaluateAll succeeded +157ms
pw:api => frame.addStyleTag started +3ms
pw:channel:command {
pw:channel:command id: 6,
pw:channel:command guid: 'frame@3ee5e10621a15eaf80cb985dbccb9a28',
pw:channel:command method: 'addStyleTag',
pw:channel:command params: { content: 'div {}' }
pw:channel:command } +466ms
pw:channel:response {
pw:channel:response id: 4,
pw:channel:response result: { response: { guid: 'response@cab1b2a18575669f02a3fbe57676ad7a' } }
pw:channel:response } +105ms
pw:api <= page.goto succeeded +100ms
pw:api => browserContext.close started +3ms
pw:channel:command {
pw:channel:command id: 7,
pw:channel:command guid: 'browser-context@c2725438de82db711cab1d84e6966c97',
pw:channel:command method: 'close',
pw:channel:command params: undefined
pw:channel:command } +103ms
pw:channel:response { id: 7 } +12ms
pw:api <= browserContext.close succeeded +8ms
pw:api => browser.close started +1ms
pw:channel:command {
pw:channel:command id: 8,
pw:channel:command guid: 'browser@457c5f62717d2b86635a9c36c4b2a3a2',
pw:channel:command method: 'close',
pw:channel:command params: undefined
pw:channel:command } +9ms
pw:channel:response { id: 8 } +38ms
pw:api <= browser.close succeeded +38ms
1
pw:api => browserType.launch started +3ms
pw:channel:command {
pw:channel:command id: 9,
pw:channel:command guid: 'browser-type@217bc1acf01e8ab60147d89d2aafcd1a',
pw:channel:command method: 'launch',
pw:channel:command params: { ignoreAllDefaultArgs: false, slowMo: 250 }
pw:channel:command } +42ms
pw:channel:response {
pw:channel:response id: 6,
pw:channel:response result: { element: { guid: 'handle@7833e65f500bd1d978e1450a5459c7bb' } }
pw:channel:response } +238ms
C:\Users\regseb\dev\testcase\node_modules\playwright-core\lib\client\connection.js:211
if (!object) throw new Error(`Object with guid ${arg.guid} was not bound in the connection`);
^

Error: Object with guid handle@7833e65f500bd1d978e1450a5459c7bb was not bound in the connection
at Connection._tChannelImplFromWire (C:\Users\regseb\dev\testcase\node_modules\playwright-core\lib\client\connection.js:211:26)
at C:\Users\regseb\dev\testcase\node_modules\playwright-core\lib\protocol\validatorPrimitives.js:129:20
at C:\Users\regseb\dev\testcase\node_modules\playwright-core\lib\protocol\validatorPrimitives.js:108:21
at Connection.dispatch (C:\Users\regseb\dev\testcase\node_modules\playwright-core\lib\client\connection.js:170:26)
at Immediate.<anonymous> (C:\Users\regseb\dev\testcase\node_modules\playwright-core\lib\inProcessFactory.js:46:83)
at processImmediate (node:internal/timers:466:21)

Additional info

I add style with frame.addStyleTag().

Playwright sends a command to the browser to add style (using a protocol close to JSON-RPC).

{
id: 6,
guid: 'frame@3ee5e10621a15eaf80cb985dbccb9a28',
method: 'addStyleTag',
params: { content: 'div {}' }
}

I close the browser.

Playwright removes the callbacks from the commands.

Playwright receives the response from the command.

{
id: 6,
result: { element: { guid: 'handle@7833e65f500bd1d978e1450a5459c7bb' } }
}

Playwright doesn't find the callback associated with the command and throws an exception.

playwright/packages/playwright-core/src/client/connection.ts

Lines 191 to 193
in
ecd0f92

const object = this._objects.get(arg.guid)!;

if (!object)

throw new Error(`Object with guid ${arg.guid} was not bound in the connection`);

Related issues

#20023

#21210 (comment)

#21210 (comment)