Skip to content

Commit 97c14e4

Browse files
committed
docs for setExecutionContext
1 parent 3ea234d commit 97c14e4

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/scripting.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,24 @@ example: setEventName loadWebmail
550550
551551
<event name> - Name to use for the event about to occur (in resulting log files)
552552
```
553+
#### `setExecutionContext`
554+
Sets the execution context (main document, iframes, etc) for any subsequent `exec` or `execAndWait` commands to run against. It accepts either the origin or ID of the execution context.
555+
556+
For example, if you navigate to a URL and there is an iframe that loads content form `https://cdpn.io`, you could have the script run in the iframe context by using the `setExecutionContext`.
557+
558+
You can reset the execution context by using the command without a match.
559+
560+
Browser support: Chrome, Edge
561+
562+
```markup
563+
usage: setExecutionContext <execution context ID or origin>
564+
example: setExecutionContext origin=https://cdpn.io
565+
566+
full example:
567+
navigate https://codepen.io/juno_okyo/pen/yOjaEZ
568+
setExecutionContext origin=https://cdpn.io
569+
execAndWait document.getElementById('name-input').value = 'Bob'; fetch('https://cdpn.io/blank.html');
570+
```
553571

554572
#### `setLocation`
555573
Specifies a geolocation override position.

0 commit comments

Comments
 (0)