[Web Inspector] Add Testing guide for Inspector layout tests#149
Merged
burg merged 1 commit intoWebKit:mainfrom Apr 3, 2026
Merged
[Web Inspector] Add Testing guide for Inspector layout tests#149burg merged 1 commit intoWebKit:mainfrom
burg merged 1 commit intoWebKit:mainfrom
Conversation
the-chenergy
reviewed
Apr 2, 2026
| suite.addTestCase({ | ||
| name: "EvaluateExpression", | ||
| async test() { | ||
| let response = await RuntimeAgent.evaluate("2 + 3"); |
Member
There was a problem hiding this comment.
Suggested change
| let response = await RuntimeAgent.evaluate("2 + 3"); | |
| let response = await WI.mainTarget.RuntimeAgent.evaluate("2 + 3"); |
According to this FIXME, using the agent directly without a target is deprecated, especially now with site isolation engineering in mind. Let's keep our suggestions in the recommended format
stwrt
approved these changes
Apr 2, 2026
| let event = await InspectorProtocol.awaitEvent({event: "Debugger.scriptParsed"}); | ||
|
|
||
| // addEventListener / removeEventListener for persistent listeners | ||
| InspectorProtocol.addEventListener("Network.requestWillBeSent", handler); |
Contributor
There was a problem hiding this comment.
You could always mention ProtocolTest.pass("passing");
the-chenergy
reviewed
Apr 2, 2026
|
|
||
| Tests under `http/tests/site-isolation/inspector/` verify inspector behavior with cross-process iframes. Key patterns: | ||
|
|
||
| - **Cross-origin iframes** use `localhost` vs `127.0.0.1` (both served by the test HTTP server) |
Member
There was a problem hiding this comment.
Worth pointing out that 127.0.0.1 is the default origin (as in tests in http/tests start with that as the origin)
Reviewed by Brandon Stewart. Port and modernize the WebInspectorTests wiki page from trac.webkit.org. Covers writing and running Web Inspector layout tests: - Tutorial walkthrough (Your First Test) - Two harness types (frontend vs protocol tests) - Async test patterns with protocol agents - Testing with page content (evaluateInPage, Promise.all pattern) - Protocol test API (InspectorProtocol.awaitCommand/awaitEvent) - Test suite and test case lifecycle (setup/teardown, timeouts) - Full assertion API reference table - Helper scripts and TestPage.registerInitializer - Site isolation test patterns (cross-origin targets, StableIdMap) - Writing deterministic output - Debugging failing tests - Common patterns (parameterized tests, event verification) All examples derived from actual passing tests in the WebKit tree.
1cbf29d to
86d045a
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Port and modernize the WebInspectorTests wiki page from trac.webkit.org. Covers writing and running Web Inspector layout tests:
All examples derived from actual passing tests in the WebKit tree.