This repository has been archived by the owner on Jan 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Add core to inject k6 object into window #1007
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3cf3de1
to
ef03900
Compare
In some cases we want to pass on information to other apps to allow them to infer who or what is performing requests against a website. For now we're exposing an empty object, but we hope to extend the object with meta data that will be useful for other apps that have been instrumented on the website.
This test will evaluate and return the value. It should be an empty object and not null.
ef03900
to
6f5222b
Compare
inancgumus
reviewed
Aug 31, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me overall, and I'm excited about this feature! 😊
I do have a few points for us to chat about. Also, it might be helpful to include some comments in the code to clarify the role of k6ObjScript
.
Co-authored-by: İnanç Gümüş <[email protected]>
We're renaming this since this file will embed scripts other than web vital scripts.
To be consistent with how we work with other injected scripts, the k6 object is being moved to its own js file. This also helps us avoid working with globals. It's worth noting that the k6 object will need to be mutable at some stage to add test specific unique metadata in the future. Resolves: #1007 (comment)
This commit now works with the new k6 object file instead of the global k6 object file. Resolves: #1007 (comment)
inancgumus
approved these changes
Aug 31, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job, thanks!
ka3de
approved these changes
Aug 31, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👏
ankur22
added a commit
that referenced
this pull request
Aug 31, 2023
To be consistent with how we work with other injected scripts, the k6 object is being moved to its own js file. This also helps us avoid working with globals. It's worth noting that the k6 object will need to be mutable at some stage to add test specific unique metadata in the future. Resolves: #1007 (comment)
3 tasks
inancgumus
added a commit
that referenced
this pull request
Aug 31, 2023
After having a discussion, we decided to make this parallel. See the related discussion here: #1007 (comment)
inancgumus
added a commit
that referenced
this pull request
Aug 31, 2023
After having a discussion, we decided to make this parallel. See the related discussion here: #1007 (comment)
inancgumus
added a commit
that referenced
this pull request
Aug 31, 2023
After having a discussion, we decided to make this parallel. See the related discussion here: #1007 (comment)
inancgumus
added a commit
that referenced
this pull request
Aug 31, 2023
After having a discussion, we decided to make this parallel. See the related discussion here: #1007 (comment)
inancgumus
added a commit
that referenced
this pull request
Aug 31, 2023
After having a discussion, we decided to make this parallel. See the related discussion here: #1007 (comment)
This was referenced Aug 31, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
The change injects
window.k6 = {};
into all browser contexts and subsequentpage
s that are created.Why?
In some cases we want to pass information to other apps to allow them to infer who is performing requests against a website. For now we're exposing an empty object, but we hope to extend the object with meta data that will be useful for other apps that have been instrumented on the website.
Test
To test this change you can run the following k6 script, which will give you enough time to go into the chrome dev tools console and type in
window.k6
which should return an empty object ({}
).Checklist
Closes: #1017