Title: [127171] trunk
Revision
127171
Author
[email protected]
Date
2012-08-30 12:46:13 -0700 (Thu, 30 Aug 2012)

Log Message

[Mac] Add testRunner.dumpWebNotificationCallbacks() to DRT
https://bugs.webkit.org/show_bug.cgi?id=95232
<rdar://problem/12190776>

Reviewed by Alexey Proskuryakov.

Source/WebKit/mac:

* WebKit.exp: Export WebNotification class.

Tools:

Add additional output when running test, if testRunner.dumpWebNotificationCallbacks() is called.

* DumpRenderTree/TestRunner.cpp:
(TestRunner::TestRunner):
(dumpWebNotificationCallbacksCallback):
(TestRunner::staticFunctions):
* DumpRenderTree/TestRunner.h:
(TestRunner):
(TestRunner::dumpWebNotificationCallbacks):
(TestRunner::setDumpWebNotificationCallbacks):
* DumpRenderTree/mac/MockWebNotificationProvider.mm:
(-[WebNotification _drt_descriptionSuitableForTestResult]):
(-[MockWebNotificationProvider webView:didShowNotification:]):
(-[MockWebNotificationProvider webView:didClickNotification:]):
(-[MockWebNotificationProvider webView:didCloseNotifications:]):
* DumpRenderTree/mac/UIDelegate.mm:
(-[UIDelegate webView:decidePolicyForNotificationRequestFromOrigin:listener:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (127170 => 127171)


--- trunk/Source/WebKit/mac/ChangeLog	2012-08-30 19:46:06 UTC (rev 127170)
+++ trunk/Source/WebKit/mac/ChangeLog	2012-08-30 19:46:13 UTC (rev 127171)
@@ -1,5 +1,15 @@
 2012-08-30  Jon Lee  <[email protected]>
 
+        [Mac] Add testRunner.dumpWebNotificationCallbacks() to DRT
+        https://bugs.webkit.org/show_bug.cgi?id=95232
+        <rdar://problem/12190776>
+
+        Reviewed by Alexey Proskuryakov.
+
+        * WebKit.exp: Export WebNotification class.
+
+2012-08-30  Jon Lee  <[email protected]>
+
         [Mac] Registering web views for notifications is unbalanced
         https://bugs.webkit.org/show_bug.cgi?id=95465
         <rdar://problem/12206765>

Modified: trunk/Source/WebKit/mac/WebKit.exp (127170 => 127171)


--- trunk/Source/WebKit/mac/WebKit.exp	2012-08-30 19:46:06 UTC (rev 127170)
+++ trunk/Source/WebKit/mac/WebKit.exp	2012-08-30 19:46:13 UTC (rev 127171)
@@ -25,6 +25,7 @@
 .objc_class_name_WebJavaScriptTextInputPanel
 .objc_class_name_WebKeyGenerator
 .objc_class_name_WebKitStatistics
+.objc_class_name_WebNotification
 .objc_class_name_WebPanelAuthenticationHandler
 .objc_class_name_WebPluginDatabase
 .objc_class_name_WebPreferences

Modified: trunk/Tools/ChangeLog (127170 => 127171)


--- trunk/Tools/ChangeLog	2012-08-30 19:46:06 UTC (rev 127170)
+++ trunk/Tools/ChangeLog	2012-08-30 19:46:13 UTC (rev 127171)
@@ -1,3 +1,29 @@
+2012-08-30  Jon Lee  <[email protected]>
+
+        [Mac] Add testRunner.dumpWebNotificationCallbacks() to DRT
+        https://bugs.webkit.org/show_bug.cgi?id=95232
+        <rdar://problem/12190776>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Add additional output when running test, if testRunner.dumpWebNotificationCallbacks() is called.
+
+        * DumpRenderTree/TestRunner.cpp:
+        (TestRunner::TestRunner):
+        (dumpWebNotificationCallbacksCallback):
+        (TestRunner::staticFunctions):
+        * DumpRenderTree/TestRunner.h:
+        (TestRunner):
+        (TestRunner::dumpWebNotificationCallbacks):
+        (TestRunner::setDumpWebNotificationCallbacks):
+        * DumpRenderTree/mac/MockWebNotificationProvider.mm:
+        (-[WebNotification _drt_descriptionSuitableForTestResult]):
+        (-[MockWebNotificationProvider webView:didShowNotification:]):
+        (-[MockWebNotificationProvider webView:didClickNotification:]):
+        (-[MockWebNotificationProvider webView:didCloseNotifications:]):
+        * DumpRenderTree/mac/UIDelegate.mm:
+        (-[UIDelegate webView:decidePolicyForNotificationRequestFromOrigin:listener:]):
+
 2012-08-30  Tommy Widenflycht  <[email protected]>
 
         MediaStream API: Introduce MediaConstraints

Modified: trunk/Tools/DumpRenderTree/TestRunner.cpp (127170 => 127171)


--- trunk/Tools/DumpRenderTree/TestRunner.cpp	2012-08-30 19:46:06 UTC (rev 127170)
+++ trunk/Tools/DumpRenderTree/TestRunner.cpp	2012-08-30 19:46:13 UTC (rev 127171)
@@ -69,6 +69,7 @@
     , m_dumpIconChanges(false)
     , m_dumpVisitedLinksCallback(false)
     , m_dumpWillCacheResponse(false)
+    , m_dumpWebNotificationCallbacks(false)
     , m_generatePixelResults(true)
     , m_callCloseOnWebViews(true)
     , m_canOpenWindows(false)
@@ -258,6 +259,13 @@
     return JSValueMakeUndefined(context);
 }
 
+static JSValueRef dumpWebNotificationCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
+    controller->setDumpWebNotificationCallbacks(true);
+    return JSValueMakeUndefined(context);
+}
+
 static JSValueRef pathToLocalResourceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     if (argumentCount < 1)
@@ -2333,6 +2341,7 @@
         { "dumpTitleChanges", dumpTitleChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "dumpIconChanges", dumpIconChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "dumpWillCacheResponse", dumpWillCacheResponseCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "dumpWebNotificationCallbacks", dumpWebNotificationCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "elementDoesAutoCompleteForElementWithId", elementDoesAutoCompleteForElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "encodeHostName", encodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "evaluateInWebInspector", evaluateInWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },

Modified: trunk/Tools/DumpRenderTree/TestRunner.h (127170 => 127171)


--- trunk/Tools/DumpRenderTree/TestRunner.h	2012-08-30 19:46:06 UTC (rev 127170)
+++ trunk/Tools/DumpRenderTree/TestRunner.h	2012-08-30 19:46:13 UTC (rev 127171)
@@ -221,7 +221,10 @@
     
     bool dumpWillCacheResponse() const { return m_dumpWillCacheResponse; }
     void setDumpWillCacheResponse(bool dumpWillCacheResponse) { m_dumpWillCacheResponse = dumpWillCacheResponse; }
-    
+
+    bool dumpWebNotificationCallbacks() const { return m_dumpWebNotificationCallbacks;}
+    void setDumpWebNotificationCallbacks(bool dumpWebNotificationCallbacks) { m_dumpWebNotificationCallbacks = dumpWebNotificationCallbacks; }
+
     bool callCloseOnWebViews() const { return m_callCloseOnWebViews; }
     void setCallCloseOnWebViews(bool callCloseOnWebViews) { m_callCloseOnWebViews = callCloseOnWebViews; }
 
@@ -397,6 +400,7 @@
     bool m_dumpIconChanges;
     bool m_dumpVisitedLinksCallback;
     bool m_dumpWillCacheResponse;
+    bool m_dumpWebNotificationCallbacks;
     bool m_generatePixelResults;
     bool m_callCloseOnWebViews;
     bool m_canOpenWindows;

Modified: trunk/Tools/DumpRenderTree/mac/MockWebNotificationProvider.mm (127170 => 127171)


--- trunk/Tools/DumpRenderTree/mac/MockWebNotificationProvider.mm	2012-08-30 19:46:06 UTC (rev 127170)
+++ trunk/Tools/DumpRenderTree/mac/MockWebNotificationProvider.mm	2012-08-30 19:46:13 UTC (rev 127171)
@@ -26,9 +26,25 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#import "config.h"
 #import "MockWebNotificationProvider.h"
+
+#import "DumpRenderTree.h"
+#import "TestRunner.h"
+#import <WebKit/WebNotification.h>
 #import <WebKit/WebSecurityOriginPrivate.h>
 
+@interface WebNotification (DRTExtras)
+- (NSString *)_drt_descriptionSuitableForTestResult;
+@end
+
+@implementation WebNotification (DRTExtras)
+- (NSString *)_drt_descriptionSuitableForTestResult
+{
+    return [NSString stringWithFormat:@"{title: \"%@\", body: \"%@\", tag: \"%@\", iconURL: %@}", [self title], [self body], [self tag], [self iconURL]];
+}
+@end
+
 @implementation MockWebNotificationProvider
 
 + (MockWebNotificationProvider *)shared
@@ -93,12 +109,22 @@
 
 - (void)webView:(WebView *)webView didShowNotification:(uint64_t)notificationID
 {
-    [_notifications.get(notificationID).get() dispatchShowEvent];
+    WebNotification *notification = _notifications.get(notificationID).get();
+    ASSERT(notification);
+
+    if (!done && gTestRunner->dumpWebNotificationCallbacks())
+        printf("SHOWED WEB NOTIFICATION %s\n", [[notification _drt_descriptionSuitableForTestResult] UTF8String]);
+    [notification dispatchShowEvent];
 }
 
 - (void)webView:(WebView *)webView didClickNotification:(uint64_t)notificationID
 {
-    [_notifications.get(notificationID).get() dispatchClickEvent];
+    WebNotification *notification = _notifications.get(notificationID).get();
+    ASSERT(notification);
+
+    if (!done && gTestRunner->dumpWebNotificationCallbacks())
+        printf("CLICKED WEB NOTIFICATION %s\n", [[notification _drt_descriptionSuitableForTestResult] UTF8String]);
+    [notification dispatchClickEvent];
 }
 
 - (void)webView:(WebView *)webView didCloseNotifications:(NSArray *)notificationIDs
@@ -107,7 +133,12 @@
         uint64_t id = [notificationID unsignedLongLongValue];
         NotificationIDMap::iterator it = _notifications.find(id);
         ASSERT(it != _notifications.end());
-        [it->second.get() dispatchCloseEvent];
+
+        WebNotification *notification = it->second.get();
+        if (!done && gTestRunner->dumpWebNotificationCallbacks())
+            printf("CLOSED WEB NOTIFICATION %s\n", [[notification _drt_descriptionSuitableForTestResult] UTF8String]);
+
+        [notification dispatchCloseEvent];
         _notifications.remove(it);
         _notificationViewMap.remove(id);
     }

Modified: trunk/Tools/DumpRenderTree/mac/UIDelegate.mm (127170 => 127171)


--- trunk/Tools/DumpRenderTree/mac/UIDelegate.mm	2012-08-30 19:46:06 UTC (rev 127170)
+++ trunk/Tools/DumpRenderTree/mac/UIDelegate.mm	2012-08-30 19:46:13 UTC (rev 127171)
@@ -291,6 +291,8 @@
 
 - (void)webView:(WebView *)webView decidePolicyForNotificationRequestFromOrigin:(WebSecurityOrigin *)origin listener:(id<WebAllowDenyPolicyListener>)listener
 {
+    if (!done && gTestRunner->dumpWebNotificationCallbacks())
+        printf("REQUESTED WEB NOTIFICATION PERMISSION FOR %s\n", [[origin stringValue] UTF8String]);
     [(MockWebNotificationProvider *)[webView _notificationProvider] setWebNotificationOrigin:[origin stringValue] permission:YES];
     [listener allow];
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to