Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 6d27093d068a866cc0f2948e561882d1f2d8039b
https://github.com/WebKit/WebKit/commit/6d27093d068a866cc0f2948e561882d1f2d8039b
Author: Timothy Hatcher <[email protected]>
Date: 2024-04-08 (Mon, 08 Apr 2024)
Changed paths:
M Source/WebCore/en.lproj/Localizable.strings
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtension.h
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtension.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionController.mm
Log Message:
-----------
Add support for background preferred_environment in Web Extensions.
https://webkit.org/b/272244
rdar://problem/125988233
Reviewed by Brian Weinstein.
Add support for extensions declaring a `preferred_environment` in the
`background` entry.
The `preferred_environment` key can be a string or an array of strings. When an
array is
used, the browser will prefer the first one it supports.
"background": {
"preferred_environment": [ "service_worker", "document" ],
"scripts": [ "script1.js", "script2.js" ]
}
If no environments are specified or supported, then we fallback to the previous
handling of
the `scripts`, `page` or `service_worker` keys (in that order) for backwards
compatibility.
This allows cross-browser extensions to have a single manifest that works in
multiple
browsers. Chrome plans to only support service workers going forward, but
Safari and
Firefox plan to support pages and service workers, and extension might prefer a
document
environment over a service worker in Safari and Firefox.
This also adds support for a `_generated_service_worker.js` script that works
with normal
scripts or modules based on the `scripts` and `type` keys if
`preferred_environment`
is `service_worker`.
WECG discussion here: https://github.com/w3c/webextensions/issues/282
* Source/WebCore/en.lproj/Localizable.strings: Updated.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm:
(WebKit::WebExtension::resourceStringForPath): Support
_generated_service_worker.js.
(WebKit::WebExtension::resourceDataForPath): Ditto.
(WebKit::WebExtension::backgroundContentUsesModules): Use renamed
m_backgroundContentUsesModules.
(WebKit::WebExtension::backgroundContentIsServiceWorker): Use new
m_backgroundContentEnvironment.
(WebKit::WebExtension::backgroundContentPath): Support
_generated_service_worker.js.
(WebKit::WebExtension::generatedBackgroundContent): Generate the service worker
script.
(WebKit::WebExtension::populateBackgroundPropertiesIfNeeded): Handle
preferred_environment.
* Source/WebKit/UIProcess/Extensions/WebExtension.h: Added
m_backgroundContentEnvironment and renamed
m_backgroundPageUsesModules to m_backgroundContentUsesModules.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtension.mm:
(TestWebKitAPI::TEST(WKWebExtension, BackgroundPreferredEnvironmentParsing)):
Added.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionController.mm:
(TestWebKitAPI::TEST(WKWebExtensionController,
BackgroundWithServiceWorkerPreferredEnvironment)): Added.
(TestWebKitAPI::TEST(WKWebExtensionController,
BackgroundWithPageDocumentPreferredEnvironment)): Added.
(TestWebKitAPI::TEST(WKWebExtensionController,
BackgroundWithScriptsDocumentPreferredEnvironment)): Added.
(TestWebKitAPI::TEST(WKWebExtensionController,
BackgroundWithMultipleDocumentModuleScripts)): Added.
(TestWebKitAPI::TEST(WKWebExtensionController,
BackgroundWithMultipleServiceWorkerScripts)): Added.
(TestWebKitAPI::TEST(WKWebExtensionController,
BackgroundWithMultipleServiceWorkerModuleScripts)): Added.
Canonical link: https://commits.webkit.org/277228@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