Source/WebKit2: [WKTR] WebKitTestRunner's eventSender.contextClick() returns objects...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Sep 2013 09:27:16 +0000 (09:27 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Sep 2013 09:27:16 +0000 (09:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=98410

Patch by Wojciech Bielawski <w.bielawski@samsung.com> on 2013-09-16
Reviewed by Darin Adler.

Add API required to implement click() method for context menu entry, used by WebkitTestRunner::EventSender.

* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageClickMenuItem):
(WKBundlePageCopyContextMenuItemTitle):
(WKBundlePageGetContextMenuItems):
* WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:

Tools: [WKTR] WebKitTestRunner's eventSender.contextClick() returns objects without implemented click() method.
https://bugs.webkit.org/show_bug.cgi?id=98410

Patch by Wojciech Bielawski <w.bielawski@samsung.com> on 2013-09-16
Reviewed by Darin Adler.

Add implementation of click() method of objects returned by eventSender.contextClick().

* WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
(MenuItemPrivateData):
(WTR::menuItemClickCallback):
(WTR::getMenuItemTitleCallback):
(WTR::staticMenuItemFinalize):
(WTR::getMenuItemClass):
(WTR::EventSendingController::contextClick):

LayoutTests: [WKTR] Add implementation of click() method of objects returned by eventSender.contextClick().
https://bugs.webkit.org/show_bug.cgi?id=98410

Patch by Wojciech Bielawski <w.bielawski@samsung.com> on 2013-09-16
Reviewed by Darin Adler.

Unskipping tests related with click() method.

* platform/efl-wk2/TestExpectations: Corrected bug number for tests:
 editing/pasteboard/can-read-in-copy-and-cut-events.html
 editing/pasteboard/can-read-in-dragstart-event.html
* platform/gtk-wk2/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@155847 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/efl-wk2/TestExpectations
LayoutTests/platform/gtk-wk2/TestExpectations
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp

index 2ecc26a2a93b4ef23076d1ea6da5f78231b99558..c41d331c8f50f5f182b49460eb7dc1d0c176323e 100644 (file)
@@ -1,3 +1,17 @@
+2013-09-16  Wojciech Bielawski  <w.bielawski@samsung.com>
+
+        [WKTR] Add implementation of click() method of objects returned by eventSender.contextClick().
+        https://bugs.webkit.org/show_bug.cgi?id=98410
+
+        Reviewed by Darin Adler.
+
+        Unskipping tests related with click() method.
+
+        * platform/efl-wk2/TestExpectations: Corrected bug number for tests:
+         editing/pasteboard/can-read-in-copy-and-cut-events.html
+         editing/pasteboard/can-read-in-dragstart-event.html
+        * platform/gtk-wk2/TestExpectations:
+
 2013-09-15  Zalan Bujtas  <zalan@apple.com>
 
         Attempt to fix a local flakiness on Lion.
index 9de9690c41f97614aaca617d46b25739a2fb564e..0ecabc367209d7487af492efd6ee0512f9ee8f77 100644 (file)
@@ -308,11 +308,8 @@ webkit.org/b/99562 http/tests/plugins/post-url-file.html [ Failure ]
 # Comparison of two javascript objects in C++ is failing.
 webkit.org/b/98739 plugins/npruntime/embed-property-equality.html [ Failure ]
 
-# EFL's EventSender contextClick should return objects that implements click() method
-webkit.org/b/98410 editing/pasteboard/can-read-in-copy-and-cut-events.html [ Failure ]
-webkit.org/b/98410 editing/pasteboard/can-read-in-dragstart-event.html [ Failure ]
-webkit.org/b/98410 editing/pasteboard/copy-standalone-image-crash.html [ Failure ]
-webkit.org/b/98410 media/context-menu-actions.html [ Failure ]
+webkit.org/b/113094 editing/pasteboard/can-read-in-copy-and-cut-events.html [ Failure ]
+webkit.org/b/113094 editing/pasteboard/can-read-in-dragstart-event.html [ Failure ]
 
 webkit.org/b/102201 fast/dom/Window/open-window-min-size.html [ Failure ]
 
index b8c5257ee7d3fc77664a3f26d8045b57f4c0ba2c..64c99687aa88240fcb8c0edbd8bc622b744cac81 100644 (file)
@@ -485,9 +485,6 @@ Bug(GTK) plugins/resize-from-plugin.html [ Failure ]
 Bug(GTK) editing/selection/context-menu-text-selection.html [ Failure Pass ]
 Bug(GTK) editing/spelling/context-menu-suggestions.html [ Failure ]
 
-# EventSender's contextClick should return objects that implements click() method
-webkit.org/b/98410 editing/pasteboard/copy-standalone-image-crash.html [ Timeout ]
-
 # An oncontextmenu attribute is not called.
 Bug(GTK) editing/spelling/spellcheck-input-search-crash.html [ Failure ]
 Bug(GTK) fast/events/contextmenu-scrolled-page-with-frame.html [ Failure ]
index 42949c90a659f27d4d63dc6c75da4d0faa90aab6..82ff24b0c374aa41717b5ce35ae16f1b6e00d8cf 100644 (file)
@@ -1,3 +1,18 @@
+2013-09-16  Wojciech Bielawski  <w.bielawski@samsung.com>
+
+        [WKTR] WebKitTestRunner's eventSender.contextClick() returns objects without implemented click() method.
+        https://bugs.webkit.org/show_bug.cgi?id=98410
+
+        Reviewed by Darin Adler.
+
+        Add API required to implement click() method for context menu entry, used by WebkitTestRunner::EventSender.
+
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+        (WKBundlePageClickMenuItem):
+        (WKBundlePageCopyContextMenuItemTitle):
+        (WKBundlePageGetContextMenuItems):
+        * WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:
+
 2013-09-15  Gustavo Noronha Silva  <gns@gnome.org>
 
         Unreviewed make distcheck fix.
index 6cce522293f102ef5a7e755e621bd0d4fd912dc9..f9db003ae2b071fb0f750390cf101f862c9d51ea 100644 (file)
@@ -148,17 +148,25 @@ WKBundleFrameRef WKBundlePageGetMainFrame(WKBundlePageRef pageRef)
     return toAPI(toImpl(pageRef)->mainWebFrame());
 }
 
-WKArrayRef WKBundlePageCopyContextMenuItemTitles(WKBundlePageRef pageRef)
+void WKBundlePageClickMenuItem(WKBundlePageRef pageRef, WKContextMenuItemRef item)
+{
+#if ENABLE(CONTEXT_MENUS)
+    toImpl(pageRef)->contextMenu()->itemSelected(*toImpl(item)->data());
+#endif
+}
+
+WKArrayRef WKBundlePageCopyContextMenuItems(WKBundlePageRef pageRef)
 {
 #if ENABLE(CONTEXT_MENUS)
     WebContextMenu* contextMenu = toImpl(pageRef)->contextMenu();
     const Vector<WebContextMenuItemData> &items = contextMenu->items();
     size_t arrayLength = items.size();
-    OwnArrayPtr<WKTypeRef> itemNames = adoptArrayPtr(new WKTypeRef[arrayLength]);
+
+    OwnArrayPtr<WKTypeRef> wkItems = adoptArrayPtr(new WKTypeRef[arrayLength]);
     for (size_t i = 0; i < arrayLength; ++i)
-        itemNames[i] = WKStringCreateWithUTF8CString(items[i].title().utf8().data());
+        wkItems[i] = toAPI(WebContextMenuItem::create(items[i]).leakRef());
 
-    return WKArrayCreateAdoptingValues(itemNames.get(), arrayLength);
+    return WKArrayCreate(wkItems.get(), arrayLength);
 #else
     return 0;
 #endif
index b52dc13cf2c2d10bb2bfe8b52fa84a6cf90732bf..27ae429a3d58b8cb1be7d5a050f847e6eaba2750 100644 (file)
@@ -78,7 +78,9 @@ WK_EXPORT bool WKBundlePageCanShowMIMEType(WKBundlePageRef, WKStringRef mimeType
 WK_EXPORT void* WKAccessibilityRootObject(WKBundlePageRef);
 WK_EXPORT void* WKAccessibilityFocusedObject(WKBundlePageRef);
 
-WK_EXPORT WKArrayRef WKBundlePageCopyContextMenuItemTitles(WKBundlePageRef);
+WK_EXPORT WKStringRef WKBundlePageCopyContextMenuItemTitle(WKContextMenuItemRef);
+WK_EXPORT void WKBundlePageClickMenuItem(WKBundlePageRef, WKContextMenuItemRef);
+WK_EXPORT WKArrayRef WKBundlePageCopyContextMenuItems(WKBundlePageRef);
 WK_EXPORT WKArrayRef WKBundlePageCopyContextMenuAtPointInWindow(WKBundlePageRef, WKPoint);
 
 // This only works if the SuppressesIncrementalRendering preference is set as well.
index 5834a7a99de94294c7bb05360970f0627da67460..1de4e77f2b9f41c760da7020d8855878147536b4 100644 (file)
@@ -1,3 +1,20 @@
+2013-09-16  Wojciech Bielawski  <w.bielawski@samsung.com>
+
+        [WKTR] WebKitTestRunner's eventSender.contextClick() returns objects without implemented click() method.
+        https://bugs.webkit.org/show_bug.cgi?id=98410
+
+        Reviewed by Darin Adler.
+
+        Add implementation of click() method of objects returned by eventSender.contextClick().
+
+        * WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
+        (MenuItemPrivateData):
+        (WTR::menuItemClickCallback):
+        (WTR::getMenuItemTitleCallback):
+        (WTR::staticMenuItemFinalize):
+        (WTR::getMenuItemClass):
+        (WTR::EventSendingController::contextClick):
+
 2013-09-15  Zan Dobersek  <zdobersek@igalia.com>
 
         Make the GDB webkit.py script compatible with Python v3
index 549b941a3707d19943bc318150280ab07ea9d24b..15680a1e598e88c2daad1b52757cb6d48bdc2563 100644 (file)
@@ -34,6 +34,7 @@
 #include <WebKit2/WKBundleFrame.h>
 #include <WebKit2/WKBundlePagePrivate.h>
 #include <WebKit2/WKBundlePrivate.h>
+#include <WebKit2/WKContextMenuItem.h>
 #include <WebKit2/WKMutableDictionary.h>
 #include <WebKit2/WKNumber.h>
 
@@ -41,6 +42,68 @@ namespace WTR {
 
 static const float ZoomMultiplierRatio = 1.2f;
 
+struct MenuItemPrivateData {
+    MenuItemPrivateData(WKBundlePageRef page, WKContextMenuItemRef item) :
+        m_page(page),
+        m_item(item) { }
+    WKBundlePageRef m_page;
+    WKRetainPtr<WKContextMenuItemRef> m_item;
+};
+
+
+static JSValueRef menuItemClickCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    MenuItemPrivateData* privateData = static_cast<MenuItemPrivateData*>(JSObjectGetPrivate(thisObject));
+    WKBundlePageClickMenuItem(privateData->m_page, privateData->m_item.get());
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef getMenuItemTitleCallback(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+    MenuItemPrivateData* privateData = static_cast<MenuItemPrivateData*>(JSObjectGetPrivate(object));
+    WKRetainPtr<WKStringRef> wkTitle(AdoptWK, WKContextMenuItemCopyTitle(privateData->m_item.get()));
+    return JSValueMakeString(context, toJS(wkTitle).get());
+}
+
+static JSStaticFunction staticMenuItemFunctions[] = {
+    { "click", menuItemClickCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+    { 0, 0, 0 }
+};
+
+static JSStaticValue staticMenuItemValues[] = {
+    { "title", getMenuItemTitleCallback, 0, kJSPropertyAttributeReadOnly },
+    { 0, 0, 0, 0 }
+};
+
+static void staticMenuItemFinalize(JSObjectRef object)
+{
+    delete static_cast<MenuItemPrivateData*>(JSObjectGetPrivate(object));
+}
+
+static JSValueRef staticConvertMenuItemToType(JSContextRef context, JSObjectRef object, JSType type, JSValueRef* exception)
+{
+    if (kJSTypeString == type)
+        return getMenuItemTitleCallback(context, object, 0, 0);
+    return 0;
+}
+
+static JSClassRef getMenuItemClass()
+{
+    static JSClassRef menuItemClass = 0;
+
+    if (!menuItemClass) {
+        JSClassDefinition classDefinition = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+        classDefinition.staticFunctions = staticMenuItemFunctions;
+        classDefinition.staticValues = staticMenuItemValues;
+        classDefinition.finalize = staticMenuItemFinalize;
+        classDefinition.convertToType = staticConvertMenuItemToType;
+
+        menuItemClass = JSClassCreate(&classDefinition);
+    }
+
+    return menuItemClass;
+}
+
 static WKEventModifiers parseModifier(JSStringRef modifier)
 {
     if (JSStringIsEqualToUTF8CString(modifier, "ctrlKey"))
@@ -316,19 +379,15 @@ JSValueRef EventSendingController::contextClick()
     mouseDown(2, 0);
     mouseUp(2, 0);
 
-    WKRetainPtr<WKArrayRef> entriesNames = adoptWK(WKBundlePageCopyContextMenuItemTitles(page));
-    JSRetainPtr<JSStringRef> jsPropertyName(Adopt, JSStringCreateWithUTF8CString("title"));
-    size_t entriesSize = WKArrayGetSize(entriesNames.get());
+    WKRetainPtr<WKArrayRef> menuEntries = adoptWK(WKBundlePageCopyContextMenuItems(page));
+    size_t entriesSize = WKArrayGetSize(menuEntries.get());
     OwnArrayPtr<JSValueRef> jsValuesArray = adoptArrayPtr(new JSValueRef[entriesSize]);
     for (size_t i = 0; i < entriesSize; ++i) {
-        ASSERT(WKGetTypeID(WKArrayGetItemAtIndex(entriesNames.get(), i)) == WKStringGetTypeID());
-
-        WKStringRef wkEntryName = static_cast<WKStringRef>(WKArrayGetItemAtIndex(entriesNames.get(), i));
-        JSObjectRef jsItemObject = JSObjectMake(context, /* JSClassRef */0, /* privData */0);
-        JSRetainPtr<JSStringRef> jsNameCopy(Adopt, WKStringCopyJSString(wkEntryName));
-        JSValueRef jsEntryName = JSValueMakeString(context, jsNameCopy.get());
-        JSObjectSetProperty(context, jsItemObject, jsPropertyName.get(), jsEntryName, kJSPropertyAttributeReadOnly, 0);
-        jsValuesArray[i] = jsItemObject;
+        ASSERT(WKGetTypeID(WKArrayGetItemAtIndex(menuEntries.get(), i)) == WKContextMenuItemGetTypeID());
+
+        WKContextMenuItemRef item = static_cast<WKContextMenuItemRef>(WKArrayGetItemAtIndex(menuEntries.get(), i));
+        MenuItemPrivateData* privateData = new MenuItemPrivateData(page, item);
+        jsValuesArray[i] = JSObjectMake(context, getMenuItemClass(), privateData);
     }
 
     return JSObjectMakeArray(context, entriesSize, jsValuesArray.get(), 0);