Commit 2a69abdf authored by jonlee@apple.com's avatar jonlee@apple.com
Browse files

Safari 6 notifications' onclick handlers can't call window.open()

https://bugs.webkit.org/show_bug.cgi?id=96959
<rdar://problem/12132427>

Reviewed by Darin Adler.

Source/WebKit2:

The click is not being treated as a user gesture when the message is sent to the web process.

* WebProcess/Notifications/WebNotificationManager.cpp:
(WebKit::WebNotificationManager::didClickNotification): Gets called when the user clicks on the
platform notification. Set UserGestureIndicator to show the click event is due to user gesture.

LayoutTests:

The test shows and clicks a platform notification. The onclick handler calls window.open(),
which in turn calls a function on the main page to confirm that a window was opened.

* http/tests/notifications/legacy/window-show-on-click-expected.txt: Added.
* http/tests/notifications/legacy/window-show-on-click.html: Added.
* http/tests/notifications/resources/window-show-on-click.html: Added.
* http/tests/notifications/window-show-on-click-expected.txt: Added.
* http/tests/notifications/window-show-on-click.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@129140 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 24fe2012
2012-09-17 Jon Lee <jonlee@apple.com>
Safari 6 notifications' onclick handlers can't call window.open()
https://bugs.webkit.org/show_bug.cgi?id=96959
<rdar://problem/12132427>
Reviewed by Darin Adler.
The test shows and clicks a platform notification. The onclick handler calls window.open(),
which in turn calls a function on the main page to confirm that a window was opened.
* http/tests/notifications/legacy/window-show-on-click-expected.txt: Added.
* http/tests/notifications/legacy/window-show-on-click.html: Added.
* http/tests/notifications/resources/window-show-on-click.html: Added.
* http/tests/notifications/window-show-on-click-expected.txt: Added.
* http/tests/notifications/window-show-on-click.html: Added.
2012-09-20 Csaba Osztrogonác <ossy@webkit.org>
 
[Qt] Unreviewed gardening. Unskip fast/exclusions tests, because they pass now.
This test checks that a script can open windows when the user clicks on a native notification.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS webkitNotifications.checkPermission() is 0
PASS clicking on notification successfully opened a window
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<script src="/resources/js-test-pre.js"></script>
<script src="/resources/notifications-test-pre.js"></script>
<p id="description"></p>
<div id="console"></div>
<script>
if (window.testRunner) {
testRunner.grantWebNotificationPermission(testURL);
testRunner.setCanOpenWindows(true);
testRunner.waitUntilDone();
}
description("This test checks that a script can open windows when the user clicks on a native notification.");
shouldBe("webkitNotifications.checkPermission()", "0");
var n = webkitNotifications.createNotification("", "", "");
n.ondisplay = function() {
if (window.testRunner)
testRunner.simulateWebNotificationClick(this);
};
n.onclick = function() {
window.open('/notifications/resources/window-show-on-click.html');
};
n.show();
function onWindowOpen() {
testPassed('clicking on notification successfully opened a window');
testCompleted();
}
setTimeout(function() {
testFailed('clicking on notification did not open a window');
testCompleted();
}, 100);
</script>
<script>
window.onload = function() {
window.opener.onWindowOpen();
};
</script>
\ No newline at end of file
This test checks that a script can open windows when the user clicks on a native notification.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Notification.permission is "granted"
PASS clicking on notification successfully opened a window
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<script src="/resources/js-test-pre.js"></script>
<script src="/resources/notifications-test-pre.js"></script>
<p id="description"></p>
<div id="console"></div>
<script>
if (window.testRunner) {
testRunner.grantWebNotificationPermission(testURL);
testRunner.setCanOpenWindows(true);
testRunner.waitUntilDone();
}
description("This test checks that a script can open windows when the user clicks on a native notification.");
shouldBeEqualToString("Notification.permission", "granted");
var n = new Notification("Test");
n.onshow = function() {
if (window.testRunner)
testRunner.simulateWebNotificationClick(this);
};
n.onclick = function() {
window.open('/notifications/resources/window-show-on-click.html');
};
function onWindowOpen() {
testPassed('clicking on notification successfully opened a window');
testCompleted();
}
setTimeout(function() {
testFailed('clicking on notification did not open a window');
testCompleted();
}, 100);
</script>
2012-09-17 Jon Lee <jonlee@apple.com>
Safari 6 notifications' onclick handlers can't call window.open()
https://bugs.webkit.org/show_bug.cgi?id=96959
<rdar://problem/12132427>
Reviewed by Darin Adler.
The click is not being treated as a user gesture when the message is sent to the web process.
* WebProcess/Notifications/WebNotificationManager.cpp:
(WebKit::WebNotificationManager::didClickNotification): Gets called when the user clicks on the
platform notification. Set UserGestureIndicator to show the click event is due to user gesture.
2012-09-20 Eunmi Lee <eunmi15.lee@samsung.com>
 
[EFL][WK2] Add APIs to create, delete and get ewk_context.
......
......@@ -39,6 +39,7 @@
#include <WebCore/ScriptExecutionContext.h>
#include <WebCore/SecurityOrigin.h>
#include <WebCore/Settings.h>
#include <WebCore/UserGestureIndicator.h>
#endif
using namespace WebCore;
......@@ -243,6 +244,8 @@ void WebNotificationManager::didClickNotification(uint64_t notificationID)
if (!notification)
return;
// Indicate that this event is being dispatched in reaction to a user's interaction with a platform notification.
UserGestureIndicator indicator(DefinitelyProcessingUserGesture);
notification->dispatchClickEvent();
#else
UNUSED_PARAM(notificationID);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment