- Revision
- 152642
- Author
- [email protected]
- Date
- 2013-07-15 10:16:12 -0700 (Mon, 15 Jul 2013)
Log Message
Source/WebKit/mac: [WK2] Calling Notification.requestPermission() without a callback crashes
https://bugs.webkit.org/show_bug.cgi?id=118654
<rdar://problem/14293352>
Reviewed by Alexey Proskuryakov.
* WebCoreSupport/WebNotificationClient.mm:
(-[WebNotificationPolicyListener initWithCallback:]): The callback can be NULL, so remove the ASSERT.
(-[WebNotificationPolicyListener allow]): Check for the callback before asking it to handle the event.
(-[WebNotificationPolicyListener deny]): Ditto.
Source/WebKit2: Calling Notification.requestPermission() without a callback crashes
https://bugs.webkit.org/show_bug.cgi?id=118654
<rdar://problem/14293352>
Reviewed by Alexey Proskuryakov.
When requestPermission() is called, we short-circuit if we know the permission was already set.
The callback handler gets invoked. But now that callbacks are optional, we need to check to make
sure a callback was provided.
* WebProcess/Notifications/NotificationPermissionRequestManager.cpp:
(WebKit::NotificationPermissionRequestManager::startRequest): Check for the callback.
LayoutTests: [WK2] Calling Notification.requestPermission() without a callback crashes
https://bugs.webkit.org/show_bug.cgi?id=118654
<rdar://problem/14293352>
Reviewed by Alexey Proskuryakov.
* http/tests/notifications/notification-request-permission-expected.txt:
* http/tests/notifications/notification-request-permission.html: Add additional subtests that check
that the call succeeds even after granting or denying permission.
* http/tests/notifications/notification-request-permission-no-callback-expected.txt: Added.
* http/tests/notifications/notification-request-permission-no-callback.html: Added. Similar test to
notification-request-permission, without the callback function.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (152641 => 152642)
--- trunk/LayoutTests/ChangeLog 2013-07-15 16:55:19 UTC (rev 152641)
+++ trunk/LayoutTests/ChangeLog 2013-07-15 17:16:12 UTC (rev 152642)
@@ -1,3 +1,19 @@
+2013-07-14 Jon Lee <[email protected]>
+
+ [WK2] Calling Notification.requestPermission() without a callback crashes
+ https://bugs.webkit.org/show_bug.cgi?id=118654
+ <rdar://problem/14293352>
+
+ Reviewed by Alexey Proskuryakov.
+
+ * http/tests/notifications/notification-request-permission-expected.txt:
+ * http/tests/notifications/notification-request-permission.html: Add additional subtests that check
+ that the call succeeds even after granting or denying permission.
+
+ * http/tests/notifications/notification-request-permission-no-callback-expected.txt: Added.
+ * http/tests/notifications/notification-request-permission-no-callback.html: Added. Similar test to
+ notification-request-permission, without the callback function.
+
2013-07-15 Zoltan Arvai <[email protected]>
[Qt][WK2] Unreviewed cleanup for pixel tester bot.
Modified: trunk/LayoutTests/http/tests/notifications/notification-request-permission-expected.txt (152641 => 152642)
--- trunk/LayoutTests/http/tests/notifications/notification-request-permission-expected.txt 2013-07-15 16:55:19 UTC (rev 152641)
+++ trunk/LayoutTests/http/tests/notifications/notification-request-permission-expected.txt 2013-07-15 17:16:12 UTC (rev 152642)
@@ -1,4 +1,6 @@
PASS Notification.requestPermission does not crash.
+PASS Notification.requestPermission does not crash.
+PASS Notification.requestPermission does not crash.
PASS successfullyParsed is true
TEST COMPLETE
Added: trunk/LayoutTests/http/tests/notifications/notification-request-permission-no-callback-expected.txt (0 => 152642)
--- trunk/LayoutTests/http/tests/notifications/notification-request-permission-no-callback-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/notifications/notification-request-permission-no-callback-expected.txt 2013-07-15 17:16:12 UTC (rev 152642)
@@ -0,0 +1,7 @@
+PASS Notification.requestPermission does not crash.
+PASS Notification.requestPermission does not crash.
+PASS Notification.requestPermission does not crash.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/notifications/notification-request-permission-no-callback.html (0 => 152642)
--- trunk/LayoutTests/http/tests/notifications/notification-request-permission-no-callback.html (rev 0)
+++ trunk/LayoutTests/http/tests/notifications/notification-request-permission-no-callback.html 2013-07-15 17:16:12 UTC (rev 152642)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<script>
+if (!window.Notification)
+ testFailed("window.Notification does not exist.");
+
+window.Notification.requestPermission();
+testPassed("Notification.requestPermission does not crash.");
+
+testRunner.grantWebNotificationPermission(testURL);
+window.Notification.requestPermission();
+testPassed("Notification.requestPermission does not crash.");
+
+testRunner.denyWebNotificationPermission(testURL);
+window.Notification.requestPermission();
+testPassed("Notification.requestPermission does not crash.");
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/http/tests/notifications/notification-request-permission.html (152641 => 152642)
--- trunk/LayoutTests/http/tests/notifications/notification-request-permission.html 2013-07-15 16:55:19 UTC (rev 152641)
+++ trunk/LayoutTests/http/tests/notifications/notification-request-permission.html 2013-07-15 17:16:12 UTC (rev 152642)
@@ -1,7 +1,8 @@
<!DOCTYPE html>
<html>
<head>
-<script src=""
+<script src=""
+<script src=""
</head>
<body>
<script>
@@ -10,7 +11,15 @@
window.Notification.requestPermission(function() { });
testPassed("Notification.requestPermission does not crash.");
+
+testRunner.grantWebNotificationPermission(testURL);
+window.Notification.requestPermission(function() { });
+testPassed("Notification.requestPermission does not crash.");
+
+testRunner.denyWebNotificationPermission(testURL);
+window.Notification.requestPermission(function() { });
+testPassed("Notification.requestPermission does not crash.");
</script>
-<script src=""
+<script src=""
</body>
</html>
Modified: trunk/Source/WebKit/mac/ChangeLog (152641 => 152642)
--- trunk/Source/WebKit/mac/ChangeLog 2013-07-15 16:55:19 UTC (rev 152641)
+++ trunk/Source/WebKit/mac/ChangeLog 2013-07-15 17:16:12 UTC (rev 152642)
@@ -1,3 +1,16 @@
+2013-07-14 Jon Lee <[email protected]>
+
+ [WK2] Calling Notification.requestPermission() without a callback crashes
+ https://bugs.webkit.org/show_bug.cgi?id=118654
+ <rdar://problem/14293352>
+
+ Reviewed by Alexey Proskuryakov.
+
+ * WebCoreSupport/WebNotificationClient.mm:
+ (-[WebNotificationPolicyListener initWithCallback:]): The callback can be NULL, so remove the ASSERT.
+ (-[WebNotificationPolicyListener allow]): Check for the callback before asking it to handle the event.
+ (-[WebNotificationPolicyListener deny]): Ditto.
+
2013-07-12 Jessie Berlin <[email protected]>
Remove some dead stores pointed out by the clang static analyzer.
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.mm (152641 => 152642)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.mm 2013-07-15 16:55:19 UTC (rev 152641)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.mm 2013-07-15 17:16:12 UTC (rev 152642)
@@ -241,7 +241,6 @@
if (!(self = [super init]))
return nil;
- ASSERT(callback);
_callback = callback;
return self;
}
@@ -269,7 +268,8 @@
}
#endif
#if ENABLE(NOTIFICATIONS)
- _callback->handleEvent(Notification::permissionString(NotificationClient::PermissionAllowed));
+ if (_callback)
+ _callback->handleEvent(Notification::permissionString(NotificationClient::PermissionAllowed));
#endif
}
@@ -283,7 +283,8 @@
}
#endif
#if ENABLE(NOTIFICATIONS)
- _callback->handleEvent(Notification::permissionString(NotificationClient::PermissionDenied));
+ if (_callback)
+ _callback->handleEvent(Notification::permissionString(NotificationClient::PermissionDenied));
#endif
}
Modified: trunk/Source/WebKit2/ChangeLog (152641 => 152642)
--- trunk/Source/WebKit2/ChangeLog 2013-07-15 16:55:19 UTC (rev 152641)
+++ trunk/Source/WebKit2/ChangeLog 2013-07-15 17:16:12 UTC (rev 152642)
@@ -1,3 +1,18 @@
+2013-07-14 Jon Lee <[email protected]>
+
+ Calling Notification.requestPermission() without a callback crashes
+ https://bugs.webkit.org/show_bug.cgi?id=118654
+ <rdar://problem/14293352>
+
+ Reviewed by Alexey Proskuryakov.
+
+ When requestPermission() is called, we short-circuit if we know the permission was already set.
+ The callback handler gets invoked. But now that callbacks are optional, we need to check to make
+ sure a callback was provided.
+
+ * WebProcess/Notifications/NotificationPermissionRequestManager.cpp:
+ (WebKit::NotificationPermissionRequestManager::startRequest): Check for the callback.
+
2013-07-15 Anton Obzhirov <[email protected]>
[GTK] Remote inspector server should send an error page if resources not found
Modified: trunk/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp (152641 => 152642)
--- trunk/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp 2013-07-15 16:55:19 UTC (rev 152641)
+++ trunk/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp 2013-07-15 17:16:12 UTC (rev 152642)
@@ -70,7 +70,8 @@
{
NotificationClient::Permission permission = permissionLevel(origin);
if (permission != NotificationClient::PermissionNotAllowed) {
- callback->handleEvent(Notification::permissionString(permission));
+ if (callback)
+ callback->handleEvent(Notification::permissionString(permission));
return;
}