Skip to content
Permalink
Browse files
Source/WebCore: [Mac] Add SPI to WK1 to retrieve internal IDs for web…
… notifications

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

Reviewed by Jessie Berlin.

This is work toward providing Mac support for web notifications in DRT and WTR (77969).

Expose functions to convert JSValue to Notification, and to get the NotificationController from a page.

* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj: Promote NotificationController.h and JSNotification.h to private headers.

Source/WebKit/mac: [Mac] Add SPI to WK1 to retrieve internal IDs for web notifications
https://bugs.webkit.org/show_bug.cgi?id=95099
<rdar://problem/12180186>

Reviewed by Jessie Berlin.

This is work toward providing Mac support for web notifications in DRT and WTR (77969).

Add function to retrieve the internal ID for a notification. This is needed by layout tests to support simulating
a user click on a notification.

* WebCoreSupport/WebNotificationClient.h:
(WebNotificationClient):
* WebCoreSupport/WebNotificationClient.mm:
(WebNotificationClient::notificationIDForTesting): Converts the JS notification to a WebCore notification, and passes
that to [WebView _notificationIDForTesting:].
* WebView/WebView.mm:
(-[WebView _notificationIDForTesting:]): Retrieves the notification ID based on the WebCore notification instance.
* WebView/WebViewPrivate.h:

Tools: Update TestRunner API for web notifications
https://bugs.webkit.org/show_bug.cgi?id=95093
<rdar://problem/12179649>

Reviewed by Jessie Berlin.

This is work toward providing Mac support for web notifications in DRT and WTR (77969).

Some of the legacy APIs are less than ideal, and not tenable with the WTR infrastructure.
This first patch renames the TestRunner calls to use the term "web notifications" instead of
"desktop notifications", deprecates a couple API calls that are not used by anyone, and adds
additional calls that will be used in the tests that test the standard API.

* DumpRenderTree/TestRunner.h:
(TestRunner): For consistency, rename a couple member variables. Remove unused checkDesktopNotificationPermission()
and areDesktopNotificationPermissionRequestsIgnored(). Remove origin mapping since each port implements its own solution.
* DumpRenderTree/TestRunner.cpp: Push grantWebNotificationPermission() to individual ports.
(TestRunner::TestRunner):
(ignoreLegacyWebNotificationPermissionRequestsCallback): Renamed.
(simulateLegacyWebNotificationClickCallback): Renamed.
(grantWebNotificationPermissionCallback): Renamed.
(denyWebNotificationPermissionCallback): Added.
(removeAllWebNotificationPermissionsCallback): Added.
(simulateWebNotificationClickCallback): Added.
(TestRunner::staticFunctions):
(TestRunner::ignoreLegacyWebNotificationPermissionRequests):

* DumpRenderTree/chromium/DRTTestRunner.cpp:
(DRTTestRunner::DRTTestRunner): Added bindings for new APIs.
(DRTTestRunner::grantWebNotificationPermission):
(DRTTestRunner::denyWebNotificationPermission): Stub.
(DRTTestRunner::removeAllWebNotificationPermissions): Stub.
(DRTTestRunner::simulateWebNotificationClick): Stub.
(DRTTestRunner::simulateLegacyWebNotificationClick):
* DumpRenderTree/chromium/DRTTestRunner.h:
(DRTTestRunner):

Added stubs.
* DumpRenderTree/blackberry/TestRunnerBlackBerry.cpp:
* DumpRenderTree/efl/TestRunnerEfl.cpp:
* DumpRenderTree/gtk/TestRunnerGtk.cpp:
* DumpRenderTree/mac/TestRunnerMac.mm: Later patch will contain implementation of this API.
* DumpRenderTree/qt/TestRunnerQt.cpp: Added Qt-based stubs.
* DumpRenderTree/win/TestRunnerWin.cpp:

LayoutTests: Update TestRunner API for web notifications
https://bugs.webkit.org/show_bug.cgi?id=95093
<rdar://problem/12179649>

Reviewed by Jessie Berlin.

This is work toward providing Mac support for web notifications in DRT and WTR (77969).

Refactor the tests to use the renamed legacy API calls.

* fast/notifications/notifications-check-permission.html:
* fast/notifications/notifications-click-event-focus.html:
* fast/notifications/notifications-click-event.html:
* fast/notifications/notifications-display-close-events.html:
* fast/notifications/notifications-document-close-crash.html: Also, convert from Windows to UNIX line endings.
* fast/notifications/notifications-double-show.html:
* fast/notifications/notifications-event-stop-propagation.html-disabled:
* fast/notifications/notifications-multi-events.html-disabled:
* fast/notifications/notifications-no-icon.html:
* fast/notifications/notifications-replace.html:
* fast/notifications/notifications-rtl.html:
* fast/notifications/notifications-with-permission.html:
* fast/notifications/notifications-without-permission.html:
* fast/notifications/resources/notifications-cancel-request-permission.html:
* platform/qt-5.0-wk2/Skipped:

Canonical link: https://commits.webkit.org/113086@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@126909 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
qanat committed Aug 28, 2012
1 parent 9beabac commit 75908ec5aca9fe56878aa1f4824f5ad3f3b88d58
Showing 36 changed files with 415 additions and 138 deletions.
@@ -1,3 +1,31 @@
2012-08-24 Jon Lee <jonlee@apple.com>

Update TestRunner API for web notifications
https://bugs.webkit.org/show_bug.cgi?id=95093
<rdar://problem/12179649>

Reviewed by Jessie Berlin.

This is work toward providing Mac support for web notifications in DRT and WTR (77969).

Refactor the tests to use the renamed legacy API calls.

* fast/notifications/notifications-check-permission.html:
* fast/notifications/notifications-click-event-focus.html:
* fast/notifications/notifications-click-event.html:
* fast/notifications/notifications-display-close-events.html:
* fast/notifications/notifications-document-close-crash.html: Also, convert from Windows to UNIX line endings.
* fast/notifications/notifications-double-show.html:
* fast/notifications/notifications-event-stop-propagation.html-disabled:
* fast/notifications/notifications-multi-events.html-disabled:
* fast/notifications/notifications-no-icon.html:
* fast/notifications/notifications-replace.html:
* fast/notifications/notifications-rtl.html:
* fast/notifications/notifications-with-permission.html:
* fast/notifications/notifications-without-permission.html:
* fast/notifications/resources/notifications-cancel-request-permission.html:
* platform/qt-5.0-wk2/Skipped:

2012-08-28 Dominic Mazzoni <dmazzoni@google.com>

AX: Should be able to tab to focus a link in a canvas subtree
@@ -25,7 +25,7 @@
}

if (window.testRunner) {
testRunner.grantDesktopNotificationPermission("file://");
testRunner.grantWebNotificationPermission("file://");
}

N = window.webkitNotifications.checkPermission();
@@ -10,7 +10,7 @@
function runTests()
{
if (window.testRunner) {
testRunner.grantDesktopNotificationPermission("file://");
testRunner.grantWebNotificationPermission("file://");
testRunner.dumpAsText();
testRunner.waitUntilDone();
testRunner.setCanOpenWindows();
@@ -32,7 +32,7 @@
N.show();

if (window.testRunner) {
testRunner.simulateDesktopNotificationClick("New E-mail");
testRunner.simulateLegacyWebNotificationClick("New E-mail");
testRunner.notifyDone();
}
}
@@ -10,7 +10,7 @@
function runTests()
{
if (window.testRunner) {
testRunner.grantDesktopNotificationPermission("file://");
testRunner.grantWebNotificationPermission("file://");
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
@@ -23,7 +23,7 @@
N.onclick = function() { log("PASS: click event fired."); N.cancel(); }
N.show();
if (window.testRunner) {
testRunner.simulateDesktopNotificationClick("New E-mail");
testRunner.simulateLegacyWebNotificationClick("New E-mail");
testRunner.notifyDone();
}
}
@@ -10,7 +10,7 @@
function runTests()
{
if (window.testRunner) {
testRunner.grantDesktopNotificationPermission("file://");
testRunner.grantWebNotificationPermission("file://");
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
@@ -1,50 +1,50 @@
<html>
<body>
<div id="result"></div>
<script>
if (window.testRunner)
{
testRunner.dumpAsText();
testRunner.setCanOpenWindows();
testRunner.grantDesktopNotificationPermission("file://");
testRunner.waitUntilDone();
}
if (!window.webkitNotifications) {
log("FAIL: No webkitNotifications interface!");
}

var target = window.open("about:blank");
var notification = target.webkitNotifications;
target.location.reload();
var timer = setInterval("crash()", 60);
setTimeout("finish()", 100);

function crash()
{
var a = [];
for (var i = 0; i < 0x100; i++)
{
try
{
a.push(new WebGLByteArray());
}
catch (e) {}
a.push(Array(i).join("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
}
delete a;
notification.requestPermission();
}
function finish()
{
clearInterval(timer);
document.getElementById("result").innerHTML = "PASS";
target.close();
if (window.testRunner)
testRunner.notifyDone();
}
</script>
</body>
</html>
<html>
<body>
<div id="result"></div>
<script>
if (window.testRunner)
{
testRunner.dumpAsText();
testRunner.setCanOpenWindows();
testRunner.grantWebNotificationPermission("file://");
testRunner.waitUntilDone();
}

if (!window.webkitNotifications) {
log("FAIL: No webkitNotifications interface!");
}

var target = window.open("about:blank");
var notification = target.webkitNotifications;
target.location.reload();
var timer = setInterval("crash()", 60);
setTimeout("finish()", 100);

function crash()
{
var a = [];
for (var i = 0; i < 0x100; i++)
{
try
{
a.push(new WebGLByteArray());
}
catch (e) {}
a.push(Array(i).join("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
}
delete a;
notification.requestPermission();
}

function finish()
{
clearInterval(timer);
document.getElementById("result").innerHTML = "PASS";
target.close();
if (window.testRunner)
testRunner.notifyDone();
}
</script>
</body>
</html>

@@ -10,7 +10,7 @@
function runTests()
{
if (window.testRunner) {
testRunner.grantDesktopNotificationPermission("file://");
testRunner.grantWebNotificationPermission("file://");
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
@@ -10,7 +10,7 @@
function runTests()
{
if (window.testRunner) {
testRunner.grantDesktopNotificationPermission("file://");
testRunner.grantWebNotificationPermission("file://");
testRunner.dumpAsText();
}

@@ -10,7 +10,7 @@
function runTests()
{
if (window.testRunner) {
testRunner.grantDesktopNotificationPermission("file://");
testRunner.grantWebNotificationPermission("file://");
testRunner.dumpAsText();
}

@@ -10,7 +10,7 @@
function runTests()
{
if (window.testRunner) {
testRunner.grantDesktopNotificationPermission("file://");
testRunner.grantWebNotificationPermission("file://");
testRunner.dumpAsText();
}

@@ -10,7 +10,7 @@
function runTests()
{
if (window.testRunner) {
testRunner.grantDesktopNotificationPermission("file://");
testRunner.grantWebNotificationPermission("file://");
testRunner.dumpAsText();
}

@@ -10,7 +10,7 @@
function runTests()
{
if (window.testRunner) {
testRunner.grantDesktopNotificationPermission("file://");
testRunner.grantWebNotificationPermission("file://");
testRunner.dumpAsText();
}

@@ -10,7 +10,7 @@
function runTests()
{
if (window.testRunner) {
testRunner.grantDesktopNotificationPermission("file://");
testRunner.grantWebNotificationPermission("file://");
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
@@ -10,7 +10,7 @@
function runTests()
{
if (window.testRunner) {
// NO PERMISSION testRunner.grantDesktopNotificationPermission("file://");
// NO PERMISSION testRunner.grantWebNotificationPermission("file://");
testRunner.dumpAsText();
}

@@ -13,7 +13,7 @@
}

if (window.testRunner) {
testRunner.ignoreDesktopNotificationPermissionRequests();
testRunner.ignoreLegacyWebNotificationPermissionRequests();
}

window.webkitNotifications.requestPermission(
@@ -141,7 +141,7 @@ fast/text/format-control.html
fast/url/anchor.html
http/tests/websocket/tests/hixie76/bad-sub-protocol-non-ascii.html

# layoutTestController.ignoreDesktopNotificationPermissionRequests is unimplemented
# layoutTestController.ignoreLegacyWebNotificationPermissionRequests is unimplemented
fast/notifications

# layoutTestController.setScrollbarPolicy is unimplemented
@@ -1,3 +1,18 @@
2012-08-27 Jon Lee <jonlee@apple.com>

[Mac] Add SPI to WK1 to retrieve internal IDs for web notifications
https://bugs.webkit.org/show_bug.cgi?id=95099
<rdar://problem/12180186>

Reviewed by Jessie Berlin.

This is work toward providing Mac support for web notifications in DRT and WTR (77969).

Expose functions to convert JSValue to Notification, and to get the NotificationController from a page.

* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj: Promote NotificationController.h and JSNotification.h to private headers.

2012-08-28 Dominic Mazzoni <dmazzoni@google.com>

AX: Should be able to tab to focus a link in a canvas subtree
@@ -2323,7 +2323,9 @@ __ZN7WebCore12Notification17dispatchShowEventEv
__ZN7WebCore12Notification18dispatchClickEventEv
__ZN7WebCore12Notification18dispatchCloseEventEv
__ZN7WebCore12Notification18dispatchErrorEventEv
__ZN7WebCore14toNotificationEN3JSC7JSValueE
__ZN7WebCore19provideNotificationEPNS_4PageEPNS_18NotificationClientE
__ZN7WebCore22NotificationController10clientFromEPNS_4PageE
#endif

#if ENABLE(NOTIFICATIONS)
@@ -869,7 +869,7 @@
31288E740E3005D6003619AE /* WebKitCSSKeyframesRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31288E700E3005D6003619AE /* WebKitCSSKeyframesRule.cpp */; };
31288E750E3005D6003619AE /* WebKitCSSKeyframesRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 31288E710E3005D6003619AE /* WebKitCSSKeyframesRule.h */; };
3128CA68147331520074C72A /* NotificationController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3128CA67147331520074C72A /* NotificationController.cpp */; };
3128CA6B147331630074C72A /* NotificationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3128CA6A147331630074C72A /* NotificationController.h */; };
3128CA6B147331630074C72A /* NotificationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3128CA6A147331630074C72A /* NotificationController.h */; settings = {ATTRIBUTES = (Private, ); }; };
312C0C41146DC6CC0016C911 /* Notification.h in Headers */ = {isa = PBXBuildFile; fileRef = 333F704F0FB49CA2008E12A6 /* Notification.h */; settings = {ATTRIBUTES = (Private, ); }; };
312D67B11535691F00563D0D /* Dictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 312D67B01535691F00563D0D /* Dictionary.cpp */; };
31313F651443B35F006E2A90 /* FilterEffectRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31313F631443B35E006E2A90 /* FilterEffectRenderer.cpp */; };
@@ -952,7 +952,7 @@
3314ACEC10892086000F0E56 /* JSExceptionBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 3314ACEA10892086000F0E56 /* JSExceptionBase.h */; };
33503C9A10179A74003B47E1 /* NotificationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 33503C9910179A74003B47E1 /* NotificationClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
33503CA310179AD7003B47E1 /* JSNotification.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33503C9F10179AD7003B47E1 /* JSNotification.cpp */; };
33503CA410179AD7003B47E1 /* JSNotification.h in Headers */ = {isa = PBXBuildFile; fileRef = 33503CA010179AD7003B47E1 /* JSNotification.h */; };
33503CA410179AD7003B47E1 /* JSNotification.h in Headers */ = {isa = PBXBuildFile; fileRef = 33503CA010179AD7003B47E1 /* JSNotification.h */; settings = {ATTRIBUTES = (Private, ); }; };
33503CA510179AD7003B47E1 /* JSNotificationCenter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33503CA110179AD7003B47E1 /* JSNotificationCenter.cpp */; };
33503CA610179AD7003B47E1 /* JSNotificationCenter.h in Headers */ = {isa = PBXBuildFile; fileRef = 33503CA210179AD7003B47E1 /* JSNotificationCenter.h */; };
33503CC010179C1A003B47E1 /* JSDesktopNotificationsCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33503CBF10179C1A003B47E1 /* JSDesktopNotificationsCustom.cpp */; };
@@ -1,3 +1,25 @@
2012-08-28 Jon Lee <jonlee@apple.com>

[Mac] Add SPI to WK1 to retrieve internal IDs for web notifications
https://bugs.webkit.org/show_bug.cgi?id=95099
<rdar://problem/12180186>

Reviewed by Jessie Berlin.

This is work toward providing Mac support for web notifications in DRT and WTR (77969).

Add function to retrieve the internal ID for a notification. This is needed by layout tests to support simulating
a user click on a notification.

* WebCoreSupport/WebNotificationClient.h:
(WebNotificationClient):
* WebCoreSupport/WebNotificationClient.mm:
(WebNotificationClient::notificationIDForTesting): Converts the JS notification to a WebCore notification, and passes
that to [WebView _notificationIDForTesting:].
* WebView/WebView.mm:
(-[WebView _notificationIDForTesting:]): Retrieves the notification ID based on the WebCore notification instance.
* WebView/WebViewPrivate.h:

2012-08-27 Sheriff Bot <webkit.review.bot@gmail.com>

Unreviewed, rolling out r126836.
@@ -48,6 +48,11 @@ class WebNotificationClient : public WebCore::NotificationClient {
WebNotificationClient(WebView *);
WebView *webView() { return m_webView; }

#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
// For testing purposes.
uint64_t notificationIDForTesting(WebCore::Notification*);
#endif

private:
virtual bool show(WebCore::Notification*) OVERRIDE;
virtual void cancel(WebCore::Notification*) OVERRIDE;
@@ -230,6 +230,11 @@ static uint64_t generateNotificationID()
}

#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
uint64_t WebNotificationClient::notificationIDForTesting(WebCore::Notification* notification)
{
return [m_notificationMap.get(notification).get() notificationID];
}

@implementation WebNotificationPolicyListener

#if ENABLE(NOTIFICATIONS)

0 comments on commit 75908ec

Please sign in to comment.