[webkit-changes] [WebKit/WebKit] bc22aa: Add stricter type checking to the Web Extension co...
Timothy Hatcher
noreply at github.com
Mon Sep 11 16:14:06 PDT 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: bc22aaaf81abef67e13f40d895cf7e51653be094
https://github.com/WebKit/WebKit/commit/bc22aaaf81abef67e13f40d895cf7e51653be094
Author: Timothy Hatcher <timothy at apple.com>
Date: 2023-09-11 (Mon, 11 Sep 2023)
Changed paths:
M Source/WebKit/Shared/Extensions/WebExtensionUtilities.h
M Source/WebKit/Shared/Extensions/WebExtensionUtilities.mm
M Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIAlarmsCocoa.mm
M Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIPermissionsCocoa.mm
M Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPITabsCocoa.mm
M Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWindowsCocoa.mm
M Source/WebKit/WebProcess/Extensions/Bindings/Scripts/CodeGeneratorExtensions.pm
M Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebNavigationURLFilter.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIAlarms.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIPermissions.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPITabs.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWindows.mm
Log Message:
-----------
Add stricter type checking to the Web Extension code generator.
https://webkit.org/b/261386
rdar://problem/115255883
Reviewed by Brian Weinstein.
* Have the code generator do strict type checks per argument now that the argument handling
is simplified and easier to add those checks. This aligns with Chrome and Firefox type checks.
* Simplified validateDictionary to not take optionalKeys, this reduces the number of static
NSSets we have for each API. Now only the dictionary of types is required for most APIs.
* Tweak the wording to not say "string value" and "number value", to be just "string" and "number".
* Have _WKWebExtensionWebNavigationURLFilter use the new toErrorString and validateObject functions,
which was missed in my earlier error message refactoring.
* Source/WebKit/Shared/Extensions/WebExtensionUtilities.h:
* Source/WebKit/Shared/Extensions/WebExtensionUtilities.mm:
(WebKit::classToClassString): Changed "string value" and "number value", to be just "string" and "number".
(WebKit::validateDictionary): Dropped optionalKeys, and generate it from the types and required set.
(WebKit::validateObject): Added an ASSERT.
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIAlarmsCocoa.mm:
(WebKit::WebExtensionAPIAlarms::createAlarm): Removed optionalKeys.
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIPermissionsCocoa.mm:
(WebKit::WebExtensionAPIPermissions::parseDetailsDictionary): Removed optionalKeys.
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPITabsCocoa.mm:
(WebKit::WebExtensionAPITabs::parseTabCreateOptions): Removed optionalKeys.
(WebKit::WebExtensionAPITabs::parseTabUpdateOptions): Removed optionalKeys.
(WebKit::WebExtensionAPITabs::parseTabQueryOptions): Removed optionalKeys.
(WebKit::WebExtensionAPITabs::reload): Removed optionalKeys.
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWindowsCocoa.mm:
(WebKit::WebExtensionAPIWindows::parsePopulateTabs): Removed optionalKeys.
(WebKit::WebExtensionAPIWindows::parseWindowTypesFilter): Removed optionalKeys.
(WebKit::WebExtensionAPIWindows::parseWindowCreateOptions): Removed optionalKeys.
(WebKit::WebExtensionAPIWindows::parseWindowUpdateOptions): Removed optionalKeys.
* Source/WebKit/WebProcess/Extensions/Bindings/Scripts/CodeGeneratorExtensions.pm:
(_generateImplementationFile): Added calls to _installArgumentTypeExceptions for arguments.
(_installArgumentTypeExceptions): Added.
(_javaScriptTypeCondition): Only allow null and undefined when the argument is optional. This matches Chrome and Firefox.
(_platformTypeVariableDeclaration): Drop condition for numbers since _installArgumentTypeExceptions handles it now.
* Source/WebKit/WebProcess/Extensions/Cocoa/_WKWebExtensionWebNavigationURLFilter.mm:
(-[_WKWebExtensionWebNavigationURLPredicate initWithTypeString:value:outErrorMessage:]): Use validateObject and toErrorString.
(-[_WKWebExtensionWebNavigationURLFilter initWithDictionary:outErrorMessage:]): Drop urlOptionalKeys.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIAlarms.mm:
(TestWebKitAPI::TEST): Updated error string expectations.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIPermissions.mm:
(TestWebKitAPI::TEST): Updated error string expectations.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPITabs.mm:
(TestWebKitAPI::TEST): Updated error string expectations. Added back some error checks that work again with generator changes.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWebNavigation.mm:
(TestWebKitAPI::TEST): Updated error string expectations.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIWindows.mm:
(TestWebKitAPI::TEST): Updated error string expectations.
Canonical link: https://commits.webkit.org/267883@main
More information about the webkit-changes
mailing list