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

webworker: the scope between the extension vs. test code is not shared #938

Closed

Conversation

nkomonen-amazon
Copy link

@nkomonen-amazon nkomonen-amazon commented Jan 12, 2024

In a node.js context, when running unit tests the context is shared between the extension and unit test code. This means that the state created in the extension context is the same as what the unit tests are using.

For example, defining a variable in the global scope of the extension code will be accessible by the unit tests.


But in a web extension, when running with webworkers this context is separate between the extension and unit tests. They only share the globalThis object from what I could find.


This commit displays these differences by showing in the unit tests that there is a disconnect in globally defined values in a web context.

In the helloword-web-sample I've added tests that show how global values are not shared between the extension and test executions, though globalThis is.

Similarily, in the helloworld-test-sample the tests show how a global value IS in the same context between the extension and test.

…not shared

In a node.js context, when running unit tests the context is shared between the
extension and unit test code. This means that the state created in the extension
context is the same as what the unit tests are using.

For example, defining a variable in the global scope of the extension code
will be accessible by the unit tests.

---

But in a web extension, when running with webworkers this context is separate
between the extension and unit tests. They only share the globalThis object from
what I could find.

---

This commit displays these differences by showing in the unit tests that there
is a disconnect in globally defined objects in a web context.

Signed-off-by: nkomonen <nkomonen@amazon.com>
@Juscc53

This comment was marked as spam.

@Flex0089

This comment was marked as spam.

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