PageSourceSearch

https://playwright.dev/assets/js/1a571de5.fbdbca32.js

js playwright.dev collected 2026-09-24 06:53:41 UTC 19,769 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkplaywright_dev=self.webpackChunkplaywright_dev||[]).push([["141"],{96874(e,r,n){n.r(r),n.d(r,{metadata:()=>s,default:()=>h,frontMatter:()=>i,contentTitle:()=>a,toc:()=>c,assets:()=>o});var s=JSON.parse('{"id":"api/class-worker","title":"Worker","description":"The Worker class represents a WebWorker. worker event is emitted on the page object to signal a worker creation. close event is emitted on the worker object when the worker is gone.","source":"@site/versioned_docs/version-stable/api/class-worker.mdx","sourceDirName":"api","slug":"/api/class-worker","permalink":"/docs/api/class-worker","draft":false,"unlisted":false,"tags":[],"version":"stable","frontMatter":{"id":"class-worker","title":"Worker"},"sidebar":"api","previous":{"title":"WebStorage","permalink":"/docs/api/class-webstorage"},"next":{"title":"APIResponseAssertions","permalink":"/docs/api/class-apiresponseassertions"}}'),t=n(74848),l=n(28453);n(13554),n(41647),n(83137);let i={id:"class-worker",title:"Worker"},a,o={},c=[{value:"Methods",id:"methods",level:2},{value:"evaluate",id:"worker-evaluate",level:3},{value:"evaluateHandle",id:"worker-evaluate-handle",level:3},{value:"url",id:"worker-url",level:3},{value:"waitForEvent",id:"worker-wait-for-event",level:3},{value:"Events",id:"events",level:2},{value:"on(&#39;close&#39;)",id:"worker-event-close",level:3},{value:"on(&#39;console&#39;)",id:"worker-event-console",level:3}];function d(e){let r={a:"a",code:"code",em:"em",h2:"h2",h3:"h3",hr:"hr",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,l.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(r.p,{children:["The Worker class represents a ",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API",children:"WebWorker"}),". ",(0,t.jsx)(r.code,{children:"worker"})," event is emitted on the page object to signal a worker creation. ",(0,t.jsx)(r.code,{children:"close"})," event is emitted on the worker object when the worker is gone."]}),"\n",(0,t.jsx)(r.pre,{children:(0,t.jsx)(r.code,{className:"language-js",children:"page.on('worker', worker => {\n  console.log('Worker created: ' + worker.url());\n  worker.on('close', worker => console.log('Worker destroyed: ' + worker.url()));\n});\n\nconsole.log('Current workers:');\nfor (const worker of page.workers())\n  console.log('  ' + worker.url());\n"})}),"\n",(0,t.jsx)(r.hr,{}),"\n",(0,t.jsx)(r.h2,{id:"methods",children:"Methods"}),"\n",(0,t.jsx)(r.h3,{id:"worker-evaluate",children:"evaluate"}),"\n",(0,t.jsx)("font",{size:"2",style:{position:"relative",top:"-20px"},children:"Added before v1.9"}),"\n",(0,t.jsx)("x-search",{children:"worker.evaluate"}),"\n",(0,t.jsxs)(r.p,{children:["Returns the return value of ",(0,t.jsx)(r.a,{href:"/docs/api/class-worker#worker-evaluate-option-expression",children:"pageFunction"}),"."]}),"\n",(0,t.jsxs)(r.p,{children:["If the function passed to the ",(0,t.jsx)(r.a,{href:"/docs/api/class-worker#worker-evaluate",children:"worker.evaluate()"})," returns a ",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise",title:"Promise",children:"Promise"}),", then ",(0,t.jsx)(r.a,{href:"/docs/api/class-worker#worker-evaluate",children:"worker.evaluate()"})," would wait for the promise to resolve and return its value."]}),"\n",(0,t.jsxs)(r.p,{children:["If the function passed to the ",(0,t.jsx)(r.a,{href:"/docs/api/class-worker#worker-evaluate",children:"worker.evaluate()"})," returns a non-",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Description",title:"Serializable",children:"Serializable"})," value, then ",(0,t.jsx)(r.a,{href:"/docs/api/class-worker#worker-evaluate",children:"worker.evaluate()"})," returns ",(0,t.jsx)(r.code,{children:"undefined"}),". Playwright also supports transferring some additional values that are not serializable by ",(0,t.jsx)(r.code,{children:"JSON"}),": ",(0,t.jsx)(r.code,{children:"-0"}),", ",(0,t.jsx)(r.code,{children:"NaN"}),", ",(0,t.jsx)(r.code,{children:"Infinity"}),", ",(0,t.jsx)(r.code,{children:"-Infinity"}),"."]}),"\n",(0,t.jsx)(r.p,{children:(0,t.jsx)(r.strong,{children:"Usage"})}),"\n",(0,t.jsx)(r.pre,{children:(0,t.jsx)(r.code,{className:"language-js",children:"await worker.evaluate(pageFunction);\nawait worker.evaluate(pageFunction, arg);\n"})}),"\n",(0,t.jsx)(r.p,{children:(0,t.jsx)(r.strong,{children:"Arguments"})}),"\n",(0,t.jsxs)(r.ul,{children:["\n",(0,t.jsxs)(r.li,{children:["\n",(0,t.jsxs)(r.p,{children:[(0,t.jsx)(r.code,{children:"pageFunction"})," ",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function",title:"Function",children:"function"})," | ",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type",title:"string",children:"string"}),(0,t.jsx)("a",{"aria-hidden":"true",tabIndex:"-1",class:"list-anchor-link",id:"worker-evaluate-option-expression"}),(0,t.jsx)("a",{href:"#worker-evaluate-option-expression",class:"list-anchor",children:"#"})]}),"\n",(0,t.jsx)(r.p,{children:"Function to be evaluated in the worker context."}),"\n"]}),"\n",(0,t.jsxs)(r.li,{children:["\n",(0,t.jsxs)(r.p,{children:[(0,t.jsx)(r.code,{children:"arg"})," ",(0,t.jsx)(r.a,{href:"/docs/evaluating#evaluation-argument",title:"EvaluationArgument",children:"EvaluationArgument"})," ",(0,t.jsx)(r.em,{children:"(optional)"}),(0,t.jsx)("a",{"aria-hidden":"true",tabIndex:"-1",class:"list-anchor-link",id:"worker-evaluate-option-arg"}),(0,t.jsx)("a",{href:"#worker-evaluate-option-arg",class:"list-anchor",children:"#"})]}),"\n",(0,t.jsxs)(r.p,{children:["Optional argument to pass to ",(0,t.jsx)(r.a,{href:"/docs/api/class-worker#worker-evaluate-option-expression",children:"pageFunction"}),"."]}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(r.p,{children:(0,t.jsx)(r.strong,{children:"Returns"})}),"\n",(0,t.jsxs)(r.ul,{children:["\n",(0,t.jsxs)(r.li,{children:[(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise",title:"Promise",children:"Promise"}),"<",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Description",title:"Serializable",children:"Serializable"}),">",(0,t.jsx)("a",{"aria-hidden":"true",tabIndex:"-1",class:"list-anchor-link",id:"worker-evaluate-return"}),(0,t.jsx)("a",{href:"#worker-evaluate-return",class:"list-anchor",children:"#"})]}),"\n"]}),"\n",(0,t.jsx)(r.hr,{}),"\n",(0,t.jsx)(r.h3,{id:"worker-evaluate-handle",children:"evaluateHandle"}),"\n",(0,t.jsx)("font",{size:"2",style:{position:"relative",top:"-20px"},children:"Added before v1.9"}),"\n",(0,t.jsx)("x-search",{children:"worker.evaluateHandle"}),"\n",(0,t.jsxs)(r.p,{children:["Returns the return value of ",(0,t.jsx)(r.a,{href:"/docs/api/class-worker#worker-evaluate-handle-option-expression",children:"pageFunction"}
1)," as a ",(0,t.jsx)(r.a,{href:"/docs/api/class-jshandle",title:"JSHandle",children:"JSHandle"}),"."]}),"\n",(0,t.jsxs)(r.p,{children:["The only difference between ",(0,t.jsx)(r.a,{href:"/docs/api/class-worker#worker-evaluate",children:"worker.evaluate()"})," and ",(0,t.jsx)(r.a,{href:"/docs/api/class-worker#worker-evaluate-handle",children:"worker.evaluateHandle()"})," is that ",(0,t.jsx)(r.a,{href:"/docs/api/class-worker#worker-evaluate-handle",children:"worker.evaluateHandle()"})," returns ",(0,t.jsx)(r.a,{href:"/docs/api/class-jshandle",title:"JSHandle",children:"JSHandle"}),"."]}),"\n",(0,t.jsxs)(r.p,{children:["If the function passed to the ",(0,t.jsx)(r.a,{href:"/docs/api/class-worker#worker-evaluate-handle",children:"worker.evaluateHandle()"})," returns a ",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise",title:"Promise",children:"Promise"}),", then ",(0,t.jsx)(r.a,{href:"/docs/api/class-worker#worker-evaluate-handle",children:"worker.evaluateHandle()"})," would wait for the promise to resolve and return its value."]}),"\n",(0,t.jsx)(r.p,{children:(0,t.jsx)(r.strong,{children:"Usage"})}),"\n",(0,t.jsx)(r.pre,{children:(0,t.jsx)(r.code,{className:"language-js",children:"await worker.evaluateHandle(pageFunction);\nawait worker.evaluateHandle(pageFunction, arg);\n"})}),"\n",(0,t.jsx)(r.p,{children:(0,t.jsx)(r.strong,{children:"Arguments"})}),"\n",(0,t.jsxs)(r.ul,{children:["\n",(0,t.jsxs)(r.li,{children:["\n",(0,t.jsxs)(r.p,{children:[(0,t.jsx)(r.code,{children:"pageFunction"})," ",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function",title:"Function",children:"function"})," | ",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type",title:"string",children:"string"}),(0,t.jsx)("a",{"aria-hidden":"true",tabIndex:"-1",class:"list-anchor-link",id:"worker-evaluate-handle-option-expression"}),(0,t.jsx)("a",{href:"#worker-evaluate-handle-option-expression",class:"list-anchor",children:"#"})]}),"\n",(0,t.jsx)(r.p,{children:"Function to be evaluated in the worker context."}),"\n"]}),"\n",(0,t.jsxs)(r.li,{children:["\n",(0,t.jsxs)(r.p,{children:[(0,t.jsx)(r.code,{children:"arg"})," ",(0,t.jsx)(r.a,{href:"/docs/evaluating#evaluation-argument",title:"EvaluationArgument",children:"EvaluationArgument"})," ",(0,t.jsx)(r.em,{children:"(optional)"}),(0,t.jsx)("a",{"aria-hidden":"true",tabIndex:"-1",class:"list-anchor-link",id:"worker-evaluate-handle-option-arg"}),(0,t.jsx)("a",{href:"#worker-evaluate-handle-option-arg",class:"list-anchor",children:"#"})]}),"\n",(0,t.jsxs)(r.p,{children:["Optional argument to pass to ",(0,t.jsx)(r.a,{href:"/docs/api/class-worker#worker-evaluate-handle-option-expression",children:"pageFunction"}),"."]}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(r.p,{children:(0,t.jsx)(r.strong,{children:"Returns"})}),"\n",(0,t.jsxs)(r.ul,{children:["\n",(0,t.jsxs)(r.li,{children:[(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise",title:"Promise",children:"Promise"}
1),"<",(0,t.jsx)(r.a,{href:"/docs/api/class-jshandle",title:"JSHandle",children:"JSHandle"}),">",(0,t.jsx)("a",{"aria-hidden":"true",tabIndex:"-1",class:"list-anchor-link",id:"worker-evaluate-handle-return"}),(0,t.jsx)("a",{href:"#worker-evaluate-handle-return",class:"list-anchor",children:"#"})]}),"\n"]}),"\n",(0,t.jsx)(r.hr,{}),"\n",(0,t.jsx)(r.h3,{id:"worker-url",children:"url"}),"\n",(0,t.jsx)("font",{size:"2",style:{position:"relative",top:"-20px"},children:"Added before v1.9"}),"\n",(0,t.jsx)("x-search",{children:"worker.url"}),"\n",(0,t.jsx)(r.p,{children:(0,t.jsx)(r.strong,{children:"Usage"})}),"\n",(0,t.jsx)(r.pre,{children:(0,t.jsx)(r.code,{className:"language-js",children:"worker.url();\n"})}),"\n",(0,t.jsx)(r.p,{children:(0,t.jsx)(r.strong,{children:"Returns"})}),"\n",(0,t.jsxs)(r.ul,{children:["\n",(0,t.jsxs)(r.li,{children:[(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type",title:"string",children:"string"}),(0,t.jsx)("a",{"aria-hidden":"true",tabIndex:"-1",class:"list-anchor-link",id:"worker-url-return"}),(0,t.jsx)("a",{href:"#worker-url-return",class:"list-anchor",children:"#"})]}),"\n"]}),"\n",(0,t.jsx)(r.hr,{}),"\n",(0,t.jsx)(r.h3,{id:"worker-wait-for-event",children:"waitForEvent"}),"\n",(0,t.jsx)("font",{size:"2",style:{position:"relative",top:"-20px"},children:"Added in: v1.57"}),"\n",(0,t.jsx)("x-search",{children:"worker.waitForEvent"}),"\n",(0,t.jsx)(r.p,{children:"Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy value. Will throw an error if the page is closed before the event is fired. Returns the event data value."}),"\n",(0,t.jsx)(r.p,{children:(0,t.jsx)(r.strong,{children:"Usage"})}),"\n",(0,t.jsx)(r.pre,{children:(0,t.jsx)(r.code,{className:"language-js",children:"// Start waiting for download before clicking. Note no await.\nconst consolePromise = worker.waitForEvent('console');\nawait worker.evaluate('console.log(42)');\nconst consoleMessage = await consolePromise;\n"})}),"\n",(0,t.jsx)(r.p,{children:(0,t.jsx)(r.strong,{children:"Arguments"})}),"\n",(0,t.jsxs)(r.ul,{children:["\n",(0,t.jsxs)(r.li,{children:["\n",(0,t.jsxs)(r.p,{children:[(0,t.jsx)(r.code,{children:"event"})," ",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type",title:"string",children:"string"}),(0,t.jsx)("a",{"aria-hidden":"true",tabIndex:"-1",class:"list-anchor-link",id:"worker-wait-for-event-option-event"}),(0,t.jsx)("a",{href:"#worker-wait-for-event-option-event",class:"list-anchor",children:"#"})]}),"\n",(0,t.jsxs)(r.p,{children:["Event name, same one typically passed into ",(0,t.jsx)(r.code,{children:"*.on(event)"}),"."]}),"\n"]}),"\n",(0,t.jsxs)(r.li,{children:["\n",(0,t.jsxs)(r.p,{children:[(0,t.jsx)(r.code,{children:"optionsOrPredicate"})," ",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function",title:"Function",children:"function"})," | ",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object",title:"Object",children:"Object"})," ",(0,t.jsx)(r.em,{children:"(optional)"}),(0,t.jsx)("a",{"aria-hidden":"true",tabIndex:"-1",class:"list-anchor-link",id:"worker-wait-for-event-option-options-or-predicate"}),(0,t.jsx)("a",{href:"#worker-wait-for-event-option-options-or-predicate",class:"list-anchor",children:"#"})]}),"\n",(0,t.jsxs)(r.ul,{children:["\n",(0,t.jsxs)(r.li,{children:["\n",(0,t.jsxs)(r.p,{children:[(0,t.jsx)(r.code,{children:"predicate"})," ",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function",title:"Function",children:"function"})]}),"\n",(0,t.jsx)(r.p,{children:"Receives the event data and resolves to truthy value when the waiting should resolve."}),"\n"]}),"\n",(0,t.jsxs)(r.li,{children:["\n",(0,t.jsxs)(r.p,{children:[(0,t.jsx)(r.code,{children:"timeout"})," ",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type",title:"Number",children:"number"})," ",(0,t.jsx)(r.em,{children:"(optional)"})]}),"\n",(0,t.jsxs)(r.p,{children:["Maximum time to wait for in milliseconds. Defaults to ",(0,t.jsx)(r.code,{children:"0"})," - no timeout. The default value can be changed via ",(0,t.jsx)(r.code,{children:"actionTimeout"})," option in the config, or by using the ",(0,t.jsx)(r.a,{href:"/docs/api/class-browsercontext#browser-context-set-default-timeout",children:"browserContext.setDefaultTimeout()"})," or ",(0,t.jsx)(r.a,{href:"/docs/api/class-page#page-set-default-timeout",children:"page.setDefaultTimeout()"})," methods."]}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(r.p,{children:"Either a predicate that receives an event or an options object. Optional."}),"\n"]}),"\n",(0,t.jsxs)(r.li,{children:["\n",(0,t.jsxs)(r.p,{children:[(0,t.jsx)(r.code,{children:"options"})," ",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object",title:"Object",children:"Object"})," ",(0,t.jsx)(r.em,{children:"(optional)"})]}),"\n",(0,t.jsxs)(r.ul,{children:["\n",(0,t.jsxs)(r.li,{children:["\n",(0,t.jsxs)(r.p,{children:[(0,t.jsx)(r.code,{children:"predicate"})," ",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function",title:"Function",children:"function"})," ",(0,t.jsx)(r.em,{children:"(optional)"}),(0,t.jsx)("a",{"aria-hidden":"true",tabIndex:"-1",class:"list-anchor-link",id:"worker-wait-for-event-option-predicate"}),(0,t.jsx)("a",{href:"#worker-wait-for-event-option-predicate",class:"list-anchor",children:"#"})]}),"\n",(0,t.jsx)(r.p,{children:"Receives the event data and resolves to truthy value when the waiting should resolve."}),"\n"]}),"\n",(0,t.jsxs)(r.li,{children:["\n",(0,t.jsxs)(r.p,{children:[(0,t.jsx)(r.code,{children:"signal"})," ",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal",title:"AbortSignal",children:"AbortSignal"})," ",(0,t.jsx)(r.em,{children:"(optional)"})," ",(0,t.jsx)("font",{size:"2",children:"Added in: v1.62"}),(0,t.jsx)("a",{"aria-hidden":"true",tabIndex:"-1",class:"list-anchor-link",id:"worker-wait-for-event-option-signal"}),(0,t.jsx)("a",{href:"#worker-wait-for-event-option-signal",class:"list-anchor",children:"#"})]}),"\n",(0,t.jsxs)(r.p,{children:["Allows to cancel the waiting using an ",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal",children:(0,t.jsx)(r.code,{children:"AbortSignal"})}),". If the signal is aborted, the waiting will be aborted and the operation will throw an error. Note that providing a signal does not disable the default timeout, which can be changed using ",(0,t.jsx)(r.a,{href:"/docs/api/class-browsercontext#browser-context-set-default-timeout",children:"browserContext.setDefaultTimeout()"}),"; pass ",(0,t.jsx)(r.code,{children:"timeout: 0"})," to disable the timeout entirely."]}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(r.p,{children:(0,t.jsx)(r.strong,{children:"Returns"})}),"\n",(0,t.jsxs)(r.ul,{children:["\n",(0,t.jsxs)(r.li,{children:[(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise",title:"Promise",children:"Promise"}),"<",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object",title:"Object",children:"Object"}),">",(0,t.jsx)("a",{"aria-hidden":"true",tabIndex:"-1",class:"list-anchor-link",id:"worker-wait-for-event-return"}),(0,t.jsx)("a",{href:"#worker-wait-for-event-return",class:"list-anchor",children:"#"})]}),"\n"]}),"\n",(0,t.jsx)(r.hr,{}),"\n",(0,t.jsx)(r.h2,{id:"events",children:"Events"}),"\n",(0,t.jsx)(r.h3,{id:"worker-event-close",children:"on('close')"}),"\n",(0,t.jsx)("font",{size:"2",style:{position:"relative",top:"-20px"},children:"Added before v1.9"}),"\n",(0,t.jsx)("x-search",{children:"worker.on('close')"}),"\n",(0,t.jsxs)(r.p,{children:["Emitted when this dedicated ",(0,t.jsx)(r.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API",children:"WebWorker"})," is terminated."]}),"\n",(0,t.jsx)(r.p,{children:(0,t.jsx)(r.strong,{children:"Usage"})}),"\n",(0,t.jsx)(r.pre,{children:(0,t.jsx)(r.code,{className:"language-js",children:"worker.on('close', data => {});\n"})}),"\n",(0,t.jsx)(r.p,{children:(0,t.jsx)(r.strong,{children:"Event data"})}),"\n",(0,t.jsxs)(r.ul,{children:["\n",(0,t.jsx)(r.li,{children:(0,t.jsx)(r.a,{href:"/docs/api/class-worker",title:"Worker",children:"Worker"})}),"\n"]}),"\n",(0,t.jsx)(r.hr,{}),"\n",(0,t.jsx)(r.h3,{id:"worker-event-console",children:"on('console')"}),"\n",(0,t.jsx)("font",{size:"2",style:{position:"relative",top:"-20px"},children:"Added in: v1.57"}),"\n",(0,t.jsx)("x-search",{children:"worker.on('console')"}),"\n",(0,t.jsxs)(r.p,{children:["Emitted when JavaScript within the worker calls one of console API methods, e.g. ",(0,t.jsx)(r.code,{children:"console.log"})," or ",(0,t.jsx)(r.code,{children:"console.dir"}),"."]}),"\n",(0,t.jsx)(r.p,{children:(0,t.jsx)(r.strong,{children:"Usage"})}),"\n",(0,t.jsx)(r.pre,{children:(0,t.jsx)(r.code,{className:"language-js",children:"worker.on('console', data => {});\n"})}),"\n",(0,t.jsx)(r.p,{children:(0,t.jsx)(r.strong,{children:"Event data"})}),"\n",(0,t.jsxs)(r.ul,{children:["\n",(0,t.jsx)(r.li,{children:(0,t.jsx)(r.a,{href:"/docs/api/class-consolemessage",title:"ConsoleMessage",children:"ConsoleMessage"})}),"\n"]})]})}function h(e={}){let{wrapper:r}={...(0,l.R)(),...e.components};return r?(0,t.jsx)(r,{...e,children:(0,t.jsx)(d,{...e})}):d(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.