-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Each executed script has a different global scope #1798
Comments
Same problem here. In my case, I'm trying to inject code that I do not own: a UMD-formatted JavaScript file. It attaches its exported value to the A workaround: const workaroundSource = `(function(globalThis) {
${source};
)(window));`
driver.executeScript(workaroundSource);
|
mantoni
added a commit
to mantoni/mochify.js
that referenced
this issue
Sep 5, 2021
This works around an issue in the mozilla geckodriver: mozilla/geckodriver#1798
mantoni
added a commit
to mantoni/mochify.js
that referenced
this issue
Sep 6, 2021
This works around an issue in the mozilla geckodriver: mozilla/geckodriver#1798
mantoni
added a commit
to mochify-js/mochify
that referenced
this issue
Dec 24, 2023
This works around an issue in the mozilla geckodriver: mozilla/geckodriver#1798
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It appears that scripts executed through WebDriver are being executed in a different global scope than Firefox's main window. Not only that, it appears each script is executed in a different global scope from each other.
I am writing a cross-browser test suite, and this makes it very difficult to interact with JavaScript code loaded in the main browser window, since I can't rely on things like
array.constructor === Uint8Array
to be true in browser code for Uint8Arrays that I pass in through WebDriver.I believe that this goes against the W3C WebDriver spec: https://www.w3.org/TR/webdriver/#dfn-execute-a-function-body. The section "The rules to execute a function body are as follows" indicates that the global scope for script execution should be the same as the current browsing context's active document. Additionally, the test case below produces the expected output when ran against Chrome and Safari.
Let me know if there is a better place to report this.
System
Testcase
Expected output:
Actual output:
Stacktrace
No errors occur.
Trace-level log
geckodriver.log
The text was updated successfully, but these errors were encountered: