Title: [253899] trunk
- Revision
- 253899
- Author
- [email protected]
- Date
- 2019-12-24 06:41:20 -0800 (Tue, 24 Dec 2019)
Log Message
Deny Notification API access for non secure contexts
https://bugs.webkit.org/show_bug.cgi?id=205496
<rdar://problem/58074660>
Reviewed by Chris Dumez.
Source/WebCore:
If document is not SecureContext, deny permission automatically.
This behavior is matching a planned update to the spec, as discussed in
https://github.com/whatwg/notifications/issues/93.
Chrome landed this restriction in M62. Mozilla is also on board with this restriction.
Test: http/tests/notifications/notification-in-non-secure-context.html
* Modules/notifications/Notification.cpp:
(WebCore::Notification::requestPermission):
Tools:
* TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:
(TEST):
LayoutTests:
* http/tests/notifications/notification-in-non-secure-context-expected.txt: Added.
* http/tests/notifications/notification-in-non-secure-context.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (253898 => 253899)
--- trunk/LayoutTests/ChangeLog 2019-12-24 14:19:45 UTC (rev 253898)
+++ trunk/LayoutTests/ChangeLog 2019-12-24 14:41:20 UTC (rev 253899)
@@ -1,3 +1,14 @@
+2019-12-24 Youenn Fablet <[email protected]>
+
+ Deny Notification API access for non secure contexts
+ https://bugs.webkit.org/show_bug.cgi?id=205496
+ <rdar://problem/58074660>
+
+ Reviewed by Chris Dumez.
+
+ * http/tests/notifications/notification-in-non-secure-context-expected.txt: Added.
+ * http/tests/notifications/notification-in-non-secure-context.html: Added.
+
2019-12-24 youenn fablet <[email protected]>
Service Worker doesn't terminate after a period of time when thread blocking
Added: trunk/LayoutTests/http/tests/notifications/notification-in-non-secure-context-expected.txt (0 => 253899)
--- trunk/LayoutTests/http/tests/notifications/notification-in-non-secure-context-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/notifications/notification-in-non-secure-context-expected.txt 2019-12-24 14:41:20 UTC (rev 253899)
@@ -0,0 +1,3 @@
+
+PASS Notification permission in insecure context
+
Added: trunk/LayoutTests/http/tests/notifications/notification-in-non-secure-context.html (0 => 253899)
--- trunk/LayoutTests/http/tests/notifications/notification-in-non-secure-context.html (rev 0)
+++ trunk/LayoutTests/http/tests/notifications/notification-in-non-secure-context.html 2019-12-24 14:41:20 UTC (rev 253899)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script src=""
+<script>
+var test = async_test("Notification permission in insecure context");
+
+// localhost is secure by default.
+if (window.internals)
+ internals.markContextAsInsecure();
+
+Notification.requestPermission(test.step_func((result) => {
+ assert_equals(result, "denied", "result");
+ assert_equals(Notification.permission, "denied", "getter");
+ test.done();
+}));
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (253898 => 253899)
--- trunk/Source/WebCore/ChangeLog 2019-12-24 14:19:45 UTC (rev 253898)
+++ trunk/Source/WebCore/ChangeLog 2019-12-24 14:41:20 UTC (rev 253899)
@@ -1,3 +1,21 @@
+2019-12-24 Youenn Fablet <[email protected]>
+
+ Deny Notification API access for non secure contexts
+ https://bugs.webkit.org/show_bug.cgi?id=205496
+ <rdar://problem/58074660>
+
+ Reviewed by Chris Dumez.
+
+ If document is not SecureContext, deny permission automatically.
+ This behavior is matching a planned update to the spec, as discussed in
+ https://github.com/whatwg/notifications/issues/93.
+ Chrome landed this restriction in M62. Mozilla is also on board with this restriction.
+
+ Test: http/tests/notifications/notification-in-non-secure-context.html
+
+ * Modules/notifications/Notification.cpp:
+ (WebCore::Notification::requestPermission):
+
2019-12-24 youenn fablet <[email protected]>
Service Worker doesn't terminate after a period of time when thread blocking
Modified: trunk/Source/WebCore/Modules/notifications/Notification.cpp (253898 => 253899)
--- trunk/Source/WebCore/Modules/notifications/Notification.cpp 2019-12-24 14:19:45 UTC (rev 253898)
+++ trunk/Source/WebCore/Modules/notifications/Notification.cpp 2019-12-24 14:41:20 UTC (rev 253899)
@@ -191,6 +191,9 @@
if (!page)
return Permission::Default;
+ if (!document.isSecureContext())
+ return Permission::Denied;
+
return NotificationController::from(document.page())->client().checkPermission(&document);
}
@@ -200,6 +203,13 @@
if (!page)
return;
+ if (!document.isSecureContext()) {
+ document.eventLoop().queueTask(TaskSource::DOMManipulation, [callback = WTFMove(callback)]() mutable {
+ callback->handleEvent(Permission::Denied);
+ });
+ return;
+ }
+
NotificationController::from(page)->client().requestPermission(&document, WTFMove(callback));
}
Modified: trunk/Tools/ChangeLog (253898 => 253899)
--- trunk/Tools/ChangeLog 2019-12-24 14:19:45 UTC (rev 253898)
+++ trunk/Tools/ChangeLog 2019-12-24 14:41:20 UTC (rev 253899)
@@ -1,3 +1,14 @@
+2019-12-24 Youenn Fablet <[email protected]>
+
+ Deny Notification API access for non secure contexts
+ https://bugs.webkit.org/show_bug.cgi?id=205496
+ <rdar://problem/58074660>
+
+ Reviewed by Chris Dumez.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:
+ (TEST):
+
2019-12-24 youenn fablet <[email protected]>
Service Worker doesn't terminate after a period of time when thread blocking
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm (253898 => 253899)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm 2019-12-24 14:19:45 UTC (rev 253898)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm 2019-12-24 14:41:20 UTC (rev 253899)
@@ -484,11 +484,11 @@
NSString *html = @"<script>Notification.requestPermission(function(p){alert('permission '+p)})</script>";
auto webView = adoptNS([[WKWebView alloc] init]);
[webView setUIDelegate:[[[NotificationDelegate alloc] initWithAllowNotifications:YES] autorelease]];
- [webView loadHTMLString:html baseURL:[NSURL URLWithString:@"http://example.org"]];
+ [webView loadHTMLString:html baseURL:[NSURL URLWithString:@"https://example.org"]];
TestWebKitAPI::Util::run(&done);
done = false;
[webView setUIDelegate:[[[NotificationDelegate alloc] initWithAllowNotifications:NO] autorelease]];
- [webView loadHTMLString:html baseURL:[NSURL URLWithString:@"http://example.com"]];
+ [webView loadHTMLString:html baseURL:[NSURL URLWithString:@"https://example.com"]];
TestWebKitAPI::Util::run(&done);
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes