mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
1 line
6.9 KiB
JavaScript
1 line
6.9 KiB
JavaScript
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[55215],{3905:(e,t,n)=>{n.d(t,{Zo:()=>u,kt:()=>d});var a=n(67294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function p(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},o=Object.keys(e);for(a=0;a<o.length;a++)n=o[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++)n=o[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var i=a.createContext({}),c=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):p(p({},t),e)),n},u=function(e){var t=c(e.components);return a.createElement(i.Provider,{value:t},e.children)},s={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},m=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,o=e.originalType,i=e.parentName,u=l(e,["components","mdxType","originalType","parentName"]),m=c(n),d=r,x=m["".concat(i,".").concat(d)]||m[d]||s[d]||o;return n?a.createElement(x,p(p({ref:t},u),{},{components:n})):a.createElement(x,p({ref:t},u))}));function d(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var o=n.length,p=new Array(o);p[0]=m;var l={};for(var i in t)hasOwnProperty.call(t,i)&&(l[i]=t[i]);l.originalType=e,l.mdxType="string"==typeof e?e:r,p[1]=l;for(var c=2;c<o;c++)p[c]=n[c];return a.createElement.apply(null,p)}return a.createElement.apply(null,n)}m.displayName="MDXCreateElement"},14831:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>p,default:()=>s,frontMatter:()=>o,metadata:()=>l,toc:()=>c});var a=n(87462),r=(n(67294),n(3905));const o={sidebar_label:"ExecutionContext"},p="ExecutionContext class",l={unversionedId:"api/puppeteer.executioncontext",id:"api/puppeteer.executioncontext",title:"ExecutionContext class",description:"Warning: This API is now obsolete.",source:"@site/../docs/api/puppeteer.executioncontext.md",sourceDirName:"api",slug:"/api/puppeteer.executioncontext",permalink:"/next/api/puppeteer.executioncontext",draft:!1,tags:[],version:"current",frontMatter:{sidebar_label:"ExecutionContext"},sidebar:"sidebar",previous:{title:"ExecutionContext.frame",permalink:"/next/api/puppeteer.executioncontext.frame"},next:{title:"ExecutionContext.queryObjects",permalink:"/next/api/puppeteer.executioncontext.queryobjects"}},i={},c=[{value:"Remarks",id:"remarks",level:2},{value:"Example",id:"example",level:2},{value:"Methods",id:"methods",level:2}],u={toc:c};function s(e){let{components:t,...n}=e;return(0,r.kt)("wrapper",(0,a.Z)({},u,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h1",{id:"executioncontext-class"},"ExecutionContext class"),(0,r.kt)("blockquote",null,(0,r.kt)("p",{parentName:"blockquote"},"Warning: This API is now obsolete."),(0,r.kt)("p",{parentName:"blockquote"},"Do not use directly."),(0,r.kt)("p",{parentName:"blockquote"},"Represents a context for JavaScript execution.")),(0,r.kt)("p",null,(0,r.kt)("strong",{parentName:"p"},"Signature:")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-typescript"},"export declare class ExecutionContext\n")),(0,r.kt)("h2",{id:"remarks"},"Remarks"),(0,r.kt)("p",null,"Besides pages, execution contexts can be found in ",(0,r.kt)("a",{parentName:"p",href:"/next/api/puppeteer.webworker"},"workers"),"."),(0,r.kt)("p",null,"The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the ",(0,r.kt)("inlineCode",{parentName:"p"},"ExecutionContext")," class."),(0,r.kt)("h2",{id:"example"},"Example"),(0,r.kt)("p",null,"A ",(0,r.kt)("a",{parentName:"p",href:"/next/api/puppeteer.page"},"Page")," can have several execution contexts:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},"Each ",(0,r.kt)("a",{parentName:"li",href:"/next/api/puppeteer.frame"},"Frame")," of a ",(0,r.kt)("a",{parentName:"li",href:"/next/api/puppeteer.page"},"page"),' has a "default" execution context that is always created after frame is attached to DOM. This context is returned by the ',(0,r.kt)("a",{parentName:"li",href:"/next/api/puppeteer.frame.executioncontext"},"Frame.executionContext()")," method. - Each ",(0,r.kt)("a",{parentName:"li",href:"https://developer.chrome.com/extensions"},"Chrome extensions")," creates additional execution contexts to isolate their code.")),(0,r.kt)("h2",{id:"methods"},"Methods"),(0,r.kt)("table",null,(0,r.kt)("thead",{parentName:"table"},(0,r.kt)("tr",{parentName:"thead"},(0,r.kt)("th",{parentName:"tr",align:null},"Method"),(0,r.kt)("th",{parentName:"tr",align:null},"Modifiers"),(0,r.kt)("th",{parentName:"tr",align:null},"Description"))),(0,r.kt)("tbody",{parentName:"table"},(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("a",{parentName:"td",href:"/next/api/puppeteer.executioncontext.evaluate"},"evaluate(pageFunction, args)")),(0,r.kt)("td",{parentName:"tr",align:null}),(0,r.kt)("td",{parentName:"tr",align:null},"Evaluates the given function.")),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("a",{parentName:"td",href:"/next/api/puppeteer.executioncontext.evaluatehandle"},"evaluateHandle(pageFunction, args)")),(0,r.kt)("td",{parentName:"tr",align:null}),(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("p",null,"Evaluates the given function."),(0,r.kt)("p",null,"Unlike ",(0,r.kt)("a",{parentName:"td",href:"/next/api/puppeteer.executioncontext.evaluate"},"evaluate"),", this method returns a handle to the result of the function."),(0,r.kt)("p",null,"This method may be better suited if the object cannot be serialized (e.g. ",(0,r.kt)("code",null,"Map"),") and requires further manipulation."))),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("a",{parentName:"td",href:"/next/api/puppeteer.executioncontext.frame"},"frame()")),(0,r.kt)("td",{parentName:"tr",align:null}),(0,r.kt)("td",{parentName:"tr",align:null})),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("a",{parentName:"td",href:"/next/api/puppeteer.executioncontext.queryobjects"},"queryObjects(prototypeHandle)")),(0,r.kt)("td",{parentName:"tr",align:null}),(0,r.kt)("td",{parentName:"tr",align:null},"Iterates through the JavaScript heap and finds all the objects with the given prototype.")))))}s.isMDXComponent=!0}}]); |