Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: e01a74ffaab3600aea2da3667edd8dd0da20a9e8
https://github.com/WebKit/WebKit/commit/e01a74ffaab3600aea2da3667edd8dd0da20a9e8
Author: Qianlang Chen <[email protected]>
Date: 2026-05-14 (Thu, 14 May 2026)
Changed paths:
M
LayoutTests/inspector/unit-tests/test-harness-expect-functions-expected.txt
M LayoutTests/inspector/unit-tests/test-harness-expect-functions.html
M Source/WebInspectorUI/UserInterface/Test/TestHarness.js
Log Message:
-----------
Web Inspector: `TestHarness.expect(Not)Null` should account for `undefined`
https://bugs.webkit.org/show_bug.cgi?id=314687
Reviewed by Devin Rousso.
We recently wasted significant debugging time on a bot failure where a
protocol agent was undefined rather than null, but expectNotNull for
that agent happily passed while subsequent test cases crashed.
expectNotNull(value) was implemented as `value !== null` (strict), which
means expectNotNull(undefined) silently passes. This should've never
been the intent: callers use expectNotNull to assert they have a real
value, and undefined is just as invalid as null in that context.
Change both checks to use loose equality:
- expectNotNull: `value != null` (fails for both null and undefined)
- expectNull: `value == null` (passes for both null and undefined)
This makes them behave like "has a value" / "has no value" checks, which
matches how they're used in practice throughout the test suite.
This should not regress any existing tests. One caveat is expectNull now
becomes more permissive (accepts undefined in addition to null). In case
someone specifically needs to assert `=== null` and not undefined,
they'll need to use expectEqual(value, null), though that scenario
shouldn't arise often in practice.
* Source/WebInspectorUI/UserInterface/Test/TestHarness.js:
(TestHarness.prototype.expectNull):
(TestHarness.prototype.expectNotNull):
Linter disallows loose equality (== and !=), so we explicitly compare
against both null and undefined to achieve the same result.
* LayoutTests/inspector/unit-tests/test-harness-expect-functions-expected.txt:
* LayoutTests/inspector/unit-tests/test-harness-expect-functions.html:
Canonical link: https://commits.webkit.org/313273@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications