Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 5ca13e0fb7c00fa541cfcfe33fbe3024bdb45212
https://github.com/WebKit/WebKit/commit/5ca13e0fb7c00fa541cfcfe33fbe3024bdb45212
Author: Elijah Sawyers <[email protected]>
Date: 2025-02-18 (Tue, 18 Feb 2025)
Changed paths:
M
Source/WebKit/UIProcess/API/Cocoa/WKWebExtensionControllerDelegatePrivate.h
M
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionControllerAPITestCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionController.h
M Source/WebKit/UIProcess/Extensions/WebExtensionController.messages.in
M Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPITestCocoa.mm
M Source/WebKit/WebProcess/Extensions/API/WebExtensionAPITest.h
M Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPITest.idl
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPITest.mm
M Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.h
M Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.mm
Log Message:
-----------
Implement browser.test.addTest to support web platform testing of extensions
https://bugs.webkit.org/show_bug.cgi?id=287566
rdar://144706714
Reviewed by Timothy Hatcher.
This patch adds a new API for running tests that are represented by promises.
If any browser.test assertion within the test method fails, we reject the
promise and notify fail; otherwise, we resolve the promise and notify pass.
It's worth noting that tests are ran in the order in which they're added with
the addTest method.
* Source/WebKit/UIProcess/API/Cocoa/WKWebExtensionControllerDelegatePrivate.h:
Define the delegate methods that are called when the following messages are
received...
* Source/WebKit/UIProcess/Extensions/WebExtensionController.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionController.messages.in:
*
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionControllerAPITestCocoa.mm:
(WebKit::WebExtensionController::testAdded):
(WebKit::WebExtensionController::testStarted):
...the two new messages are:
the testAdded message, which is sent when browser.test.addTest is called,
and the testStarted message, which is called when the next test is removed
from the queue and has started executing.
* Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPITest.idl:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPITestCocoa.mm:
(WebKit::WebExtensionAPITest::assertTrue):
(WebKit::WebExtensionAPITest::assertDeepEq):
(WebKit::WebExtensionAPITest::assertEquals):
(WebKit::WebExtensionAPITest::assertEq):
(WebKit::WebExtensionAPITest::addTest):
(WebKit::WebExtensionAPITest::startNextTest):
(WebKit::assertEquals): Deleted.
Implement the logic for browser.test.addTest, which just maintains a queue of
test methods to run and resolves/rejects the promise based on whether or not
any assertions are hit during the execution.
* Source/WebKit/WebProcess/Extensions/API/WebExtensionAPITest.h:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPITest.mm:
(TestWebKitAPI::TEST(WKWebExtensionAPITest, AddTestThatPasses)):
(TestWebKitAPI::TEST(WKWebExtensionAPITest, AddTestThatFails)):
Add new tests to ensure that passing and failing tests resolve and reject,
respectively. Additionally, check that the new delegate methods are called
as expected.
* Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.h:
* Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.mm:
(-[TestWebExtensionManager initForExtension:extensionControllerConfiguration:]):
(-[TestWebExtensionManager
_webExtensionController:recordTestAssertionResult:withMessage:andSourceURL:lineNumber:]):
(-[TestWebExtensionManager
_webExtensionController:recordTestEqualityResult:expectedValue:actualValue:withMessage:andSourceURL:lineNumber:]):
(-[TestWebExtensionManager
_webExtensionController:recordTestAddedWithTestName:andSourceURL:lineNumber:]):
(-[TestWebExtensionManager
_webExtensionController:recordTestStartedWithTestName:andSourceURL:lineNumber:]):
(-[TestWebExtensionManager
_webExtensionController:recordTestFinishedWithResult:message:andSourceURL:lineNumber:]):
Throw away test events if we're currently executing a test that was added
with the new browser.test.addTest API. We don't care what the result of
those assertions are, just that the promise resolves/rejects as expected.
Canonical link: https://commits.webkit.org/290558@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes