JavaScript Execution Context

Execution context refers to the environment in which the JavaScript code will be run. In GoLess, you can choose between two environments Active Tab and Background.

Active Tab

The workflow will insert the JS code in the active tab of the workflow. You can select this environment if you want to perform DOM manipulation or if you want to get the attribute or text from an element. However, keep in mind that it's not allowed to inject JS code for some websites because of Content Security Policy (CSP). It prevents the injection of 3rd party code. You can open the Chrome Dev Tools by pressing ctrl+shift+i; in the console tab and paste the following code to check if 3rd party code is allowed:


const script = document.createElement('script');
script.textContent = 'alert("Hello world!")';

If you see the following error, then 3rd party code can not be injected: Refused to execute inline script because it violates the following Content Security Policy directive...


The workflow will run your JS in a sandbox. So you can select this environment as the execution context if your code doesn't do anything related to DOM. Also, it doesn't require an active tab to work.

If you want to debug (for example, using the console.log method), you can find the output by opening the Chrome Devtools in the GoLess dashboard.

Last updated