Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for running a script in an arbitrary frame context #584

Merged
merged 1 commit into from
Dec 1, 2022

Conversation

pmeenan
Copy link
Contributor

@pmeenan pmeenan commented Nov 30, 2022

This enables cross-origin frame scripting for Chromium browsers (might work on iOS as well, haven't tested there yet).

It collects the available execution contexts from Chromium browsers and adds it to the page data json as execution_contexts:

"execution_contexts": [
    {
        "id": 2,
        "origin": "http:\/\/127.0.0.1:8888",
        "name": ""
    },
    {
        "id": 3,
        "origin": "https:\/\/codepen.io",
        "name": ""
    },
    {
        "id": 4,
        "origin": "https:\/\/cdpn.io",
        "name": ""
    }
],

It also adds a new script command, setExecutionContext that lets you match one of the available contexts by id, origin or name (though name is always blank as best as I can tell) and any future exec commands will target that context (and it can be reset to the main document by not passing a match).

navigate	https://codepen.io/juno_okyo/pen/yOjaEZ
setExecutionContext	origin=https://cdpn.io
execAndWait	document.getElementById('name-input').value = 'Bob'; fetch('https://cdpn.io/blank.html');

@pmeenan pmeenan requested review from tkadlec and scottjehl November 30, 2022 21:35
Copy link
Contributor

@tkadlec tkadlec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome!!

@tkadlec tkadlec merged commit 6101894 into catchpoint:master Dec 1, 2022
@pmeenan pmeenan deleted the frames branch December 5, 2022 19:58
@manpreet-compro
Copy link

Hi @pmeenan
Thanks for adding this option, highly useful. However I am not able to reset the execution context to main after performing some action inside iframe. Could you pls provide an example of that. Thanks!

@pmeenan
Copy link
Contributor Author

pmeenan commented May 17, 2023

@manpreet-compro As best as I can tell from the code, using setexecutioncontext with no parameters should result in the execution context being reset to the default.

@manpreet-compro
Copy link

@pmeenan Thanks for quick reply. I tried that already but that is not working as expected. Not sure what is the issue, will post details on a separate thread.

@manpreet-compro
Copy link

I have added details on #616. I am looking at the code in case I am able to locate the cause of this. If someone can help, that will be much appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants