playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[internal] re-enable RenderDocument

Open dgozman opened this issue 3 months ago • 3 comments

RenderDocument feature breaks isolated worlds - it reports an extra utility context, and so using it right away results in an error.

Commit that enabled RenderDocument: https://chromium.googlesource.com/chromium/src/+/c35065f7e612e3becbe7f24baaca28c7859b7543

Failing tests:

[chromium-library] › library/chromium/js-coverage.spec.ts:66 › should report scripts across navigations when disabled
[chromium-page] › page/frame-evaluate.spec.ts:45 › should dispose context on navigation
[chromium-page] › page/frame-evaluate.spec.ts:55 › should dispose context on cross-origin navigation
[chromium-page] › page/page-goto.spec.ts:828 › should return when navigation is committed if commit is specified
[chromium-page] › page/page-wait-for-navigation.spec.ts:63 › should work with commit
[chromium-page] › page/page-wait-for-url.spec.ts:52 › should work with commit

dgozman avatar Oct 06 '25 09:10 dgozman

Relevant protocol log
  pw:protocol SEND ► {"id":1,"method":"Browser.getVersion"} +0ms
  pw:protocol ◀ RECV {"id":1,"result":{"protocolVersion":"1.3","product":"Chrome/143.0.7447.0","revision":"@4553da61ef1a9546a795026c1d70738ed9999b89","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/143.0.0.0 Safari/537.36","jsVersion":"14.3.28"}} +352ms
  pw:protocol SEND ► {"id":2,"method":"Target.setAutoAttach","params":{"autoAttach":true,"waitForDebuggerOnStart":true,"flatten":true}} +0ms
  pw:protocol ◀ RECV {"id":2,"result":{}} +1ms
  pw:protocol SEND ► {"id":3,"method":"Target.createBrowserContext","params":{"disposeOnDetach":true}} +13ms
  pw:protocol ◀ RECV {"id":3,"result":{"browserContextId":"4BE26E27D78065618129845F4885052B"}} +6ms
  pw:protocol SEND ► {"id":4,"method":"Browser.setDownloadBehavior","params":{"behavior":"allowAndName","browserContextId":"4BE26E27D78065618129845F4885052B","downloadPath":"C:\\Users\\dgozman\\AppData\\Local\\Temp\\playwright-artifacts-7aDjik","eventsEnabled":true}} +3ms
  pw:protocol ◀ RECV {"id":4,"result":{}} +1ms
  pw:protocol SEND ► {"id":5,"method":"Target.createTarget","params":{"url":"about:blank","browserContextId":"4BE26E27D78065618129845F4885052B"}} +15ms
  pw:protocol ◀ RECV {"method":"Target.attachedToTarget","params":{"sessionId":"6FE3A51109E8390B5A8D763E282A0911","targetInfo":{"targetId":"446E7EBD9BB35E285820A86DF721DDB6","type":"page","title":"","url":"about:blank","attached":true,"canAccessOpener":false,"browserContextId":"4BE26E27D78065618129845F4885052B"},"waitingForDebugger":true}} +66ms
  pw:protocol SEND ► {"id":6,"method":"Browser.getWindowForTarget","sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +3ms
  pw:protocol ◀ RECV {"id":5,"result":{"targetId":"446E7EBD9BB35E285820A86DF721DDB6"}} +7ms
  pw:protocol ◀ RECV {"id":6,"result":{"windowId":286701268,"bounds":{"left":10,"top":10,"width":780,"height":580,"windowState":"normal"}},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +2ms
  pw:protocol SEND ► {"id":7,"method":"Page.enable","sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol SEND ► {"id":8,"method":"Page.getFrameTree","sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol SEND ► {"id":9,"method":"Log.enable","params":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol SEND ► {"id":10,"method":"Page.setLifecycleEventsEnabled","params":{"enabled":true},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +1ms
  pw:protocol SEND ► {"id":11,"method":"Runtime.enable","params":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol SEND ► {"id":12,"method":"Page.addScriptToEvaluateOnNewDocument","params":{"source":"","worldName":"__playwright_utility_world_page@590d646c08b8cce334ff020752fa2c46"},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol SEND ► {"id":13,"method":"Network.enable","sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol SEND ► {"id":14,"method":"Target.setAutoAttach","params":{"autoAttach":true,"waitForDebuggerOnStart":true,"flatten":true,"filter":[{"type":"iframe"},{"type":"worker"},{"type":"service_worker","exclude":true}]},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +1ms
  pw:protocol SEND ► {"id":15,"method":"Emulation.setFocusEmulationEnabled","params":{"enabled":true},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol SEND ► {"id":16,"method":"Browser.setWindowBounds","params":{"windowId":286701268,"bounds":{"width":1280,"height":720}},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol SEND ► {"id":17,"method":"Emulation.setDeviceMetricsOverride","params":{"mobile":false,"width":1280,"height":720,"screenWidth":1280,"screenHeight":720,"deviceScaleFactor":1,"screenOrientation":{"angle":0,"type":"landscapePrimary"}},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol SEND ► {"id":18,"method":"Emulation.setUserAgentOverride","params":{"userAgent":"","acceptLanguage":"en-US"},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +1ms
  pw:protocol SEND ► {"id":19,"method":"Emulation.setLocaleOverride","params":{"locale":"en-US"},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol SEND ► {"id":20,"method":"Page.setFontFamilies","params":{"fontFamilies":{"standard":"Times New Roman","fixed":"Consolas","serif":"Times New Roman","sansSerif":"Arial","cursive":"Comic Sans MS","fantasy":"Impact"},"forScripts":[{"script":"cyrl","fontFamilies":{"standard":"Times New Roman","fixed":"Courier New","serif":"Times New Roman","sansSerif":"Arial"}},{"script":"arab","fontFamilies":{"fixed":"Courier New","sansSerif":"Segoe UI"}},{"script":"grek","fontFamilies":{"standard":"Times New Roman","fixed":"Courier New","serif":"Times New Roman","sansSerif":"Arial"}},{"script":"jpan","fontFamilies":{"standard":",Meiryo,Yu Gothic","fixed":"MS Gothic","serif":",Yu Mincho,MS PMincho","sansSerif":",Meiryo,Yu Gothic"}},{"script":"hang","fontFamilies":{"standard":"Malgun Gothic","fixed":"Gulimche","serif":"Batang","sansSerif":"Malgun Gothic","cursive":"Gungsuh"}},{"script":"hans","fontFamilies":{"standard":"Microsoft YaHei","fixed":"NSimsun","serif":"Simsun","sansSerif":"Microsoft YaHei","cursive":"KaiTi"}},{"script":"hant","fontFamilies":{"standard":"Microsoft JhengHei","fixed":"MingLiU","serif":"PMingLiU","sansSerif":"Microsoft JhengHei","cursive":"DFKai-SB"}}]},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol SEND ► {"id":21,"method":"Emulation.setEmulatedMedia","params":{"media":"","features":[{"name":"prefers-color-scheme","value":"light"},{"name":"prefers-reduced-motion","value":"no-preference"},{"name":"forced-colors","value":"none"},{"name":"prefers-contrast","value":"no-preference"}]},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +1ms
  pw:protocol SEND ► {"id":22,"method":"Runtime.runIfWaitingForDebugger","sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"id":16,"result":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +5ms
  pw:protocol ◀ RECV {"method":"Network.policyUpdated","params":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +52ms
  pw:protocol ◀ RECV {"method":"Page.frameStoppedLoading","params":{"frameId":"446E7EBD9BB35E285820A86DF721DDB6"},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +9ms
  pw:protocol ◀ RECV {"id":7,"result":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +1ms
  pw:protocol ◀ RECV {"id":8,"result":{"frameTree":{"frame":{"id":"446E7EBD9BB35E285820A86DF721DDB6","loaderId":"5E3478C6719C5240F0CD3F8AED2AAB40","url":"about:blank","domainAndRegistry":"","securityOrigin":"://","securityOriginDetails":{"isLocalhost":false},"mimeType":"text/html","adFrameStatus":{"adFrameType":"none"},"secureContextType":"InsecureScheme","crossOriginIsolatedContextType":"NotIsolated","gatedAPIFeatures":[]}}},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol SEND ► {"id":23,"method":"Page.createIsolatedWorld","params":{"frameId":"446E7EBD9BB35E285820A86DF721DDB6","grantUniveralAccess":true,"worldName":"__playwright_utility_world_page@590d646c08b8cce334ff020752fa2c46"},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +2ms
  pw:protocol ◀ RECV {"id":9,"result":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"method":"Page.lifecycleEvent","params":{"frameId":"446E7EBD9BB35E285820A86DF721DDB6","loaderId":"5E3478C6719C5240F0CD3F8AED2AAB40","name":"commit","timestamp":4701567.406656},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"method":"Page.lifecycleEvent","params":{"frameId":"446E7EBD9BB35E285820A86DF721DDB6","loaderId":"5E3478C6719C5240F0CD3F8AED2AAB40","name":"DOMContentLoaded","timestamp":4701567.406821},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +1ms
  pw:protocol ◀ RECV {"method":"Page.lifecycleEvent","params":{"frameId":"446E7EBD9BB35E285820A86DF721DDB6","loaderId":"5E3478C6719C5240F0CD3F8AED2AAB40","name":"load","timestamp":4701567.407982},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"method":"Page.lifecycleEvent","params":{"frameId":"446E7EBD9BB35E285820A86DF721DDB6","loaderId":"5E3478C6719C5240F0CD3F8AED2AAB40","name":"networkAlmostIdle","timestamp":4701567.407755},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"method":"Page.lifecycleEvent","params":{"frameId":"446E7EBD9BB35E285820A86DF721DDB6","loaderId":"5E3478C6719C5240F0CD3F8AED2AAB40","name":"networkIdle","timestamp":4701567.407755},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"id":10,"result":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"method":"Runtime.executionContextCreated","params":{"context":{"id":1,"origin":"://","name":"","uniqueId":"3344387447319892746.-774129535190415857","auxData":{"isDefault":true,"type":"default","frameId":"446E7EBD9BB35E285820A86DF721DDB6"}}},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"id":11,"result":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +1ms
  pw:protocol ◀ RECV {"id":12,"result":{"identifier":"1"},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"id":13,"result":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"id":14,"result":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"id":15,"result":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"method":"Page.frameResized","params":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"id":17,"result":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"id":18,"result":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"id":19,"result":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"id":20,"result":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +1ms
  pw:protocol ◀ RECV {"id":21,"result":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"id":22,"result":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"method":"Runtime.executionContextCreated","params":{"context":{"id":2,"origin":"","name":"__playwright_utility_world_page@590d646c08b8cce334ff020752fa2c46","uniqueId":"5373864394948387910.1621773160709327684","auxData":{"isDefault":false,"type":"isolated","frameId":"446E7EBD9BB35E285820A86DF721DDB6"}}},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +10ms
  pw:protocol ◀ RECV {"id":23,"result":{"executionContextId":2},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol SEND ► {"id":24,"method":"Page.navigate","params":{"url":"http://localhost:8907/empty.html","frameId":"446E7EBD9BB35E285820A86DF721DDB6","referrerPolicy":"unsafeUrl"},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +46ms
  pw:protocol ◀ RECV {"method":"Page.frameStartedNavigating","params":{"frameId":"446E7EBD9BB35E285820A86DF721DDB6","url":"http://localhost:8907/empty.html","loaderId":"C5816F03256D284C280E3F2D68AA54AC","navigationType":"differentDocument"},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +17ms
  pw:protocol ◀ RECV {"method":"Page.frameStartedLoading","params":{"frameId":"446E7EBD9BB35E285820A86DF721DDB6"},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"method":"Network.requestWillBeSent","params":{"requestId":"C5816F03256D284C280E3F2D68AA54AC","loaderId":"C5816F03256D284C280E3F2D68AA54AC","documentURL":"http://localhost:8907/empty.html","request":{"url":"http://localhost:8907/empty.html","method":"GET","headers":{"Accept-Language":"en-US","Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/143.0.0.0 Safari/537.36","sec-ch-ua":"\"Chromium\";v=\"143\", \"Not A(Brand\";v=\"24\"","sec-ch-ua-mobile":"?0","sec-ch-ua-platform":"\"Windows\""},"mixedContentType":"none","initialPriority":"VeryHigh","referrerPolicy":"unsafe-url","isSameSite":true},"timestamp":4701567.491807,"wallTime":1759742339.26379,"initiator":{"type":"other"},"redirectHasExtraInfo":false,"type":"Document","frameId":"446E7EBD9BB35E285820A86DF721DDB6","hasUserGesture":false},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"method":"Network.requestWillBeSentExtraInfo","params":{"requestId":"C5816F03256D284C280E3F2D68AA54AC","associatedCookies":[],"headers":{"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7","Accept-Encoding":"gzip, deflate, br, zstd","Accept-Language":"en-US","Connection":"keep-alive","Host":"localhost:8907","Sec-Fetch-Dest":"document","Sec-Fetch-Mode":"navigate","Sec-Fetch-Site":"none","Sec-Fetch-User":"?1","Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/143.0.0.0 Safari/537.36","sec-ch-ua":"\"Chromium\";v=\"143\", \"Not A(Brand\";v=\"24\"","sec-ch-ua-mobile":"?0","sec-ch-ua-platform":"\"Windows\""},"connectTiming":{"requestTime":4701567.49258},"siteHasCookieInOtherPartition":false},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +7ms
  pw:protocol ◀ RECV {"method":"Network.responseReceivedExtraInfo","params":{"requestId":"C5816F03256D284C280E3F2D68AA54AC","blockedCookies":[],"headers":{"Connection":"keep-alive","Content-Length":"53","Date":"Mon, 06 Oct 2025 09:18:59 GMT","Keep-Alive":"timeout=5","content-type":"text/html"},"resourceIPAddressSpace":"Loopback","statusCode":200,"headersText":"HTTP/1.1 200 OK\r\ncontent-type: text/html\r\nDate: Mon, 06 Oct 2025 09:18:59 GMT\r\nConnection: keep-alive\r\nKeep-Alive: timeout=5\r\nContent-Length: 53\r\n\r\n","cookiePartitionKey":{"topLevelSite":"http://localhost","hasCrossSiteAncestor":false},"cookiePartitionKeyOpaque":false,"exemptedCookies":[]},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +1ms
  pw:protocol ◀ RECV {"method":"Network.responseReceived","params":{"requestId":"C5816F03256D284C280E3F2D68AA54AC","loaderId":"C5816F03256D284C280E3F2D68AA54AC","timestamp":4701567.497962,"type":"Document","response":{"url":"http://localhost:8907/empty.html","status":200,"statusText":"OK","headers":{"Connection":"keep-alive","Content-Length":"53","Date":"Mon, 06 Oct 2025 09:18:59 GMT","Keep-Alive":"timeout=5","content-type":"text/html"},"mimeType":"text/html","charset":"","connectionReused":true,"connectionId":74,"remoteIPAddress":"[::1]","remotePort":8907,"fromDiskCache":false,"fromServiceWorker":false,"fromPrefetchCache":false,"encodedDataLength":148,"timing":{"requestTime":4701567.49258,"proxyStart":-1,"proxyEnd":-1,"dnsStart":-1,"dnsEnd":-1,"connectStart":-1,"connectEnd":-1,"sslStart":-1,"sslEnd":-1,"workerStart":-1,"workerReady":-1,"workerFetchStart":-1,"workerRespondWithSettled":-1,"sendStart":0.212,"sendEnd":0.325,"pushStart":0,"pushEnd":0,"receiveHeadersStart":4.367,"receiveHeadersEnd":4.427},"responseTime":1759742339268.919,"protocol":"http/1.1","alternateProtocolUsage":"unspecifiedReason","securityState":"secure","isIpProtectionUsed":false},"hasExtraInfo":true,"frameId":"446E7EBD9BB35E285820A86DF721DDB6"},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"id":24,"result":{"frameId":"446E7EBD9BB35E285820A86DF721DDB6","loaderId":"C5816F03256D284C280E3F2D68AA54AC","isDownload":false},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +2ms
  pw:protocol ◀ RECV {"method":"Runtime.executionContextsCleared","params":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +1ms
  pw:protocol ◀ RECV {"method":"Page.lifecycleEvent","params":{"frameId":"446E7EBD9BB35E285820A86DF721DDB6","loaderId":"C5816F03256D284C280E3F2D68AA54AC","name":"init","timestamp":4701567.501597},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +1ms
  pw:protocol ◀ RECV {"method":"Runtime.executionContextsCleared","params":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"method":"Page.frameNavigated","params":{"frame":{"id":"446E7EBD9BB35E285820A86DF721DDB6","loaderId":"C5816F03256D284C280E3F2D68AA54AC","url":"http://localhost:8907/empty.html","domainAndRegistry":"","securityOrigin":"http://localhost:8907","securityOriginDetails":{"isLocalhost":true},"mimeType":"text/html","adFrameStatus":{"adFrameType":"none"},"secureContextType":"SecureLocalhost","crossOriginIsolatedContextType":"NotIsolated","gatedAPIFeatures":[]},"type":"Navigation"},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"method":"Network.policyUpdated","params":{},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +8ms
  pw:protocol ◀ RECV {"method":"Network.dataReceived","params":{"requestId":"C5816F03256D284C280E3F2D68AA54AC","timestamp":4701567.502938,"dataLength":53,"encodedDataLength":0},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"method":"Network.requestWillBeSent","params":{"requestId":"30024.2","loaderId":"C5816F03256D284C280E3F2D68AA54AC","documentURL":"http://localhost:8907/empty.html","request":{"url":"http://localhost:8907/script.js","method":"GET","headers":{"sec-ch-ua-platform":"\"Windows\"","Referer":"http://localhost:8907/empty.html","User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/143.0.0.0 Safari/537.36","sec-ch-ua":"\"Chromium\";v=\"143\", \"Not A(Brand\";v=\"24\"","Accept-Language":"en-US","sec-ch-ua-mobile":"?0"},"mixedContentType":"none","initialPriority":"High","referrerPolicy":"strict-origin-when-cross-origin","isSameSite":true},"timestamp":4701567.503722,"wallTime":1759742339.275742,"initiator":{"type":"parser","url":"http://localhost:8907/empty.html","lineNumber":0,"columnNumber":44},"redirectHasExtraInfo":false,"type":"Script","frameId":"446E7EBD9BB35E285820A86DF721DDB6","hasUserGesture":false},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +1ms
  pw:protocol ◀ RECV {"method":"Runtime.executionContextCreated","params":{"context":{"id":3,"origin":"http://localhost:8907","name":"","uniqueId":"-5302182308839801742.-8858525390651389165","auxData":{"isDefault":true,"type":"default","frameId":"446E7EBD9BB35E285820A86DF721DDB6"}}},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol ◀ RECV {"method":"Runtime.executionContextCreated","params":{"context":{"id":4,"origin":"","name":"__playwright_utility_world_page@590d646c08b8cce334ff020752fa2c46","uniqueId":"7368767395832026217.4410820529728796027","auxData":{"isDefault":false,"type":"isolated","frameId":"446E7EBD9BB35E285820A86DF721DDB6"}}},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +0ms
  pw:protocol SEND ► {"id":25,"method":"Runtime.evaluate","params":{"expression":"\n      (() => {\n        const module = {};\n        \nvar __commonJS = obj => {\n  let required = false;\n  let result;\n  return function __require() {\n    if (!required) {\n      required = true;\n      let fn;\n      for (const name in obj) { fn = obj[name]; break; }\n      const module = { exports: {} };\n      fn(module.exports, module);\n      result = module.exports;\n    }\n    return result;\n  }\n};\nvar __export = (target, all) => {for (var name in all) target[name] = all[name];};\nvar __toESM = mod => ({ ...mod, 'default': mod });\nvar __toCommonJS = mod => ({ ...mod, __esModule: true });\n\n\n// packages/injected/src/utilityScript.ts\nvar utilityScript_exports = {};\n__export(utilityScript_exports, {\n  UtilityScript: () => UtilityScript\n});\nmodule.exports = __toCommonJS(utilityScript_exports);\n\n// packages/playwright-core/src/utils/isomorphic/utilityScriptSerializers.ts\nfunction isRegExp(obj) {\n  try {\n    return obj instanceof RegExp || Object.prototype.toString.call(obj) === \"[object RegExp]\";\n  } catch (error) {\n    return false;\n  }\n}\nfunction isDate(obj) {\n  try {\n    return obj instanceof Date || Object.prototype.toString.call(obj) === \"[object Date]\";\n  } catch (error) {\n    return false;\n  }\n}\nfunction isURL(obj) {\n  try {\n    return obj instanceof URL || Object.prototype.toString.call(obj) === \"[object URL]\";\n  } catch (error) {\n    return false;\n  }\n}\nfunction isError(obj) {\n  var _a;\n  try {\n    return obj instanceof Error || obj && ((_a = Object.getPrototypeOf(obj)) == null ? void 0 : _a.name) === \"Error\";\n  } catch (error) {\n    return false;\n  }\n}\nfunction isTypedArray(obj, constructor) {\n  try {\n    return obj instanceof constructor || Object.prototype.toString.call(obj) === `[object ${constructor.name}]`;\n  } catch (error) {\n    return false;\n  }\n}\nvar typedArrayConstructors = {\n  i8: Int8Array,\n  ui8: Uint8Array,\n  ui8c: Uint8ClampedArray,\n  i16: Int16Array,\n  ui16: Uint16Array,\n  i32: Int32Array,\n  ui32: Uint32Array,\n  // TODO: add Float16Array once it's in baseline\n  f32: Float32Array,\n  f64: Float64Array,\n  bi64: BigInt64Array,\n  bui64: BigUint64Array\n};\nfunction typedArrayToBase64(array) {\n  if (\"toBase64\" in array)\n    return array.toBase64();\n  const binary = Array.from(new Uint8Array(array.buffer, array.byteOffset, array.byteLength)).map((b) => String.fromCharCode(b)).join(\"\");\n  return btoa(binary);\n}\nfunction base64ToTypedArray(base64, TypedArrayConstructor) {\n  const binary = atob(base64);\n  const bytes = new Uint8Array(binary.length);\n  for (let i = 0; i < binary.length; i++)\n    bytes[i] = binary.charCodeAt(i);\n  return new TypedArrayConstructor(bytes.buffer);\n}\nfunction parseEvaluationResultValue(value, handles = [], refs = /* @__PURE__ */ new Map()) {\n  if (Object.is(value, void 0))\n    return void 0;\n  if (typeof value === \"object\" && value) {\n    if (\"ref\" in value)\n      return refs.get(value.ref);\n    if (\"v\" in value) {\n      if (value.v === \"undefined\")\n        return void 0;\n      if (value.v === \"null\")\n        return null;\n      if (value.v === \"NaN\")\n        return NaN;\n      if (value.v === \"Infinity\")\n        return Infinity;\n      if (value.v === \"-Infinity\")\n        return -Infinity;\n      if (value.v === \"-0\")\n        return -0;\n      return void 0;\n    }\n    if (\"d\" in value) {\n      return new Date(value.d);\n    }\n    if (\"u\" in value)\n      return new URL(value.u);\n    if (\"bi\" in value)\n      return BigInt(value.bi);\n    if (\"e\" in value) {\n      const error = new Error(value.e.m);\n      error.name = value.e.n;\n      error.stack = value.e.s;\n      return error;\n    }\n    if (\"r\" in value)\n      return new RegExp(value.r.p, value.r.f);\n    if (\"a\" in value) {\n      const result = [];\n      refs.set(value.id, result);\n      for (const a of value.a)\n        result.push(parseEvaluationResultValue(a, handles, refs));\n      return result;\n    }\n    if (\"o\" in value) {\n      const result = {};\n      refs.set(value.id, result);\n      for (const { k, v } of value.o) {\n        if (k === \"__proto__\")\n          continue;\n        result[k] = parseEvaluationResultValue(v, handles, refs);\n      }\n      return result;\n    }\n    if (\"h\" in value)\n      return handles[value.h];\n    if (\"ta\" in value)\n      return base64ToTypedArray(value.ta.b, typedArrayConstructors[value.ta.k]);\n  }\n  return value;\n}\nfunction serializeAsCallArgument(value, handleSerializer) {\n  return serialize(value, handleSerializer, { visited: /* @__PURE__ */ new Map(), lastId: 0 });\n}\nfunction serialize(value, handleSerializer, visitorInfo) {\n  if (value && typeof value === \"object\") {\n    if (typeof globalThis.Window === \"function\" && value instanceof globalThis.Window)\n      return \"ref: <Window>\";\n    if (typeof globalThis.Document === \"function\" && value instanceof globalThis.Document)\n      return \"ref: <Document>\";\n    if (typeof globalThis.Node === \"function\" && value instanceof globalThis.Node)\n      return \"ref: <Node>\";\n  }\n  return innerSerialize(value, handleSerializer, visitorInfo);\n}\nfunction innerSerialize(value, handleSerializer, visitorInfo) {\n  var _a;\n  const result = handleSerializer(value);\n  if (\"fallThrough\" in result)\n    value = result.fallThrough;\n  else\n    return result;\n  if (typeof value === \"symbol\")\n    return { v: \"undefined\" };\n  if (Object.is(value, void 0))\n    return { v: \"undefined\" };\n  if (Object.is(value, null))\n    return { v: \"null\" };\n  if (Object.is(value, NaN))\n    return { v: \"NaN\" };\n  if (Object.is(value, Infinity))\n    return { v: \"Infinity\" };\n  if (Object.is(value, -Infinity))\n    return { v: \"-Infinity\" };\n  if (Object.is(value, -0))\n    return { v: \"-0\" };\n  if (typeof value === \"boolean\")\n    return value;\n  if (typeof value === \"number\")\n    return value;\n  if (typeof value === \"string\")\n    return value;\n  if (typeof value === \"bigint\")\n    return { bi: value.toString() };\n  if (isError(value)) {\n    let stack;\n    if ((_a = value.stack) == null ? void 0 : _a.startsWith(value.name + \": \" + value.message)) {\n      stack = value.stack;\n    } else {\n      stack = `${value.name}: ${value.message}\n${value.stack}`;\n    }\n    return { e: { n: value.name, m: value.message, s: stack } };\n  }\n  if (isDate(value))\n    return { d: value.toJSON() };\n  if (isURL(value))\n    return { u: value.toJSON() };\n  if (isRegExp(value))\n    return { r: { p: value.source, f: value.flags } };\n  for (const [k, ctor] of Object.entries(typedArrayConstructors)) {\n    if (isTypedArray(value, ctor))\n      return { ta: { b: typedArrayToBase64(value), k } };\n  }\n  const id = visitorInfo.visited.get(value);\n  if (id)\n    return { ref: id };\n  if (Array.isArray(value)) {\n    const a = [];\n    const id2 = ++visitorInfo.lastId;\n    visitorInfo.visited.set(value, id2);\n    for (let i = 0; i < value.length; ++i)\n      a.push(serialize(value[i], handleSerializer, visitorInfo));\n    return { a, id: id2 };\n  }\n  if (typeof value === \"object\") {\n    const o = [];\n    const id2 = ++visitorInfo.lastId;\n    visitorInfo.visited.set(value, id2);\n    for (const name of Object.keys(value)) {\n      let item;\n      try {\n        item = value[name];\n      } catch (e) {\n        continue;\n      }\n      if (name === \"toJSON\" && typeof item === \"function\")\n        o.push({ k: name, v: { o: [], id: 0 } });\n      else\n        o.push({ k: name, v: serialize(item, handleSerializer, visitorInfo) });\n    }\n    let jsonWrapper;\n    try {\n      if (o.length === 0 && value.toJSON && typeof value.toJSON === \"function\")\n        jsonWrapper = { value: value.toJSON() };\n    } catch (e) {\n    }\n    if (jsonWrapper)\n      return innerSerialize(jsonWrapper.value, handleSerializer, visitorInfo);\n    return { o, id: id2 };\n  }\n}\n\n// packages/injected/src/utilityScript.ts\nvar UtilityScript = class {\n  constructor(global, isUnderTest) {\n    var _a, _b, _c, _d, _e, _f, _g, _h;\n    this.global = global;\n    this.isUnderTest = isUnderTest;\n    if (global.__pwClock) {\n      this.builtins = global.__pwClock.builtins;\n    } else {\n      this.builtins = {\n        setTimeout: (_a = global.setTimeout) == null ? void 0 : _a.bind(global),\n        clearTimeout: (_b = global.clearTimeout) == null ? void 0 : _b.bind(global),\n        setInterval: (_c = global.setInterval) == null ? void 0 : _c.bind(global),\n        clearInterval: (_d = global.clearInterval) == null ? void 0 : _d.bind(global),\n        requestAnimationFrame: (_e = global.requestAnimationFrame) == null ? void 0 : _e.bind(global),\n        cancelAnimationFrame: (_f = global.cancelAnimationFrame) == null ? void 0 : _f.bind(global),\n        requestIdleCallback: (_g = global.requestIdleCallback) == null ? void 0 : _g.bind(global),\n        cancelIdleCallback: (_h = global.cancelIdleCallback) == null ? void 0 : _h.bind(global),\n        performance: global.performance,\n        Intl: global.Intl,\n        Date: global.Date\n      };\n    }\n    if (this.isUnderTest)\n      global.builtins = this.builtins;\n  }\n  evaluate(isFunction, returnByValue, expression, argCount, ...argsAndHandles) {\n    const args = argsAndHandles.slice(0, argCount);\n    const handles = argsAndHandles.slice(argCount);\n    const parameters = [];\n    for (let i = 0; i < args.length; i++)\n      parameters[i] = parseEvaluationResultValue(args[i], handles);\n    let result = this.global.eval(expression);\n    if (isFunction === true) {\n      result = result(...parameters);\n    } else if (isFunction === false) {\n      result = result;\n    } else {\n      if (typeof result === \"function\")\n        result = result(...parameters);\n    }\n    return returnByValue ? this._promiseAwareJsonValueNoThrow(result) : result;\n  }\n  jsonValue(returnByValue, value) {\n    if (value === void 0)\n      return void 0;\n    return serializeAsCallArgument(value, (value2) => ({ fallThrough: value2 }));\n  }\n  _promiseAwareJsonValueNoThrow(value) {\n    const safeJson = (value2) => {\n      try {\n        return this.jsonValue(true, value2);\n      } catch (e) {\n        return void 0;\n      }\n    };\n    if (value && typeof value === \"object\" && typeof value.then === \"function\") {\n      return (async () => {\n        const promiseValue = await value;\n        return safeJson(promiseValue);\n      })();\n    }\n    return safeJson(value);\n  }\n};\n\n        return new (module.exports.UtilityScript())(globalThis, true);\n      })();","contextId":4},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +1ms
  pw:protocol ◀ RECV {"method":"Runtime.executionContextCreated","params":{"context":{"id":5,"origin":"://","name":"__playwright_utility_world_page@590d646c08b8cce334ff020752fa2c46","uniqueId":"-6417349146996727970.4242642306799352281","auxData":{"isDefault":false,"type":"isolated","frameId":"446E7EBD9BB35E285820A86DF721DDB6"}}},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +3ms
  pw:protocol ◀ RECV {"method":"Network.loadingFinished","params":{"requestId":"C5816F03256D284C280E3F2D68AA54AC","timestamp":4701567.49726,"encodedDataLength":201},"sessionId":"6FE3A51109E8390B5A8D763E282A0911"} +1ms

dgozman avatar Oct 06 '25 09:10 dgozman

Interestingly, this test does the same, but for some reason does not report an extra context: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/web_tests/inspector-protocol/page/add-script-to-evaluate-in-world.js.

dgozman avatar Oct 06 '25 09:10 dgozman

Upstream issue: https://issues.chromium.org/u/1/issues/452663032 Upstream test: https://chromium-review.googlesource.com/c/chromium/src/+/7011807 Upstream meta-issue for RenderDocument: https://issues.chromium.org/u/1/issues/40615943?pli=1

dgozman avatar Oct 17 '25 13:10 dgozman