@@ -319,7 +319,7 @@ func (f *Frame) document() (*ElementHandle, error) {
319
319
return nil , fmt .Errorf ("frame document: cannot evaluate in main execution context: %w" , err )
320
320
}
321
321
if result == nil {
322
- return nil , fmt . Errorf ("frame document: evaluate result is nil in main execution context: %w" , err )
322
+ return nil , errors . New ("frame document: evaluate result is nil in main execution context" )
323
323
}
324
324
325
325
f .documentHandle = result .(* ElementHandle )
@@ -1249,3 +1249,46 @@ func (f *Frame) WaitForTimeout(timeout int64) {
1249
1249
case <- time .After (time .Duration (timeout ) * time .Millisecond ):
1250
1250
}
1251
1251
}
1252
+
1253
+ // frameExecutionContext represents a JS execution context that belongs to Frame.
1254
+ type frameExecutionContext interface {
1255
+ // adoptBackendNodeId adopts specified backend node into this execution
1256
+ // context from another execution context.
1257
+ adoptBackendNodeId (backendNodeID cdp.BackendNodeID ) (* ElementHandle , error )
1258
+
1259
+ // adoptElementHandle adopts the specified element handle into this
1260
+ // execution context from another execution context.
1261
+ adoptElementHandle (elementHandle * ElementHandle ) (* ElementHandle , error )
1262
+
1263
+ // evaluate will evaluate provided callable within this execution
1264
+ // context and return by value or handle.
1265
+ evaluate (
1266
+ apiCtx context.Context ,
1267
+ forceCallable bool , returnByValue bool ,
1268
+ pageFunc goja.Value , args ... goja.Value ,
1269
+ ) (res interface {}, err error )
1270
+
1271
+ // getInjectedScript returns a JS handle to the injected script of helper
1272
+ // functions.
1273
+ getInjectedScript (apiCtx context.Context ) (api.JSHandle , error )
1274
+
1275
+ // Evaluate will evaluate provided page function within this execution
1276
+ // context.
1277
+ Evaluate (
1278
+ apiCtx context.Context ,
1279
+ pageFunc goja.Value , args ... goja.Value ,
1280
+ ) (interface {}, error )
1281
+
1282
+ // EvaluateHandle will evaluate provided page function within this
1283
+ // execution context.
1284
+ EvaluateHandle (
1285
+ apiCtx context.Context ,
1286
+ pageFunc goja.Value , args ... goja.Value ,
1287
+ ) (api.JSHandle , error )
1288
+
1289
+ // Frame returns the frame that this execution context belongs to.
1290
+ Frame () * Frame
1291
+
1292
+ // id returns the CDP runtime ID of this execution context.
1293
+ ID () runtime.ExecutionContextID
1294
+ }
0 commit comments