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
Fix PushManager in ephemeral sessions
https://bugs.webkit.org/show_bug.cgi?id=241934 Reviewed by Geoffrey Garen. PushManager does not behave correctly when invoked in an ephemeral session. For instance: - PushManager.subscribe and PushManager.getSubscription fail with an AbortError. - PushManager.permissionState returns the persistent session's notification permissions for the given origin. This patch makes PushManager in ephemeral sessions behave as if a user denied notification permissions for all origins (which users can already do in persistent sessions via the appropriate checkbox). This also prevents these APIs from being used to detect private browsing mode. * LayoutTests/http/tests/push-api/permissions-ephemeral-expected.txt: Added. * LayoutTests/http/tests/push-api/permissions-ephemeral.html: Added. * LayoutTests/http/tests/push-api/resources/subscribe-tests.js * LayoutTests/http/tests/push-api/resources/subscribe-worker.js * LayoutTests/platform/gtk/TestExpectations: * LayoutTests/platform/ios/TestExpectations: * LayoutTests/platform/mac-wk1/TestExpectations: * LayoutTests/platform/win/TestExpectations: * Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.cpp: (WebKit::NetworkNotificationManager::getPushSubscription): (WebKit::NetworkNotificationManager::getPushPermissionState): * Source/WebKit/WebProcess/WebCoreSupport/WebNotificationClient.cpp: (WebKit::WebNotificationClient::requestPermission): (WebKit::WebNotificationClient::checkPermission): Canonical link: https://commits.webkit.org/251831@main
- Loading branch information
Showing
10 changed files
with
100 additions
and
30 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,8 @@ | ||
PASS: service worker permissionState was denied | ||
PASS: document permissionState was denied | ||
PASS: service worker subscribe was error: NotAllowedError | ||
PASS: document subscribe without user gesture was error: NotAllowedError | ||
PASS: document subscribe with user gesture was error: NotAllowedError | ||
PASS: document getSubscription was false | ||
PASS: service worker getSubscription was false | ||
|
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,33 @@ | ||
<!-- webkit-test-runner [ useEphemeralSession=true ] --> | ||
<html> | ||
<head> | ||
<script src="resources/push-api-test-pre.js"></script> | ||
<script src="resources/subscribe-tests.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
// Even if the UIProcess has granted permissions for notifications for a regular session, | ||
// they should not apply to this ephemeral session. | ||
if (window.testRunner) | ||
testRunner.grantWebNotificationPermission(window.origin); | ||
|
||
navigator.serviceWorker.register("resources/subscribe-worker.js", { }).then(async (registration) => { | ||
try { | ||
await waitForState(registration.installing, "activated"); | ||
await testServiceWorkerPermissionState(registration, 'denied'); | ||
await testDocumentPermissionState(registration, 'denied'); | ||
await testServiceWorkerSubscribe(registration, 'NotAllowedError'); | ||
await testDocumentSubscribeWithoutUserGesture(registration, 'NotAllowedError'); | ||
await testDocumentSubscribeWithUserGesture(registration, 'NotAllowedError'); | ||
await testDocumentGetSubscription(registration, false); | ||
await testServiceWorkerGetSubscription(registration, false); | ||
} catch (e) { | ||
log(`FAIL: unexpected exception ${e}`); | ||
} finally { | ||
await registration.unregister(); | ||
finishPushAPITest(); | ||
} | ||
}); | ||
</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