<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[277420] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/277420">277420</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2021-05-12 22:02:45 -0700 (Wed, 12 May 2021)</dd>
</dl>
<h3>Log Message</h3>
<pre>Notification.requestPermission() should return a Promise
https://bugs.webkit.org/show_bug.cgi?id=225712
Reviewed by Darin Adler.
LayoutTests/imported/w3c:
Drop manual test that should not have been imported from WPT. The test happened to be using Notification.requestPermission()
internally.
* web-platform-tests/service-workers/service-worker/fetch-event-within-sw-manual.https-expected.txt: Removed.
* web-platform-tests/service-workers/service-worker/fetch-event-within-sw-manual.https.html: Removed.
Source/WebCore:
Notification.requestPermission() should return a Promise as per the specification:
- https://notifications.spec.whatwg.org/#notification
Both Firefox and Chrome already support this.
Test: http/tests/notifications/request-with-promise.html
* Modules/notifications/Notification.cpp:
(WebCore::Notification::requestPermission):
* Modules/notifications/Notification.h:
* Modules/notifications/Notification.idl:
* Modules/notifications/NotificationClient.h:
Source/WebKit:
Update code now that WebCore passes a CompletionHandler instead of a
NotificationPermissionCallback.
* WebProcess/Notifications/NotificationPermissionRequestManager.cpp:
(WebKit::NotificationPermissionRequestManager::~NotificationPermissionRequestManager):
(WebKit::NotificationPermissionRequestManager::startRequest):
* WebProcess/Notifications/NotificationPermissionRequestManager.h:
* WebProcess/WebCoreSupport/WebNotificationClient.cpp:
(WebKit::WebNotificationClient::requestPermission):
* WebProcess/WebCoreSupport/WebNotificationClient.h:
Source/WebKitLegacy/mac:
Update code now that WebCore passes a CompletionHandler instead of a
NotificationPermissionCallback.
* WebCoreSupport/WebNotificationClient.h:
* WebCoreSupport/WebNotificationClient.mm:
(WebNotificationClient::requestPermission):
(-[WebNotificationPolicyListener initWithCompletionHandler:]):
(-[WebNotificationPolicyListener allow]):
(-[WebNotificationPolicyListener deny]):
Source/WebKitLegacy/win:
Update code now that WebCore passes a CompletionHandler instead of a
NotificationPermissionCallback.
* WebCoreSupport/WebDesktopNotificationsDelegate.cpp:
(WebDesktopNotificationsDelegate::requestPermission):
* WebCoreSupport/WebDesktopNotificationsDelegate.h:
LayoutTests:
* http/tests/notifications/notification-in-non-secure-context-expected.txt:
Rebaseline test now that we log an error message in the JS console when trying to call
Notification.requestPermission() in a non-secure context.
* http/tests/notifications/request-with-promise-expected.txt: Added.
* http/tests/notifications/request-with-promise.html: Added.
Add layout test coverage.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestsnotificationsnotificationinnonsecurecontextexpectedtxt">trunk/LayoutTests/http/tests/notifications/notification-in-non-secure-context-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesnotificationsNotificationcpp">trunk/Source/WebCore/Modules/notifications/Notification.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesnotificationsNotificationh">trunk/Source/WebCore/Modules/notifications/Notification.h</a></li>
<li><a href="#trunkSourceWebCoreModulesnotificationsNotificationidl">trunk/Source/WebCore/Modules/notifications/Notification.idl</a></li>
<li><a href="#trunkSourceWebCoreModulesnotificationsNotificationClienth">trunk/Source/WebCore/Modules/notifications/NotificationClient.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitWebProcessNotificationsNotificationPermissionRequestManagercpp">trunk/Source/WebKit/WebProcess/Notifications/NotificationPermissionRequestManager.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessNotificationsNotificationPermissionRequestManagerh">trunk/Source/WebKit/WebProcess/Notifications/NotificationPermissionRequestManager.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebCoreSupportWebNotificationClientcpp">trunk/Source/WebKit/WebProcess/WebCoreSupport/WebNotificationClient.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebCoreSupportWebNotificationClienth">trunk/Source/WebKit/WebProcess/WebCoreSupport/WebNotificationClient.h</a></li>
<li><a href="#trunkSourceWebKitLegacymacChangeLog">trunk/Source/WebKitLegacy/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitLegacymacWebCoreSupportWebNotificationClienth">trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebNotificationClient.h</a></li>
<li><a href="#trunkSourceWebKitLegacymacWebCoreSupportWebNotificationClientmm">trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebNotificationClient.mm</a></li>
<li><a href="#trunkSourceWebKitLegacywinChangeLog">trunk/Source/WebKitLegacy/win/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitLegacywinWebCoreSupportWebDesktopNotificationsDelegatecpp">trunk/Source/WebKitLegacy/win/WebCoreSupport/WebDesktopNotificationsDelegate.cpp</a></li>
<li><a href="#trunkSourceWebKitLegacywinWebCoreSupportWebDesktopNotificationsDelegateh">trunk/Source/WebKitLegacy/win/WebCoreSupport/WebDesktopNotificationsDelegate.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestsnotificationsrequestwithpromiseexpectedtxt">trunk/LayoutTests/http/tests/notifications/request-with-promise-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsnotificationsrequestwithpromisehtml">trunk/LayoutTests/http/tests/notifications/request-with-promise.html</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsserviceworkersserviceworkerfetcheventwithinswmanualhttpsexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw-manual.https-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsserviceworkersserviceworkerfetcheventwithinswmanualhttpshtml">trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw-manual.https.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/LayoutTests/ChangeLog 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2021-05-12 Chris Dumez <cdumez@apple.com>
+
+ Notification.requestPermission() should return a Promise
+ https://bugs.webkit.org/show_bug.cgi?id=225712
+
+ Reviewed by Darin Adler.
+
+ * http/tests/notifications/notification-in-non-secure-context-expected.txt:
+ Rebaseline test now that we log an error message in the JS console when trying to call
+ Notification.requestPermission() in a non-secure context.
+
+ * http/tests/notifications/request-with-promise-expected.txt: Added.
+ * http/tests/notifications/request-with-promise.html: Added.
+ Add layout test coverage.
+
</ins><span class="cx"> 2021-05-12 Diego Pino Garcia <dpino@igalia.com>
</span><span class="cx">
</span><span class="cx"> [GLIB] http/tests/security/contentSecurityPolicy/report-only-from-header.py is a flaky text failure
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsnotificationsnotificationinnonsecurecontextexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/notifications/notification-in-non-secure-context-expected.txt (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/notifications/notification-in-non-secure-context-expected.txt 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/LayoutTests/http/tests/notifications/notification-in-non-secure-context-expected.txt 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -1,3 +1,5 @@
</span><ins>+CONSOLE MESSAGE: The Notification permission may only be requested in a secure context.
+CONSOLE MESSAGE: The Notification permission may only be requested in a secure context.
</ins><span class="cx">
</span><span class="cx"> PASS Notification permission in insecure context
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsnotificationsrequestwithpromiseexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/notifications/request-with-promise-expected.txt (0 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/notifications/request-with-promise-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/notifications/request-with-promise-expected.txt 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+This tests Notification.permission's returned Promise
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Requesting permission with default permission
+PASS Notification.permission is "default"
+PASS permission is granted
+PASS Notification.permission is "granted"
+Requesting permission with non-default permission
+PASS permission is denied
+PASS Notification.permission is "denied"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsnotificationsrequestwithpromisehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/notifications/request-with-promise.html (0 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/notifications/request-with-promise.html (rev 0)
+++ trunk/LayoutTests/http/tests/notifications/request-with-promise.html 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -0,0 +1,34 @@
</span><ins>+<!DOCTYPE html>
+<script src="/js-test-resources/js-test.js"></script>
+<script>
+description("This tests Notification.permission's returned Promise");
+jsTestIsAsync = true;
+
+function step1() {
+ debug("Requesting permission with default permission");
+ shouldBeEqualToString("Notification.permission", "default");
+ Notification.requestPermission().then((permission) => {
+ if (permission == 'granted')
+ testPassed("permission is granted");
+ else
+ testFailed("permission should be granted, but is " + permission);
+ shouldBeEqualToString("Notification.permission", "granted");
+ setTimeout(step2, 0);
+ });
+}
+
+function step2() {
+ debug("Requesting permission with non-default permission");
+ testRunner.denyWebNotificationPermission(self.origin);
+ Notification.requestPermission().then((permission) => {
+ if (permission == 'denied')
+ testPassed("permission is denied");
+ else
+ testFailed("permission should be denied, but is " + permission);
+ shouldBeEqualToString("Notification.permission", "denied");
+ finishJSTest();
+ });
+}
+
+step1();
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2021-05-12 Chris Dumez <cdumez@apple.com>
+
+ Notification.requestPermission() should return a Promise
+ https://bugs.webkit.org/show_bug.cgi?id=225712
+
+ Reviewed by Darin Adler.
+
+ Drop manual test that should not have been imported from WPT. The test happened to be using Notification.requestPermission()
+ internally.
+
+ * web-platform-tests/service-workers/service-worker/fetch-event-within-sw-manual.https-expected.txt: Removed.
+ * web-platform-tests/service-workers/service-worker/fetch-event-within-sw-manual.https.html: Removed.
+
</ins><span class="cx"> 2021-05-12 Ziran Sun <zsun@igalia.com>
</span><span class="cx">
</span><span class="cx"> Wrong position for orthogonal positioned element with writing-mode: vertical-rl
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsserviceworkersserviceworkerfetcheventwithinswmanualhttpsexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw-manual.https-expected.txt (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw-manual.https-expected.txt 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw-manual.https-expected.txt 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -1,3 +0,0 @@
</span><del>-
-FAIL Notification requests intercepted both from window and SW undefined is not an object (evaluating 'Notification.requestPermission().then')
-
</del></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsserviceworkersserviceworkerfetcheventwithinswmanualhttpshtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw-manual.https.html (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw-manual.https.html 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw-manual.https.html 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -1,122 +0,0 @@
</span><del>-<!DOCTYPE html>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script src="/common/get-host-info.sub.js"></script>
-<script src="resources/test-helpers.sub.js"></script>
-<body>
-<script>
-const worker = 'resources/fetch-event-within-sw-worker.js';
-
-function wait(ms) {
- return new Promise(r => setTimeout(r, ms));
-}
-
-function reset() {
- for (const iframe of [...document.querySelectorAll('.test-iframe')]) {
- iframe.remove();
- }
- return navigator.serviceWorker.getRegistrations().then(registrations => {
- return Promise.all(registrations.map(r => r.unregister()));
- }).then(() => caches.keys()).then(cacheKeys => {
- return Promise.all(cacheKeys.map(c => caches.delete(c)));
- });
-}
-
-add_completion_callback(reset);
-
-function regReady(reg) {
- return new Promise((resolve, reject) => {
- if (reg.active) {
- resolve();
- return;
- }
- const nextWorker = reg.waiting || reg.installing;
-
- nextWorker.addEventListener('statechange', () => {
- if (nextWorker.state == 'redundant') {
- reject(Error(`Service worker failed to install`));
- return;
- }
- if (nextWorker.state == 'activated') {
- resolve();
- }
- });
- });
-}
-
-function getCookies() {
- return new Map(
- document.cookie
- .split(/;/g)
- .map(c => c.trim().split('=').map(s => s.trim()))
- );
-}
-
-function registerSwAndOpenFrame() {
- return reset().then(() => navigator.serviceWorker.register(worker, {scope: 'resources/'}))
- .then(reg => regReady(reg))
- .then(() => with_iframe('resources/simple.html'));
-}
-
-function raceBroadcastAndCookie(channel, cookie) {
- const initialCookie = getCookies().get(cookie);
- let done = false;
-
- return Promise.race([
- new Promise(resolve => {
- const bc = new BroadcastChannel(channel);
- bc.onmessage = () => {
- bc.close();
- resolve('broadcast');
- };
- }),
- (function checkCookie() {
- // Stop polling if the broadcast channel won
- if (done == true) return;
- if (getCookies().get(cookie) != initialCookie) return 'cookie';
-
- return wait(200).then(checkCookie);
- }())
- ]).then(val => {
- done = true;
- return val;
- });
-}
-
-promise_test(() => {
- return Notification.requestPermission().then(permission => {
- if (permission != "granted") {
- throw Error('You must allow notifications for this origin before running this test.');
- }
- return registerSwAndOpenFrame();
- }).then(iframe => {
- return Promise.resolve().then(() => {
- // In this test, the service worker will ping the 'icon-request' channel
- // if it intercepts a request for 'notification_icon.py'. If the request
- // reaches the server it sets the 'notification' cookie to the value given
- // in the URL. "raceBroadcastAndCookie" monitors both and returns which
- // happens first.
- const race = raceBroadcastAndCookie('icon-request', 'notification');
- const notification = new iframe.contentWindow.Notification('test', {
- icon: `notification_icon.py?set-cookie-notification=${Math.random()}`
- });
- notification.close();
-
- return race.then(winner => {
- assert_equals(winner, 'broadcast', 'The service worker intercepted the from-window notification icon request');
- });
- }).then(() => {
- // Similar race to above, but this time the service worker requests the
- // notification.
- const race = raceBroadcastAndCookie('icon-request', 'notification');
- iframe.contentWindow.fetch(`show-notification?set-cookie-notification=${Math.random()}`);
-
- return race.then(winner => {
- assert_equals(winner, 'broadcast', 'The service worker intercepted the from-service-worker notification icon request');
- });
- })
- });
-}, `Notification requests intercepted both from window and SW`);
-
-</script>
-</body>
</del></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/Source/WebCore/ChangeLog 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2021-05-12 Chris Dumez <cdumez@apple.com>
+
+ Notification.requestPermission() should return a Promise
+ https://bugs.webkit.org/show_bug.cgi?id=225712
+
+ Reviewed by Darin Adler.
+
+ Notification.requestPermission() should return a Promise as per the specification:
+ - https://notifications.spec.whatwg.org/#notification
+
+ Both Firefox and Chrome already support this.
+
+ Test: http/tests/notifications/request-with-promise.html
+
+ * Modules/notifications/Notification.cpp:
+ (WebCore::Notification::requestPermission):
+ * Modules/notifications/Notification.h:
+ * Modules/notifications/Notification.idl:
+ * Modules/notifications/NotificationClient.h:
+
</ins><span class="cx"> 2021-05-12 Fujii Hironori <Hironori.Fujii@sony.com>
</span><span class="cx">
</span><span class="cx"> Some webgl/2.0.0/conformance/textures/image_bitmap_from_image_data tests are failing after r277369 if !USE(ACCELERATE)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesnotificationsNotificationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/notifications/Notification.cpp (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/notifications/Notification.cpp 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/Source/WebCore/Modules/notifications/Notification.cpp 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -38,11 +38,13 @@
</span><span class="cx"> #include "Document.h"
</span><span class="cx"> #include "Event.h"
</span><span class="cx"> #include "EventNames.h"
</span><ins>+#include "JSDOMPromiseDeferred.h"
</ins><span class="cx"> #include "NotificationClient.h"
</span><span class="cx"> #include "NotificationController.h"
</span><span class="cx"> #include "NotificationPermissionCallback.h"
</span><span class="cx"> #include "WindowEventLoop.h"
</span><span class="cx"> #include "WindowFocusAllowedIndicator.h"
</span><ins>+#include <wtf/CompletionHandler.h>
</ins><span class="cx"> #include <wtf/IsoMallocInlines.h>
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -184,22 +186,26 @@
</span><span class="cx"> return NotificationController::from(document.page())->client().checkPermission(&document);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void Notification::requestPermission(Document& document, RefPtr<NotificationPermissionCallback>&& callback)
</del><ins>+void Notification::requestPermission(Document& document, RefPtr<NotificationPermissionCallback>&& callback, Ref<DeferredPromise>&& promise)
</ins><span class="cx"> {
</span><ins>+ auto resolvePromiseAndCallback = [document = makeRef(document), callback = WTFMove(callback), promise = WTFMove(promise)](Permission permission) mutable {
+ document->eventLoop().queueTask(TaskSource::DOMManipulation, [callback = WTFMove(callback), promise = WTFMove(promise), permission]() mutable {
+ if (callback)
+ callback->handleEvent(permission);
+ promise->resolve<IDLEnumeration<NotificationPermission>>(permission);
+ });
+ };
+
</ins><span class="cx"> auto* page = document.page();
</span><span class="cx"> if (!page)
</span><del>- return;
</del><ins>+ return resolvePromiseAndCallback(Permission::Denied);
</ins><span class="cx">
</span><span class="cx"> if (!document.isSecureContext()) {
</span><del>- if (callback) {
- document.eventLoop().queueTask(TaskSource::DOMManipulation, [callback = WTFMove(callback)]() mutable {
- callback->handleEvent(Permission::Denied);
- });
- }
- return;
</del><ins>+ document.addConsoleMessage(MessageSource::Security, MessageLevel::Error, "The Notification permission may only be requested in a secure context."_s);
+ return resolvePromiseAndCallback(Permission::Denied);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- NotificationController::from(page)->client().requestPermission(&document, WTFMove(callback));
</del><ins>+ NotificationController::from(page)->client().requestPermission(document, WTFMove(resolvePromiseAndCallback));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void Notification::eventListenersDidChange()
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesnotificationsNotificationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/notifications/Notification.h (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/notifications/Notification.h 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/Source/WebCore/Modules/notifications/Notification.h 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -42,6 +42,7 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+class DeferredPromise;
</ins><span class="cx"> class Document;
</span><span class="cx"> class NotificationPermissionCallback;
</span><span class="cx">
</span><span class="lines">@@ -82,7 +83,7 @@
</span><span class="cx"> WEBCORE_EXPORT void finalize();
</span><span class="cx">
</span><span class="cx"> static Permission permission(Document&);
</span><del>- static void requestPermission(Document&, RefPtr<NotificationPermissionCallback>&&);
</del><ins>+ static void requestPermission(Document&, RefPtr<NotificationPermissionCallback>&&, Ref<DeferredPromise>&&);
</ins><span class="cx">
</span><span class="cx"> ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesnotificationsNotificationidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/notifications/Notification.idl (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/notifications/Notification.idl 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/Source/WebCore/Modules/notifications/Notification.idl 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -40,7 +40,7 @@
</span><span class="cx"> [CallWith=Document] constructor(DOMString title, optional NotificationOptions options);
</span><span class="cx">
</span><span class="cx"> [CallWith=Document] static readonly attribute NotificationPermission permission;
</span><del>- [CallWith=Document] static undefined requestPermission(optional NotificationPermissionCallback? deprecatedCallback); // FIXME: This should return a Promise<NotificationPermission>.
</del><ins>+ [CallWith=Document] static Promise<NotificationPermission> requestPermission(optional NotificationPermissionCallback? deprecatedCallback);
</ins><span class="cx">
</span><span class="cx"> // static readonly attribute unsigned long maxActions;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesnotificationsNotificationClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/notifications/NotificationClient.h (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/notifications/NotificationClient.h 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/Source/WebCore/Modules/notifications/NotificationClient.h 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx"> class NotificationClient {
</span><span class="cx"> public:
</span><span class="cx"> using Permission = NotificationPermission;
</span><ins>+ using PermissionHandler = CompletionHandler<void(Permission)>;
</ins><span class="cx">
</span><span class="cx"> // Requests that a notification be shown.
</span><span class="cx"> virtual bool show(Notification*) = 0;
</span><span class="lines">@@ -66,7 +67,7 @@
</span><span class="cx"> // Requests user permission to show desktop notifications from a particular
</span><span class="cx"> // script context. The callback parameter should be run when the user has
</span><span class="cx"> // made a decision.
</span><del>- virtual void requestPermission(ScriptExecutionContext*, RefPtr<NotificationPermissionCallback>&&) = 0;
</del><ins>+ virtual void requestPermission(ScriptExecutionContext&, PermissionHandler&&) = 0;
</ins><span class="cx">
</span><span class="cx"> // Checks the current level of permission.
</span><span class="cx"> virtual Permission checkPermission(ScriptExecutionContext*) = 0;
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/Source/WebKit/ChangeLog 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2021-05-12 Chris Dumez <cdumez@apple.com>
+
+ Notification.requestPermission() should return a Promise
+ https://bugs.webkit.org/show_bug.cgi?id=225712
+
+ Reviewed by Darin Adler.
+
+ Update code now that WebCore passes a CompletionHandler instead of a
+ NotificationPermissionCallback.
+
+ * WebProcess/Notifications/NotificationPermissionRequestManager.cpp:
+ (WebKit::NotificationPermissionRequestManager::~NotificationPermissionRequestManager):
+ (WebKit::NotificationPermissionRequestManager::startRequest):
+ * WebProcess/Notifications/NotificationPermissionRequestManager.h:
+ * WebProcess/WebCoreSupport/WebNotificationClient.cpp:
+ (WebKit::WebNotificationClient::requestPermission):
+ * WebProcess/WebCoreSupport/WebNotificationClient.h:
+
</ins><span class="cx"> 2021-05-12 Fujii Hironori <Hironori.Fujii@sony.com>
</span><span class="cx">
</span><span class="cx"> [WinCairo] Failed to open WebInspector UI since r277231
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessNotificationsNotificationPermissionRequestManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/Notifications/NotificationPermissionRequestManager.cpp (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/Notifications/NotificationPermissionRequestManager.cpp 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/Source/WebKit/WebProcess/Notifications/NotificationPermissionRequestManager.cpp 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -59,43 +59,52 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+NotificationPermissionRequestManager::~NotificationPermissionRequestManager()
+{
</ins><span class="cx"> #if ENABLE(NOTIFICATIONS)
</span><del>-void NotificationPermissionRequestManager::startRequest(const SecurityOriginData& securityOrigin, RefPtr<NotificationPermissionCallback>&& callback)
</del><ins>+ auto requestsPerOrigin = std::exchange(m_requestsPerOrigin, { });
+ for (auto& permissionHandlers : requestsPerOrigin.values())
+ callPermissionHandlersWith(permissionHandlers, Permission::Denied);
+#endif
+}
+
+#if ENABLE(NOTIFICATIONS)
+void NotificationPermissionRequestManager::startRequest(const SecurityOriginData& securityOrigin, PermissionHandler&& permissionHandler)
</ins><span class="cx"> {
</span><span class="cx"> auto permission = permissionLevel(securityOrigin);
</span><del>- if (permission != NotificationClient::Permission::Default) {
- if (callback)
- callback->handleEvent(permission);
- return;
- }
</del><ins>+ if (permission != Permission::Default)
+ return permissionHandler(permission);
</ins><span class="cx">
</span><del>- auto addResult = m_requestsPerOrigin.add(securityOrigin, Vector<RefPtr<WebCore::NotificationPermissionCallback>> { });
- addResult.iterator->value.append(WTFMove(callback));
</del><ins>+ auto addResult = m_requestsPerOrigin.add(securityOrigin, PermissionHandlers { });
+ addResult.iterator->value.append(WTFMove(permissionHandler));
</ins><span class="cx"> if (!addResult.isNewEntry)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- m_page->sendWithAsyncReply(Messages::WebPageProxy::RequestNotificationPermission(securityOrigin.toString()), [this, protectedThis = makeRef(*this), callback = WTFMove(callback), securityOrigin](bool allowed) mutable {
</del><ins>+ m_page->sendWithAsyncReply(Messages::WebPageProxy::RequestNotificationPermission(securityOrigin.toString()), [this, protectedThis = makeRef(*this), permissionHandler = WTFMove(permissionHandler), securityOrigin](bool allowed) mutable {
</ins><span class="cx"> WebProcess::singleton().supplement<WebNotificationManager>()->didUpdateNotificationDecision(securityOrigin.toString(), allowed);
</span><span class="cx">
</span><del>- auto callbacks = m_requestsPerOrigin.take(securityOrigin);
- for (auto& callback : callbacks) {
- if (callback)
- callback->handleEvent(allowed ? NotificationClient::Permission::Granted : NotificationClient::Permission::Denied);
- }
</del><ins>+ auto permissionHandlers = m_requestsPerOrigin.take(securityOrigin);
+ callPermissionHandlersWith(permissionHandlers, allowed ? Permission::Granted : Permission::Denied);
</ins><span class="cx"> });
</span><span class="cx"> }
</span><ins>+
+void NotificationPermissionRequestManager::callPermissionHandlersWith(PermissionHandlers& permissionHandlers, Permission permission)
+{
+ for (auto& permissionHandler : permissionHandlers)
+ permissionHandler(permission);
+}
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>-NotificationClient::Permission NotificationPermissionRequestManager::permissionLevel(const SecurityOriginData& securityOrigin)
</del><ins>+auto NotificationPermissionRequestManager::permissionLevel(const SecurityOriginData& securityOrigin) -> Permission
</ins><span class="cx"> {
</span><span class="cx"> #if ENABLE(NOTIFICATIONS)
</span><span class="cx"> if (!m_page->corePage()->settings().notificationsEnabled())
</span><del>- return NotificationClient::Permission::Denied;
</del><ins>+ return Permission::Denied;
</ins><span class="cx">
</span><span class="cx"> return WebProcess::singleton().supplement<WebNotificationManager>()->policyForOrigin(securityOrigin.toString());
</span><span class="cx"> #else
</span><span class="cx"> UNUSED_PARAM(securityOrigin);
</span><del>- return NotificationClient::Permission::Denied;
</del><ins>+ return Permission::Denied;
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessNotificationsNotificationPermissionRequestManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/Notifications/NotificationPermissionRequestManager.h (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/Notifications/NotificationPermissionRequestManager.h 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/Source/WebKit/WebProcess/Notifications/NotificationPermissionRequestManager.h 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -46,12 +46,16 @@
</span><span class="cx"> class NotificationPermissionRequestManager : public RefCounted<NotificationPermissionRequestManager> {
</span><span class="cx"> public:
</span><span class="cx"> static Ref<NotificationPermissionRequestManager> create(WebPage*);
</span><ins>+ ~NotificationPermissionRequestManager();
</ins><span class="cx">
</span><ins>+ using Permission = WebCore::NotificationClient::Permission;
+ using PermissionHandler = WebCore::NotificationClient::PermissionHandler;
+
</ins><span class="cx"> #if ENABLE(NOTIFICATIONS)
</span><del>- void startRequest(const WebCore::SecurityOriginData&, RefPtr<WebCore::NotificationPermissionCallback>&&);
</del><ins>+ void startRequest(const WebCore::SecurityOriginData&, PermissionHandler&&);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- WebCore::NotificationClient::Permission permissionLevel(const WebCore::SecurityOriginData&);
</del><ins>+ Permission permissionLevel(const WebCore::SecurityOriginData&);
</ins><span class="cx">
</span><span class="cx"> // For testing purposes only.
</span><span class="cx"> void setPermissionLevelForTesting(const String& originString, bool allowed);
</span><span class="lines">@@ -61,7 +65,10 @@
</span><span class="cx"> NotificationPermissionRequestManager(WebPage*);
</span><span class="cx">
</span><span class="cx"> #if ENABLE(NOTIFICATIONS)
</span><del>- HashMap<WebCore::SecurityOriginData, Vector<RefPtr<WebCore::NotificationPermissionCallback>>> m_requestsPerOrigin;
</del><ins>+ using PermissionHandlers = Vector<PermissionHandler>;
+ static void callPermissionHandlersWith(PermissionHandlers&, Permission);
+
+ HashMap<WebCore::SecurityOriginData, PermissionHandlers> m_requestsPerOrigin;
</ins><span class="cx"> WebPage* m_page;
</span><span class="cx"> #endif
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebCoreSupportWebNotificationClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebNotificationClient.cpp (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebNotificationClient.cpp 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebNotificationClient.cpp 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -71,15 +71,12 @@
</span><span class="cx"> delete this;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebNotificationClient::requestPermission(ScriptExecutionContext* context, RefPtr<NotificationPermissionCallback>&& callback)
</del><ins>+void WebNotificationClient::requestPermission(ScriptExecutionContext& context, PermissionHandler&& permissionHandler)
</ins><span class="cx"> {
</span><del>- auto* securityOrigin = context->securityOrigin();
- if (!securityOrigin) {
- if (callback)
- callback->handleEvent(NotificationClient::Permission::Denied);
- return;
- }
- m_page->notificationPermissionRequestManager()->startRequest(securityOrigin->data(), WTFMove(callback));
</del><ins>+ auto* securityOrigin = context.securityOrigin();
+ if (!securityOrigin)
+ return permissionHandler(NotificationClient::Permission::Denied);
+ m_page->notificationPermissionRequestManager()->startRequest(securityOrigin->data(), WTFMove(permissionHandler));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> NotificationClient::Permission WebNotificationClient::checkPermission(ScriptExecutionContext* context)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebCoreSupportWebNotificationClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebNotificationClient.h (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebNotificationClient.h 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebNotificationClient.h 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -31,7 +31,6 @@
</span><span class="cx"> #include <WebCore/NotificationClient.h>
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><del>-class NotificationPermissionCallback;
</del><span class="cx"> class ScriptExecutionContext;
</span><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="lines">@@ -51,7 +50,7 @@
</span><span class="cx"> void clearNotifications(WebCore::ScriptExecutionContext*) override;
</span><span class="cx"> void notificationObjectDestroyed(WebCore::Notification*) override;
</span><span class="cx"> void notificationControllerDestroyed() override;
</span><del>- void requestPermission(WebCore::ScriptExecutionContext*, RefPtr<WebCore::NotificationPermissionCallback>&&) override;
</del><ins>+ void requestPermission(WebCore::ScriptExecutionContext&, PermissionHandler&&) override;
</ins><span class="cx"> WebCore::NotificationClient::Permission checkPermission(WebCore::ScriptExecutionContext*) override;
</span><span class="cx">
</span><span class="cx"> WebPage* m_page;
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/ChangeLog 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -1,5 +1,22 @@
</span><span class="cx"> 2021-05-12 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><ins>+ Notification.requestPermission() should return a Promise
+ https://bugs.webkit.org/show_bug.cgi?id=225712
+
+ Reviewed by Darin Adler.
+
+ Update code now that WebCore passes a CompletionHandler instead of a
+ NotificationPermissionCallback.
+
+ * WebCoreSupport/WebNotificationClient.h:
+ * WebCoreSupport/WebNotificationClient.mm:
+ (WebNotificationClient::requestPermission):
+ (-[WebNotificationPolicyListener initWithCompletionHandler:]):
+ (-[WebNotificationPolicyListener allow]):
+ (-[WebNotificationPolicyListener deny]):
+
+2021-05-12 Chris Dumez <cdumez@apple.com>
+
</ins><span class="cx"> Queue notification permission requests for the same origin on WebKit side
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=225701
</span><span class="cx"> <rdar://76804977>
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacWebCoreSupportWebNotificationClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebNotificationClient.h (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebNotificationClient.h 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebNotificationClient.h 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -50,10 +50,10 @@
</span><span class="cx"> void clearNotifications(WebCore::ScriptExecutionContext*) override;
</span><span class="cx"> void notificationObjectDestroyed(WebCore::Notification*) override;
</span><span class="cx"> void notificationControllerDestroyed() override;
</span><del>- void requestPermission(WebCore::ScriptExecutionContext*, RefPtr<WebCore::NotificationPermissionCallback>&&) override;
</del><ins>+ void requestPermission(WebCore::ScriptExecutionContext&, PermissionHandler&&) override;
</ins><span class="cx"> WebCore::NotificationClient::Permission checkPermission(WebCore::ScriptExecutionContext*) override;
</span><span class="cx">
</span><del>- void requestPermission(WebCore::ScriptExecutionContext*, WebNotificationPolicyListener *);
</del><ins>+ void requestPermission(WebCore::ScriptExecutionContext&, WebNotificationPolicyListener *);
</ins><span class="cx">
</span><span class="cx"> WebView *m_webView;
</span><span class="cx"> HashMap<RefPtr<WebCore::Notification>, RetainPtr<WebNotification>> m_notificationMap;
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacWebCoreSupportWebNotificationClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebNotificationClient.mm (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebNotificationClient.mm 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebNotificationClient.mm 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -33,9 +33,9 @@
</span><span class="cx"> #import "WebSecurityOriginInternal.h"
</span><span class="cx"> #import "WebUIDelegatePrivate.h"
</span><span class="cx"> #import "WebViewInternal.h"
</span><del>-#import <WebCore/NotificationPermissionCallback.h>
</del><span class="cx"> #import <WebCore/ScriptExecutionContext.h>
</span><span class="cx"> #import <wtf/BlockObjCExceptions.h>
</span><ins>+#import <wtf/CompletionHandler.h>
</ins><span class="cx"> #import <wtf/cocoa/VectorCocoa.h>
</span><span class="cx">
</span><span class="cx"> using namespace WebCore;
</span><span class="lines">@@ -42,9 +42,9 @@
</span><span class="cx">
</span><span class="cx"> @interface WebNotificationPolicyListener : NSObject <WebAllowDenyPolicyListener>
</span><span class="cx"> {
</span><del>- RefPtr<NotificationPermissionCallback> _callback;
</del><ins>+ NotificationClient::PermissionHandler _permissionHandler;
</ins><span class="cx"> }
</span><del>-- (id)initWithCallback:(RefPtr<NotificationPermissionCallback>&&)callback;
</del><ins>+- (id)initWithPermissionHandler:(NotificationClient::PermissionHandler&&)permissionHandler;
</ins><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> static uint64_t generateNotificationID()
</span><span class="lines">@@ -122,7 +122,7 @@
</span><span class="cx"> delete this;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebNotificationClient::requestPermission(ScriptExecutionContext* context, WebNotificationPolicyListener *listener)
</del><ins>+void WebNotificationClient::requestPermission(ScriptExecutionContext& context, WebNotificationPolicyListener *listener)
</ins><span class="cx"> {
</span><span class="cx"> SEL selector = @selector(webView:decidePolicyForNotificationRequestFromOrigin:listener:);
</span><span class="cx"> if (![[m_webView UIDelegate] respondsToSelector:selector])
</span><span class="lines">@@ -130,15 +130,15 @@
</span><span class="cx">
</span><span class="cx"> m_everRequestedPermission = true;
</span><span class="cx">
</span><del>- auto webOrigin = adoptNS([[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:context->securityOrigin()]);
</del><ins>+ auto webOrigin = adoptNS([[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:context.securityOrigin()]);
</ins><span class="cx">
</span><span class="cx"> CallUIDelegate(m_webView, selector, webOrigin.get(), listener);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebNotificationClient::requestPermission(ScriptExecutionContext* context, RefPtr<NotificationPermissionCallback>&& callback)
</del><ins>+void WebNotificationClient::requestPermission(ScriptExecutionContext& context, PermissionHandler&& permissionHandler)
</ins><span class="cx"> {
</span><span class="cx"> BEGIN_BLOCK_OBJC_EXCEPTIONS
</span><del>- auto listener = adoptNS([[WebNotificationPolicyListener alloc] initWithCallback:WTFMove(callback)]);
</del><ins>+ auto listener = adoptNS([[WebNotificationPolicyListener alloc] initWithPermissionHandler:WTFMove(permissionHandler)]);
</ins><span class="cx"> requestPermission(context, listener.get());
</span><span class="cx"> END_BLOCK_OBJC_EXCEPTIONS
</span><span class="cx"> }
</span><span class="lines">@@ -170,25 +170,25 @@
</span><span class="cx">
</span><span class="cx"> @implementation WebNotificationPolicyListener
</span><span class="cx">
</span><del>-- (id)initWithCallback:(RefPtr<NotificationPermissionCallback>&&)callback
</del><ins>+- (id)initWithPermissionHandler:(NotificationClient::PermissionHandler&&)permissionHandler
</ins><span class="cx"> {
</span><span class="cx"> if (!(self = [super init]))
</span><span class="cx"> return nil;
</span><span class="cx">
</span><del>- _callback = WTFMove(callback);
</del><ins>+ _permissionHandler = WTFMove(permissionHandler);
</ins><span class="cx"> return self;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)allow
</span><span class="cx"> {
</span><del>- if (_callback)
- _callback->handleEvent(NotificationClient::Permission::Granted);
</del><ins>+ if (_permissionHandler)
+ _permissionHandler(NotificationClient::Permission::Granted);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)deny
</span><span class="cx"> {
</span><del>- if (_callback)
- _callback->handleEvent(NotificationClient::Permission::Denied);
</del><ins>+ if (_permissionHandler)
+ _permissionHandler(NotificationClient::Permission::Denied);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span></span></pre></div>
<a id="trunkSourceWebKitLegacywinChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/win/ChangeLog (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/win/ChangeLog 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/Source/WebKitLegacy/win/ChangeLog 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -1,5 +1,19 @@
</span><span class="cx"> 2021-05-12 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><ins>+ Notification.requestPermission() should return a Promise
+ https://bugs.webkit.org/show_bug.cgi?id=225712
+
+ Reviewed by Darin Adler.
+
+ Update code now that WebCore passes a CompletionHandler instead of a
+ NotificationPermissionCallback.
+
+ * WebCoreSupport/WebDesktopNotificationsDelegate.cpp:
+ (WebDesktopNotificationsDelegate::requestPermission):
+ * WebCoreSupport/WebDesktopNotificationsDelegate.h:
+
+2021-05-12 Chris Dumez <cdumez@apple.com>
+
</ins><span class="cx"> Queue notification permission requests for the same origin on WebKit side
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=225701
</span><span class="cx"> <rdar://76804977>
</span></span></pre></div>
<a id="trunkSourceWebKitLegacywinWebCoreSupportWebDesktopNotificationsDelegatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebDesktopNotificationsDelegate.cpp (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebDesktopNotificationsDelegate.cpp 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebDesktopNotificationsDelegate.cpp 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -177,8 +177,9 @@
</span><span class="cx"> notificationDelegate()->requestNotificationPermission(org);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebDesktopNotificationsDelegate::requestPermission(SecurityOrigin*, RefPtr<NotificationPermissionCallback>&&)
</del><ins>+void WebDesktopNotificationsDelegate::requestPermission(SecurityOrigin&, PermissionHandler&& permissionHandler)
</ins><span class="cx"> {
</span><ins>+ permissionHandler(Permission::Denied);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> NotificationClient::Permission WebDesktopNotificationsDelegate::checkPermission(const URL& url)
</span></span></pre></div>
<a id="trunkSourceWebKitLegacywinWebCoreSupportWebDesktopNotificationsDelegateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebDesktopNotificationsDelegate.h (277419 => 277420)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebDesktopNotificationsDelegate.h 2021-05-13 03:46:57 UTC (rev 277419)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebDesktopNotificationsDelegate.h 2021-05-13 05:02:45 UTC (rev 277420)
</span><span class="lines">@@ -53,7 +53,7 @@
</span><span class="cx"> virtual void cancel(WebCore::Notification* object);
</span><span class="cx"> virtual void notificationObjectDestroyed(WebCore::Notification* object);
</span><span class="cx"> virtual void notificationControllerDestroyed();
</span><del>- virtual void requestPermission(WebCore::SecurityOrigin*, RefPtr<WebCore::NotificationPermissionCallback>&&);
</del><ins>+ virtual void requestPermission(WebCore::SecurityOrigin&, PermissionHandler&&);
</ins><span class="cx"> virtual WebCore::NotificationClient::Permission checkPermission(const URL&);
</span><span class="cx">
</span><span class="cx"> private:
</span></span></pre>
</div>
</div>
</body>
</html>