Title: [141072] branches/chromium/1364
- Revision
- 141072
- Author
- [email protected]
- Date
- 2013-01-29 00:25:19 -0800 (Tue, 29 Jan 2013)
Log Message
Merge 140927
> Check notification permissions in the show() method
> https://bugs.webkit.org/show_bug.cgi?id=108009
>
> Reviewed by Adam Barth.
>
> Source/WebCore:
>
> Tests: fast/notifications/notifications-constructor-with-permission.html
> fast/notifications/notifications-constructor-without-permission.html
>
> * Modules/notifications/Notification.cpp:
> (WebCore::Notification::show):
> (WebCore::Notification::taskTimerFired):
>
> LayoutTests:
>
> * fast/notifications/notifications-constructor-with-permission-expected.txt: Added.
> * fast/notifications/notifications-constructor-with-permission.html: Added.
> * fast/notifications/notifications-constructor-without-permission-expected.txt: Added.
> * fast/notifications/notifications-constructor-without-permission.html: Added.
>
[email protected]
Review URL: https://codereview.chromium.org/12087048
Modified Paths
Added Paths
Diff
Copied: branches/chromium/1364/LayoutTests/fast/notifications/notifications-constructor-with-permission-expected.txt (from rev 140927, trunk/LayoutTests/fast/notifications/notifications-constructor-with-permission-expected.txt) (0 => 141072)
--- branches/chromium/1364/LayoutTests/fast/notifications/notifications-constructor-with-permission-expected.txt (rev 0)
+++ branches/chromium/1364/LayoutTests/fast/notifications/notifications-constructor-with-permission-expected.txt 2013-01-29 08:25:19 UTC (rev 141072)
@@ -0,0 +1,5 @@
+DESKTOP NOTIFICATION: icon , title Hello world, text
+Sending notifications with permission...
+
+PASS: show event fired.
+
Copied: branches/chromium/1364/LayoutTests/fast/notifications/notifications-constructor-with-permission.html (from rev 140927, trunk/LayoutTests/fast/notifications/notifications-constructor-with-permission.html) (0 => 141072)
--- branches/chromium/1364/LayoutTests/fast/notifications/notifications-constructor-with-permission.html (rev 0)
+++ branches/chromium/1364/LayoutTests/fast/notifications/notifications-constructor-with-permission.html 2013-01-29 08:25:19 UTC (rev 141072)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script type="text/_javascript_">
+ function log(message)
+ {
+ document.getElementById("result").innerHTML += message + "<br>";
+ }
+
+ function runTests()
+ {
+ if (window.testRunner) {
+ testRunner.grantWebNotificationPermission("file://");
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+
+ if (!window.Notification) {
+ log("FAIL: No Notification constructor!");
+ }
+
+ var N = new Notification("Hello world");
+ N._onshow_ = function() { log("PASS: show event fired."); }
+ N._onerror_ = function() { log("FAIL: error event fired."); }
+ setTimeout(function() { testRunner.notifyDone(); }, 100);
+ }
+ </script>
+</head>
+<body>
+<p>Sending notifications with permission...</p>
+<div id="result"></div>
+
+<script type="text/_javascript_">
+runTests();
+</script>
+</body>
+</html>
Copied: branches/chromium/1364/LayoutTests/fast/notifications/notifications-constructor-without-permission-expected.txt (from rev 140927, trunk/LayoutTests/fast/notifications/notifications-constructor-without-permission-expected.txt) (0 => 141072)
--- branches/chromium/1364/LayoutTests/fast/notifications/notifications-constructor-without-permission-expected.txt (rev 0)
+++ branches/chromium/1364/LayoutTests/fast/notifications/notifications-constructor-without-permission-expected.txt 2013-01-29 08:25:19 UTC (rev 141072)
@@ -0,0 +1,4 @@
+Sending notifications without permission...
+
+PASS: error event fired.
+
Copied: branches/chromium/1364/LayoutTests/fast/notifications/notifications-constructor-without-permission.html (from rev 140927, trunk/LayoutTests/fast/notifications/notifications-constructor-without-permission.html) (0 => 141072)
--- branches/chromium/1364/LayoutTests/fast/notifications/notifications-constructor-without-permission.html (rev 0)
+++ branches/chromium/1364/LayoutTests/fast/notifications/notifications-constructor-without-permission.html 2013-01-29 08:25:19 UTC (rev 141072)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script type="text/_javascript_">
+ function log(message)
+ {
+ document.getElementById("result").innerHTML += message + "<br>";
+ }
+
+ function runTests()
+ {
+ if (window.testRunner) {
+ // NO PERMISSION testRunner.grantWebNotificationPermission("file://");
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+
+ if (!window.Notification) {
+ log("FAIL: No Notification constructor!");
+ }
+
+ var N = new Notification("Hello world");
+ N._onshow_ = function() { log("FAIL: show event fired."); }
+ N._onerror_ = function() { log("PASS: error event fired."); }
+ setTimeout(function() { testRunner.notifyDone(); }, 100);
+ }
+ </script>
+</head>
+<body>
+<p>Sending notifications without permission...</p>
+<div id="result"></div>
+
+<script type="text/_javascript_">
+runTests();
+</script>
+</body>
+</html>
Modified: branches/chromium/1364/Source/WebCore/Modules/notifications/Notification.cpp (141071 => 141072)
--- branches/chromium/1364/Source/WebCore/Modules/notifications/Notification.cpp 2013-01-29 08:18:54 UTC (rev 141071)
+++ branches/chromium/1364/Source/WebCore/Modules/notifications/Notification.cpp 2013-01-29 08:25:19 UTC (rev 141072)
@@ -169,9 +169,19 @@
void Notification::show()
{
// prevent double-showing
- if (m_state == Idle && m_notificationCenter->client() && m_notificationCenter->client()->show(this)) {
- m_state = Showing;
- setPendingActivity(this);
+ if (m_state == Idle && m_notificationCenter->client()) {
+#if ENABLE(NOTIFICATIONS)
+ if (!static_cast<Document*>(scriptExecutionContext())->page())
+ return;
+ if (NotificationController::from(static_cast<Document*>(scriptExecutionContext())->page())->client()->checkPermission(scriptExecutionContext()) != NotificationClient::PermissionAllowed) {
+ dispatchErrorEvent();
+ return;
+ }
+#endif
+ if (m_notificationCenter->client()->show(this)) {
+ m_state = Showing;
+ setPendingActivity(this);
+ }
}
}
@@ -240,12 +250,7 @@
void Notification::taskTimerFired(Timer<Notification>* timer)
{
ASSERT(scriptExecutionContext()->isDocument());
- ASSERT(static_cast<Document*>(scriptExecutionContext())->page());
ASSERT_UNUSED(timer, timer == m_taskTimer.get());
- if (NotificationController::from(static_cast<Document*>(scriptExecutionContext())->page())->client()->checkPermission(scriptExecutionContext()) != NotificationClient::PermissionAllowed) {
- dispatchErrorEvent();
- return;
- }
show();
}
#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes