-
Notifications
You must be signed in to change notification settings - Fork 41
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
Move taskqueue to mapping layer #1069
Commits on Oct 23, 2023
-
Move TaskQueue to mapping layer
Removes the goja TaskQueue from the page implementation and instead places it in the mapping layer by wrapping the handler in a function that will execute it in the local TaskQueue.
Configuration menu - View commit details
-
Copy full SHA for c89a240 - Browse repository at this point
Copy the full SHA c89a240View commit details -
Modify consoleEventHandlerFunc to not return error
It's no longer required to return an error from the handler, as this is handled in the TaskQueue wrapper in the mapping layer. This change also refactors the test so that: 1. it no longer returns an error from the handler; 2. the event loop has been removed since the taskqueue has been removed from the business logic, making the test simpler to understand with less orchestration.
Configuration menu - View commit details
-
Copy full SHA for 24fab41 - Browse repository at this point
Copy the full SHA 24fab41View commit details -
Move TaskQueue to moduleVU scope
With this change we only use the TaskQueue from the main thread, as it's required to avoid race conditions with goja. Unfortunately this implies an explicit close call for the TaskQueue that we are wrapping in the page.close() call in the mapping layer.
Configuration menu - View commit details
-
Copy full SHA for 7a3f047 - Browse repository at this point
Copy the full SHA 7a3f047View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8f2bc52 - Browse repository at this point
Copy the full SHA 8f2bc52View commit details -
Refactor taskqueue for waitForEvent
To enable us to work with the task queue outside of the business logic and allow the setup of the predicate function within the task queue we need to: 1. Parse the options in the mapping layer. 2. Create a func that can call the predicate function from within a taskqueue. 3. We need to wait for the taskqueue call to complete and return the response back to the caller. 4. Change the browserContext API within the go code.
Configuration menu - View commit details
-
Copy full SHA for f7bddc2 - Browse repository at this point
Copy the full SHA f7bddc2View commit details -
Refactor browserContext.waitForEvent tests
This refactors the tests so that it matches the new signature for waitForEvent, which is that it takes in a predicate method and a timeout. The predicate method will now be wrapped and added to a taskqueue in the mapping layer which means we do not need to work with the event loop in the test itself. Since the options are now parsed in the mapping layer, this also simplifies how we pass the predicate and timeout arguments to waitForEvent.
Configuration menu - View commit details
-
Copy full SHA for 8bf40ed - Browse repository at this point
Copy the full SHA 8bf40edView commit details -
Configuration menu - View commit details
-
Copy full SHA for 646b45b - Browse repository at this point
Copy the full SHA 646b45bView commit details -
Refactor internal waitForEvent method
This is just cleaning up the arguments so that they are grouped in a better way, as well as shortening the line length to avoid the linter issue.
Configuration menu - View commit details
-
Copy full SHA for caf9ad4 - Browse repository at this point
Copy the full SHA caf9ad4View commit details -
Add thread safety to the taskqueue
Since waitForEvent is a promisified function, we need to make the taskqueue thread safe.
Configuration menu - View commit details
-
Copy full SHA for 9180b7b - Browse repository at this point
Copy the full SHA 9180b7bView commit details -
Fix taskqueue so it is per page
The taskqueue wasn't working when it was one per vu since it became difficult to understand exactly when it was best to close the taskqueue if there were multiple pages. This change now creates a taskqueue per page, but the taskqueues is stored in the vu rather than in the page struct itself, which helps ensure that the taskqueue is kept away from the page business logic.
Configuration menu - View commit details
-
Copy full SHA for fffd720 - Browse repository at this point
Copy the full SHA fffd720View commit details -
This will be used to register, retrieve and close the taskqueues which is required by the page.on and browserContext.waitForEvent APIs.
Configuration menu - View commit details
-
Copy full SHA for 90a2125 - Browse repository at this point
Copy the full SHA 90a2125View commit details -
Configuration menu - View commit details
-
Copy full SHA for a8901f5 - Browse repository at this point
Copy the full SHA a8901f5View commit details -
Configuration menu - View commit details
-
Copy full SHA for ba1f3e8 - Browse repository at this point
Copy the full SHA ba1f3e8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 82a6544 - Browse repository at this point
Copy the full SHA 82a6544View commit details -
Configuration menu - View commit details
-
Copy full SHA for 08b9c00 - Browse repository at this point
Copy the full SHA 08b9c00View commit details -
Since a require.True will FailNow in the current goroutine and not the root goroutine of the test, it's best to pass an error back to assert on in the test's root goroutine.
Configuration menu - View commit details
-
Copy full SHA for 1af173f - Browse repository at this point
Copy the full SHA 1af173fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 468d84c - Browse repository at this point
Copy the full SHA 468d84cView commit details