Title: [128080] trunk
Revision
128080
Author
[email protected]
Date
2012-09-10 11:08:25 -0700 (Mon, 10 Sep 2012)

Log Message

The options dictionary in Notification constructor should not accept event listeners
https://bugs.webkit.org/show_bug.cgi?id=95538
<rdar://problem/12213901>

Reviewed by Alexey Proskuryakov.

Source/WebCore:

The latest spec only allows setting the event listeners after the notification has been created.

Test: http/tests/notifications/events-in-dictionary.html

* Modules/notifications/Notification.cpp:
(WebCore::Notification::create): Do not look for the event handlers in the options dictionary.

LayoutTests:

Make sure the onshow handler added in the options dictionary does not get called.

* http/tests/notifications/events-in-dictionary-expected.txt: Added.
* http/tests/notifications/events-in-dictionary.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (128079 => 128080)


--- trunk/LayoutTests/ChangeLog	2012-09-10 18:06:39 UTC (rev 128079)
+++ trunk/LayoutTests/ChangeLog	2012-09-10 18:08:25 UTC (rev 128080)
@@ -1,5 +1,18 @@
 2012-08-31  Jon Lee  <[email protected]>
 
+        The options dictionary in Notification constructor should not accept event listeners
+        https://bugs.webkit.org/show_bug.cgi?id=95538
+        <rdar://problem/12213901>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Make sure the onshow handler added in the options dictionary does not get called.
+
+        * http/tests/notifications/events-in-dictionary-expected.txt: Added.
+        * http/tests/notifications/events-in-dictionary.html: Added.
+
+2012-08-31  Jon Lee  <[email protected]>
+
         [Tests] Move fast/notifications/notifications-double-show.html to http/tests/notifications
         https://bugs.webkit.org/show_bug.cgi?id=95537
         <rdar://problem/12213860>

Added: trunk/LayoutTests/http/tests/notifications/events-in-dictionary-expected.txt (0 => 128080)


--- trunk/LayoutTests/http/tests/notifications/events-in-dictionary-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/notifications/events-in-dictionary-expected.txt	2012-09-10 18:08:25 UTC (rev 128080)
@@ -0,0 +1,11 @@
+This test ensures event handlers defined inside the options dictionary are ignored.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Notification.permission is "granted"
+PASS onshow event handler defined after Notification construction was called
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/notifications/events-in-dictionary.html (0 => 128080)


--- trunk/LayoutTests/http/tests/notifications/events-in-dictionary.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/notifications/events-in-dictionary.html	2012-09-10 18:08:25 UTC (rev 128080)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<script src=""
+<script src=""
+<p id="description"></p>
+<div id="console"></div>
+<script>
+if (window.testRunner)
+	testRunner.waitUntilDone();
+
+description("This test ensures event handlers defined inside the options dictionary are ignored.");
+
+if (window.testRunner) {
+	testRunner.grantWebNotificationPermission(testURL);
+	shouldBeEqualToString("Notification.permission", "granted");
+
+	var n = new Notification("title", { onshow: function() {
+		testFailed("onshow event handler defined in options dictionary should not be called");
+	}});
+	n.addEventListener("show", function() {
+		testPassed("onshow event handler defined after Notification construction was called");
+		testCompleted();
+	});
+}
+
+setTimeout(testCompleted, 100);
+</script>

Modified: trunk/Source/WebCore/ChangeLog (128079 => 128080)


--- trunk/Source/WebCore/ChangeLog	2012-09-10 18:06:39 UTC (rev 128079)
+++ trunk/Source/WebCore/ChangeLog	2012-09-10 18:08:25 UTC (rev 128080)
@@ -1,3 +1,18 @@
+2012-08-31  Jon Lee  <[email protected]>
+
+        The options dictionary in Notification constructor should not accept event listeners
+        https://bugs.webkit.org/show_bug.cgi?id=95538
+        <rdar://problem/12213901>
+
+        Reviewed by Alexey Proskuryakov.
+
+        The latest spec only allows setting the event listeners after the notification has been created.
+
+        Test: http/tests/notifications/events-in-dictionary.html
+
+        * Modules/notifications/Notification.cpp:
+        (WebCore::Notification::create): Do not look for the event handlers in the options dictionary.
+
 2012-09-04  Robert Hogan  <[email protected]>
 
         CSS 2.1 failure: content-counter-010.htm fails

Modified: trunk/Source/WebCore/Modules/notifications/Notification.cpp (128079 => 128080)


--- trunk/Source/WebCore/Modules/notifications/Notification.cpp	2012-09-10 18:06:39 UTC (rev 128079)
+++ trunk/Source/WebCore/Modules/notifications/Notification.cpp	2012-09-10 18:08:25 UTC (rev 128080)
@@ -138,13 +138,6 @@
 #endif
 
 #if ENABLE(NOTIFICATIONS)
-static void getAndAddEventListener(const AtomicString& eventName, const char* property, const Dictionary& options, Notification* notification)
-{
-    RefPtr<EventListener> listener = options.getEventListener(property, notification);
-    if (listener)
-        notification->addEventListener(eventName, listener.release(), false);
-}
-
 PassRefPtr<Notification> Notification::create(ScriptExecutionContext* context, const String& title, const Dictionary& options)
 {
     RefPtr<Notification> notification(adoptRef(new Notification(context, title)));
@@ -153,10 +146,6 @@
         notification->setBody(argument);
     if (options.get("tag", argument))
         notification->setTag(argument);
-    getAndAddEventListener(eventNames().showEvent, "onshow", options, notification.get());
-    getAndAddEventListener(eventNames().closeEvent, "onclose", options, notification.get());
-    getAndAddEventListener(eventNames().errorEvent, "onerror", options, notification.get());
-    getAndAddEventListener(eventNames().clickEvent, "onclick", options, notification.get());
 
     notification->suspendIfNeeded();
     return notification.release();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to