Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Add support for PermissionStatus.onchange
https://bugs.webkit.org/show_bug.cgi?id=244633 Reviewed by Chris Dumez and Youenn Fablet. The PermissionStatus object returned by Permissions::query should have an onchange event as specified by the Permissions API spec. This patch adds this by adding a permissionChanged function to the WKWebViewPrivate SPI which a client can call to indicate to WebKit that a permission state has changed. WebPermissionController will then query for the specified permission state and dispatch an onchange event to the PermissionStatus object if the permission state has indeed changed. The permissionChanged function is a class/static function, so the client needs to call it only once and WebKit will look through all of the web processes and find the ones where the permission has changed. Currently, the onchange event is only supported in Window contexts. A future patch will add support for Worker contexts. An API test and Layout test were added to test this. * LayoutTests/http/tests/notifications/permission/permission-status-onchange-event-expected.txt: Added. * LayoutTests/http/tests/notifications/permission/permission-status-onchange-event.html: Added. * LayoutTests/imported/w3c/web-platform-tests/permissions/idlharness.any-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/permissions/idlharness.any.worker-expected.txt: * Source/WebCore/Headers.cmake: * Source/WebCore/Modules/permissions/PermissionController.h: * Source/WebCore/Modules/permissions/PermissionObserver.h: * Source/WebCore/Modules/permissions/PermissionStatus.h: * Source/WebCore/Modules/permissions/PermissionStatus.idl: * Source/WebCore/Modules/permissions/Permissions.cpp: (WebCore::Permissions::sourceFromContext): (WebCore::Permissions::toPermissionName): (WebCore::Permissions::query): (WebCore::sourceFromContext): Deleted. * Source/WebCore/Modules/permissions/Permissions.h: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebKit/CMakeLists.txt: * Source/WebKit/DerivedSources-input.xcfilelist: * Source/WebKit/DerivedSources-output.xcfilelist: * Source/WebKit/DerivedSources.make: * Source/WebKit/Sources.txt: * Source/WebKit/UIProcess/API/C/WKPage.cpp: (WKPagePermissionChanged): * Source/WebKit/UIProcess/API/C/WKPagePrivate.h: * Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm: (+[WKWebView _permissionChanged:forOrigin:]): * Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h: * Source/WebKit/UIProcess/WebPermissionControllerProxy.h: * Source/WebKit/UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::permissionChanged): (WebKit::WebProcessProxy::sendPermissionChanged): * Source/WebKit/UIProcess/WebProcessProxy.h: * Source/WebKit/WebKit.xcodeproj/project.pbxproj: * Source/WebKit/WebProcess/WebCoreSupport/WebPermissionController.cpp: (WebKit::WebPermissionController::create): (WebKit::WebPermissionController::WebPermissionController): (WebKit::WebPermissionController::~WebPermissionController): (WebKit::WebPermissionController::query): (WebKit::WebPermissionController::permissionChanged): * Source/WebKit/WebProcess/WebCoreSupport/WebPermissionController.h: * Source/WebKit/WebProcess/WebCoreSupport/WebPermissionController.messages.in: Copied from Source/WebCore/Modules/permissions/PermissionStatus.idl. * Source/WebKit/WebProcess/WebProcess.cpp: * Tools/TestWebKitAPI/Tests/WebKitCocoa/PermissionsAPI.mm: (-[PermissionChangedTestAPIMessageHandler userContentController:didReceiveScriptMessage:]): (-[PermissionChangedTestAPIUIDelegate _webView:queryPermission:forOrigin:completionHandler:]): (TestWebKitAPI::TEST): * Tools/WebKitTestRunner/TestController.cpp: (WTR::TestController::grantNotificationPermission): (WTR::TestController::denyNotificationPermission): Canonical link: https://commits.webkit.org/254193@main
- Loading branch information
1 parent
e347e3e
commit 7f531f3e0265f2d2722545e3600d39eb08242190
Showing
31 changed files
with
320 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
This test checks that the Permissions API on-change event works. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
No permission state is set | ||
PASS permissionStatusState is "prompt" | ||
Permission has been granted | ||
PASS permissionStatusState is "granted" | ||
PASS onChangeCalled became true | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="/resources/js-test-pre.js"></script> | ||
<script src="/resources/notifications-test-pre.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
|
||
description("This test checks that the Permissions API on-change event works.") | ||
|
||
jsTestIsAsync = true; | ||
|
||
debug("No permission state is set"); | ||
navigator.permissions.query({ name: "notifications" }).then((permissionStatus)=>{ | ||
permissionStatusState = permissionStatus.state; | ||
shouldBeEqualToString("permissionStatusState", "prompt"); | ||
|
||
onChangeCalled = false; | ||
permissionStatus.onchange = () => { | ||
permissionStatusState = permissionStatus.state; | ||
shouldBeEqualToString("permissionStatusState", "granted"); | ||
onChangeCalled = true; | ||
}; | ||
|
||
testRunner.grantWebNotificationPermission(testURL); | ||
debug("Permission has been granted"); | ||
shouldBecomeEqual("onChangeCalled", "true", () => { | ||
finishJSTest(); | ||
}); | ||
}); | ||
|
||
</script> | ||
<script src="/resources/js-test-post.js"></script> | ||
</body> | ||
</html> |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.