2010-07-14 Johnny Ding <jnd@chromium.org>
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Jul 2010 21:03:03 +0000 (21:03 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Jul 2010 21:03:03 +0000 (21:03 +0000)
        Reviewed by Adam Barth.

        https://bugs.webkit.org/show_bug.cgi?id=41292
        Set right UserGestureIndicator to indicate whether the NPN_Evaluate allows popup window or not.

        Test: plugins/plugin-initiate-popup-window.html

        * bindings/v8/NPV8Object.cpp:
        (_NPN_EvaluateHelper):
2010-07-14  Johnny Ding  <jnd@chromium.org>

        Reviewed by Adam Barth.

        https://bugs.webkit.org/show_bug.cgi?id=41292
        Add a test to initiate popup windows from plugin during plugin is handling mouse/keyboard event.
        Disable this test on gtk/qt/win since the test plugin in those platforms didn't implement NPP_HandleEvent.

        * platform/chromium/test_expectations.txt:
        * platform/gtk/Skipped:
        * platform/qt/Skipped:
        * platform/win/Skipped:
        * plugins/plugin-initiate-popup-window-expected.txt: Added.
        * plugins/plugin-initiate-popup-window.html: Added.
2010-07-14  Johnny Ding  <jnd@chromium.org>

        Reviewed by Adam Barth.

        https://bugs.webkit.org/show_bug.cgi?id=41292
        Add a new parameter to the test plugin to allow to specify a script and a
        mouse/keyboard event. The specified script will be evaluated in the browser
        when the specified event is received by the plugin.

        * DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp:
        (pluginAllocate):
        * DumpRenderTree/TestNetscapePlugIn/PluginObject.h:
        * DumpRenderTree/TestNetscapePlugIn/main.cpp:
        (NPP_New):
        (handleEventCarbon):
        (handleEventCocoa):

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

13 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/gtk/Skipped
LayoutTests/platform/qt/Skipped
LayoutTests/platform/win/Skipped
LayoutTests/plugins/plugin-initiate-popup-window-expected.txt [new file with mode: 0644]
LayoutTests/plugins/plugin-initiate-popup-window.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/bindings/v8/NPV8Object.cpp
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp
WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.h
WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp

index 92c1e04..76cefeb 100644 (file)
@@ -1,3 +1,18 @@
+2010-07-14  Johnny Ding  <jnd@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        https://bugs.webkit.org/show_bug.cgi?id=41292
+        Add a test to initiate popup windows from plugin during plugin is handling mouse/keyboard event.
+        Disable this test on gtk/qt/win since the test plugin in those platforms didn't implement NPP_HandleEvent.
+
+        * platform/chromium/test_expectations.txt:
+        * platform/gtk/Skipped:
+        * platform/qt/Skipped:
+        * platform/win/Skipped:
+        * plugins/plugin-initiate-popup-window-expected.txt: Added.
+        * plugins/plugin-initiate-popup-window.html: Added.
+
 2010-07-14  Erik Arvidsson  <arv@chromium.org>
 
         Reviewed by Darin Adler.
index 7ad52b1..5339a0f 100644 (file)
@@ -3002,6 +3002,9 @@ BUG48737 WIN LINUX MAC SKIP : ietestcenter/Javascript/15.4.4.15-3-14.html = TIME
 BUG48737 WIN LINUX MAC SKIP : ietestcenter/Javascript/15.4.4.15-3-29.html = TIMEOUT
 BUG48737 WIN LINUX MAC SKIP : ietestcenter/Javascript/15.4.4.15-3-8.html = TIMEOUT
 
+// Implement new test logic in Chromium's TestNetscape Plugin to pass the plugins/plugin-initiate-popup-window.html
+BUG48033 SKIP : plugins/plugin-initiate-popup-window.html = TIMEOUT
+
 // Broken prior to r62921.
 BUG48696 WIN LINUX : fast/forms/focus2.html = CRASH
 BUG48696 WIN LINUX MAC : fast/forms/tabs-with-modifiers.html = CRASH
index 8241a29..8dc2e6e 100644 (file)
@@ -3341,13 +3341,14 @@ plugins/throw-on-dealloc.html
 plugins/undefined-property-crash.html
 #   These test require Qt Widgets
 plugins/qt-qwidget-plugin.html
-#   Tests failing
+#   Tests failing, need to implement NPP_HandleEvent() in TestNetscapePlugin
 plugins/embed-attributes-setting.html
 plugins/get-url-with-blank-target.html
 plugins/mouse-events.html
 plugins/mouse-events-fixedpos.html
 plugins/keyboard-events.html
 plugins/geturlnotify-during-document-teardown.html
+plugins/plugin-initiate-popup-window.html
 
 # This test is for clients that choose to make the missing plugin indicator a button
 plugins/clicking-missing-plugin-fires-delegate.html
index e1756b3..40eb076 100644 (file)
@@ -457,6 +457,7 @@ fast/dom/object-embed-plugin-scripting.html
 plugins/mouse-events.html
 plugins/keyboard-events.html
 plugins/mouse-events-fixedpos.html
+plugins/plugin-initiate-popup-window.html
 # ---- to be reviewed
 http/tests/plugins/plugin-document-has-focus.html
 
index efd7c2f..506bd4d 100644 (file)
@@ -804,6 +804,7 @@ fast/loader/api-test-new-window-data-load-base-url.html
 # Needs to implement NPP_HandleEvent() in TestNetscapePlugin
 plugins/keyboard-events.html
 http/tests/plugins/plugin-document-has-focus.html
+plugins/plugin-initiate-popup-window.html
 
 # DumpRenderTree code to enable Java is currently a no-op. Windows doesn't come with Java by default.
 java
diff --git a/LayoutTests/plugins/plugin-initiate-popup-window-expected.txt b/LayoutTests/plugins/plugin-initiate-popup-window-expected.txt
new file mode 100644 (file)
index 0000000..2d390ff
--- /dev/null
@@ -0,0 +1,21 @@
+CONSOLE MESSAGE: line 0: PLUGIN: getFocusEvent
+CONSOLE MESSAGE: line 0: PLUGIN: getFocusEvent
+CONSOLE MESSAGE: line 0: PLUGIN: getFocusEvent
+CONSOLE MESSAGE: line 0: PLUGIN: mouseDown at (12, 12)
+CONSOLE MESSAGE: line 0: PLUGIN: mouseUp at (12, 12)
+CONSOLE MESSAGE: line 0: PLUGIN: loseFocusEvent
+CONSOLE MESSAGE: line 0: PLUGIN: getFocusEvent
+CONSOLE MESSAGE: line 0: PLUGIN: mouseDown at (52, 12)
+CONSOLE MESSAGE: line 0: PLUGIN: mouseUp at (52, 12)
+CONSOLE MESSAGE: line 0: PLUGIN: keyDown 'p'
+CONSOLE MESSAGE: line 0: PLUGIN: keyUp 'p'
+CONSOLE MESSAGE: line 0: PLUGIN: loseFocusEvent
+ALERT: MOUSEDOWN PASSED
+ALERT: KEYDOWN PASSED
+
+
+Specify a script and a mouse/keyboard event to the plugin. The specified script will be evaluated in the browser when the specified event is received by the plugin. The test is for bug https://bugs.webkit.org/show_bug.cgi?id=41292.
+
+
+
+
diff --git a/LayoutTests/plugins/plugin-initiate-popup-window.html b/LayoutTests/plugins/plugin-initiate-popup-window.html
new file mode 100644 (file)
index 0000000..98c81eb
--- /dev/null
@@ -0,0 +1,67 @@
+<html>
+<head>
+<script>
+if (window.layoutTestController) {
+  layoutTestController.dumpAsText();
+  layoutTestController.setCanOpenWindows();
+  layoutTestController.setPopupBlockingEnabled(true);
+  layoutTestController.setCloseRemainingWindowsWhenComplete(true);
+  layoutTestController.waitUntilDone();
+}
+
+function test() {
+    if (window.layoutTestController) {
+        // Send a mouse-click event to set the input focus to the test plug-in.
+        eventSender.mouseMoveTo(0, 0);
+        eventSender.mouseMoveTo(20, 20);
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+    }
+}
+
+function popup_by_mousedown() {
+    // We rely on sequential ordering of POST processing.
+    var form = document.getElementById('form');
+    form.submit();
+    setTimeout(send_key_to_plugin, 1);
+}
+
+function send_key_to_plugin() {
+  // Send keyboard events to the plug-in.
+  if (window.layoutTestController) {
+      eventSender.mouseMoveTo(0, 0);
+      eventSender.mouseMoveTo(60, 60);
+      eventSender.mouseDown();
+      eventSender.mouseUp();
+      eventSender.keyDown('p');
+  }
+}
+
+function popup_by_keydown() {
+    // We rely on sequential ordering of POST processing.
+    var form = document.getElementById('form2');
+    form.submit();
+    setTimeout(close_test, 1);
+}
+function close_test() {
+    var form = document.getElementById('form3');
+    form.submit();
+}
+</script>
+</head>
+<body onload="test()">
+<embed name="plg" type="application/x-webkit-test-netscape" width=100 height=40 evaluatescript="mouse::popup_by_mousedown()"></embed><br>
+<embed type="application/x-webkit-test-netscape" width=100 height=40 evaluatescript="key::popup_by_keydown()"></embed><br>
+Specify a script and a mouse/keyboard event to the plugin. The specified script will be evaluated in the browser when the specified event is received by the plugin. The test is for bug https://bugs.webkit.org/show_bug.cgi?id=41292.
+<form id="form" action="data:text/html,<script>alert('MOUSEDOWN PASSED')</script>" target="target1">
+<input type="submit" value="Submit to new window"/>
+</form>
+<form id="form2" action="data:text/html,<script>alert('KEYDOWN PASSED')</script>" target="target2">
+<input type="submit" value="Submit to new window"/>
+</form>
+<form id="form3" action="data:text/html,<b>hello!</b><script>window.layoutTestController && layoutTestController.notifyDone()</script>" target="panel">
+<input type="submit" value="Submit local page Javascript"/>
+</form>
+<iframe id="target1"></iframe><iframe id="target2"></iframe><iframe id="panel"></iframe>
+</body>
+</html>
index 78b9188..f84a46d 100644 (file)
@@ -1,3 +1,15 @@
+2010-07-14  Johnny Ding  <jnd@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        https://bugs.webkit.org/show_bug.cgi?id=41292
+        Set right UserGestureIndicator to indicate whether the NPN_Evaluate allows popup window or not.
+
+        Test: plugins/plugin-initiate-popup-window.html
+
+        * bindings/v8/NPV8Object.cpp:
+        (_NPN_EvaluateHelper):
+
 2010-07-14  Chris Fleizach  <cfleizach@apple.com>
 
         Reviewed by Darin Adler.
index a25a5eb..94b7d88 100644 (file)
@@ -34,6 +34,7 @@
 #include "OwnArrayPtr.h"
 #include "PlatformString.h"
 #include "ScriptController.h"
+#include "UserGestureIndicator.h"
 #include "V8GCController.h"
 #include "V8Helpers.h"
 #include "V8NPUtils.h"
@@ -278,6 +279,8 @@ bool _NPN_EvaluateHelper(NPP npp, bool popupsAllowed, NPObject* npObject, NPStri
     if (!popupsAllowed)
         filename = "npscript";
 
+    UserGestureIndicator gestureIndicator(popupsAllowed ? DefinitelyProcessingUserGesture : DefinitelyNotProcessingUserGesture);
+
     String script = String::fromUTF8(npScript->UTF8Characters, npScript->UTF8Length);
     v8::Local<v8::Value> v8result = proxy->evaluate(ScriptSourceCode(script, KURL(ParsedURLString, filename)), 0);
 
index 2655545..c693302 100644 (file)
@@ -1,3 +1,20 @@
+2010-07-14  Johnny Ding  <jnd@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        https://bugs.webkit.org/show_bug.cgi?id=41292
+        Add a new parameter to the test plugin to allow to specify a script and a
+        mouse/keyboard event. The specified script will be evaluated in the browser
+        when the specified event is received by the plugin.
+
+        * DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp:
+        (pluginAllocate):
+        * DumpRenderTree/TestNetscapePlugIn/PluginObject.h:
+        * DumpRenderTree/TestNetscapePlugIn/main.cpp:
+        (NPP_New):
+        (handleEventCarbon):
+        (handleEventCocoa):
+
 2010-07-14  Adam Roben  <aroben@apple.com>
 
         Make urlSuitableForTestResult work for http: URLs, too
index 671069e..b2b4013 100644 (file)
@@ -978,16 +978,19 @@ static NPObject *pluginAllocate(NPP npp, NPClass *theClass)
     newInstance->returnNegativeOneFromWrite = FALSE;
     newInstance->stream = 0;
 
-    newInstance->firstUrl = NULL;
-    newInstance->firstHeaders = NULL;
-    newInstance->lastUrl = NULL;
-    newInstance->lastHeaders = NULL;
+    newInstance->firstUrl = 0;
+    newInstance->firstHeaders = 0;
+    newInstance->lastUrl = 0;
+    newInstance->lastHeaders = 0;
 
     newInstance->testGetURLOnDestroy = FALSE;
     newInstance->testDocumentOpenInDestroyStream = FALSE;
     newInstance->testWindowOpen = FALSE;
     newInstance->testKeyboardFocusForPlugins = FALSE;
 
+    newInstance->mouseDownForEvaluateScript = FALSE;
+    newInstance->evaluateScriptOnMouseDownOrKeyDown = 0;
+
     return (NPObject*)newInstance;
 }
 
index 03befb0..206cad3 100644 (file)
@@ -54,6 +54,7 @@ typedef struct {
     NPBool testGetURLOnDestroy;
     NPBool testWindowOpen;
     NPBool testKeyboardFocusForPlugins;
+    NPBool mouseDownForEvaluateScript;
     char* onStreamLoad;
     char* onStreamDestroy;
     char* onDestroy;
@@ -63,6 +64,7 @@ typedef struct {
     char* firstHeaders;
     char* lastUrl;
     char* lastHeaders;
+    char* evaluateScriptOnMouseDownOrKeyDown;
 #ifdef XP_MACOSX
     NPEventModel eventModel;
 #endif
index 82a6e3a..aeaee30 100644 (file)
@@ -183,8 +183,20 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc
             // FIXME: When https://bugs.webkit.org/show_bug.cgi?id=41831 is fixed, this #ifdef can be removed.
             obj->testGetURLOnDestroy = TRUE;
 #endif
-        } else if (strcasecmp(argn[i], "src") == 0 && strstr(argv[i], "plugin-document-has-focus.pl"))
+        } else if (!strcasecmp(argn[i], "src") && strstr(argv[i], "plugin-document-has-focus.pl"))
             obj->testKeyboardFocusForPlugins = TRUE;
+        else if (!strcasecmp(argn[i], "evaluatescript")) {
+            char* script = argv[i];
+            if (script == strstr(script, "mouse::")) {
+                obj->mouseDownForEvaluateScript = true;
+                obj->evaluateScriptOnMouseDownOrKeyDown = strdup(script + sizeof("mouse::") - 1);
+            } else if (script == strstr(script, "key::")) {
+                obj->evaluateScriptOnMouseDownOrKeyDown = strdup(script + sizeof("key::") - 1);
+            }
+            // When testing evaluate script on mouse-down or key-down, allow event logging to handle events.
+            if (obj->evaluateScriptOnMouseDownOrKeyDown)
+                obj->eventLogging = true;
+        }
     }
 
 #if XP_MACOSX
@@ -369,6 +381,8 @@ static int16_t handleEventCarbon(NPP instance, PluginObject* obj, EventRecord* e
         case mouseDown:
             GlobalToLocal(&pt);
             pluginLog(instance, "mouseDown at (%d, %d)", pt.h, pt.v);
+            if (obj->evaluateScriptOnMouseDownOrKeyDown && obj->mouseDownForEvaluateScript)
+                executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown);
             break;
         case mouseUp:
             GlobalToLocal(&pt);
@@ -376,6 +390,8 @@ static int16_t handleEventCarbon(NPP instance, PluginObject* obj, EventRecord* e
             break;
         case keyDown:
             pluginLog(instance, "keyDown '%c'", (char)(event->message & 0xFF));
+            if (obj->evaluateScriptOnMouseDownOrKeyDown && !obj->mouseDownForEvaluateScript)
+                executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown);
             break;
         case keyUp:
             pluginLog(instance, "keyUp '%c'", (char)(event->message & 0xFF));
@@ -449,6 +465,8 @@ static int16_t handleEventCocoa(NPP instance, PluginObject* obj, NPCocoaEvent* e
         case NPCocoaEventKeyDown:
             if (event->data.key.characters)
                 pluginLog(instance, "keyDown '%c'", CFStringGetCharacterAtIndex(reinterpret_cast<CFStringRef>(event->data.key.characters), 0));
+            if (obj->evaluateScriptOnMouseDownOrKeyDown && !obj->mouseDownForEvaluateScript)
+                executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown);
             return 1;
 
         case NPCocoaEventKeyUp:
@@ -469,6 +487,8 @@ static int16_t handleEventCocoa(NPP instance, PluginObject* obj, NPCocoaEvent* e
             pluginLog(instance, "mouseDown at (%d, %d)", 
                    (int)event->data.mouse.pluginX,
                    (int)event->data.mouse.pluginY);
+            if (obj->evaluateScriptOnMouseDownOrKeyDown && obj->mouseDownForEvaluateScript)
+                executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown);
             return 1;
         case NPCocoaEventMouseUp:
             pluginLog(instance, "mouseUp at (%d, %d)",