2011-05-02 Robert Hogan <robert@webkit.org>
authorrobert@webkit.org <robert@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 May 2011 21:04:32 +0000 (21:04 +0000)
committerrobert@webkit.org <robert@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 May 2011 21:04:32 +0000 (21:04 +0000)
        Reviewed by Adam Roben.

        [Qt] Allow popup windows from plugins when initiated by a user gesture

        https://bugs.webkit.org/show_bug.cgi?id=41292

        * platform/qt/Skipped: Unskip plugin-initiate-popup-window.html
        * platform/qt/plugins/plugin-initiate-popup-window-expected.txt: Copied from LayoutTests/platform/mac/plugins/plugin-initiate-popup-window-expected.txt.
        * plugins/plugin-initiate-popup-window.html: Plugins are only windowless
                                                     by default on OSX, so make the plugins windowless explicitly.
2011-05-02  Robert Hogan  <robert@webkit.org>

        Reviewed by Adam Roben.

        [Qt] Allow popup windows from plugins when initiated by a user gesture

        https://bugs.webkit.org/show_bug.cgi?id=41292

        If the event is from a user gesture and the plugin doesn't support
        NPN_PushPopupsEnabledState() and NPN_PopPopupsEnabledState(), allow popups.

        * plugins/qt/PluginViewQt.cpp:
        (WebCore::PluginView::dispatchNPEvent):
2011-05-02  Robert Hogan  <robert@webkit.org>

        Reviewed by Adam Roben.

        [Qt] Allow popup windows from plugins when initiated by a user gesture

        https://bugs.webkit.org/show_bug.cgi?id=41292

        Support parameters introduced in plugin-initiate-popup-window.html

        * DumpRenderTree/unix/TestNetscapePlugin/TestNetscapePlugin.cpp:
        (webkit_test_plugin_new_instance):
        (webkit_test_plugin_handle_event):

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

LayoutTests/ChangeLog
LayoutTests/platform/qt/Skipped
LayoutTests/platform/qt/plugins/plugin-initiate-popup-window-expected.txt [new file with mode: 0644]
LayoutTests/plugins/plugin-initiate-popup-window.html
Source/WebCore/ChangeLog
Source/WebCore/plugins/qt/PluginViewQt.cpp
Tools/ChangeLog
Tools/DumpRenderTree/unix/TestNetscapePlugin/TestNetscapePlugin.cpp

index 68eada9..0c98dde 100644 (file)
@@ -1,3 +1,16 @@
+2011-05-02  Robert Hogan  <robert@webkit.org>
+
+        Reviewed by Adam Roben.
+
+        [Qt] Allow popup windows from plugins when initiated by a user gesture
+
+        https://bugs.webkit.org/show_bug.cgi?id=41292
+
+        * platform/qt/Skipped: Unskip plugin-initiate-popup-window.html
+        * platform/qt/plugins/plugin-initiate-popup-window-expected.txt: Copied from LayoutTests/platform/mac/plugins/plugin-initiate-popup-window-expected.txt.
+        * plugins/plugin-initiate-popup-window.html: Plugins are only windowless
+                                                     by default on OSX, so make the plugins windowless explicitly.
+
 2011-05-26  Mihai Parparita  <mihaip@chromium.org>
 
         Reviewed by Adam Barth.
index 6fd196f..568b0e5 100644 (file)
@@ -356,9 +356,6 @@ plugins/get-url-with-blank-target.html
 # ---- plugins rendered in incorrect position ?
 plugins/embed-attributes-style.html
 
-# https://bugs.webkit.org/show_bug.cgi?id=41292
-plugins/plugin-initiate-popup-window.html
-
 # https://bugs.webkit.org/show_bug.cgi?id=60722
 http/tests/plugins/plugin-document-has-focus.html
 
diff --git a/LayoutTests/platform/qt/plugins/plugin-initiate-popup-window-expected.txt b/LayoutTests/platform/qt/plugins/plugin-initiate-popup-window-expected.txt
new file mode 100644 (file)
index 0000000..b400c75
--- /dev/null
@@ -0,0 +1,17 @@
+CONSOLE MESSAGE: line 17: window count: 1
+CONSOLE MESSAGE: line 0: PLUGIN: getFocusEvent
+CONSOLE MESSAGE: line 0: PLUGIN: mouseDown at (12, 12)
+CONSOLE MESSAGE: line 30: window count: 2
+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 52: window count: 3
+CONSOLE MESSAGE: line 0: PLUGIN: keyUp 'p'
+
+
+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.
+Opening window by mouse down is PASSED
+Opening window by key down is PASSED
index b880d3a..63b3e07 100644 (file)
@@ -65,8 +65,8 @@ function end_test() {
 </script>
 </head>
 <body onload="window.setTimeout(test, 0);">
-<embed 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>
+<embed type="application/x-webkit-test-netscape" width=100 height=40 evaluatescript="mouse::popup_by_mousedown()" windowedplugin="false"></embed><br>
+<embed type="application/x-webkit-test-netscape" width=100 height=40 evaluatescript="key::popup_by_keydown()" windowedplugin="false"></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.<br>
 Opening window by mouse down is <span id="mousedown_output">FAILED</span><br>
 Opening window by key down is <span id="keydown_output">FAILED</span>
index bbdea31..210d914 100644 (file)
@@ -1,3 +1,17 @@
+2011-05-02  Robert Hogan  <robert@webkit.org>
+
+        Reviewed by Adam Roben.
+
+        [Qt] Allow popup windows from plugins when initiated by a user gesture
+
+        https://bugs.webkit.org/show_bug.cgi?id=41292
+
+        If the event is from a user gesture and the plugin doesn't support
+        NPN_PushPopupsEnabledState() and NPN_PopPopupsEnabledState(), allow popups.
+
+        * plugins/qt/PluginViewQt.cpp:
+        (WebCore::PluginView::dispatchNPEvent):
+
 2011-05-26  Leandro Gracia Gil  <leandrogracia@chromium.org>
 
         Reviewed by Dmitry Titov.
index eafdf97..adf7c10 100644 (file)
@@ -384,6 +384,14 @@ bool PluginView::dispatchNPEvent(NPEvent& event)
     if (!m_plugin->pluginFuncs()->event)
         return false;
 
+    bool shouldPop = false;
+
+    if (m_plugin->pluginFuncs()->version < NPVERS_HAS_POPUPS_ENABLED_STATE
+        && (event.type == ButtonRelease || event.type == 3 /*KeyRelease*/)) {
+        pushPopupsEnabledState(true);
+        shouldPop = true;
+    }
+
     PluginView::setCurrentPluginView(this);
 #if USE(JSC)
     JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
@@ -393,6 +401,9 @@ bool PluginView::dispatchNPEvent(NPEvent& event)
     setCallingPlugin(false);
     PluginView::setCurrentPluginView(0);
 
+    if (shouldPop)
+        popPopupsEnabledState();
+
     return accepted;
 }
 
index 939c3a1..1d478c7 100644 (file)
@@ -1,3 +1,17 @@
+2011-05-02  Robert Hogan  <robert@webkit.org>
+
+        Reviewed by Adam Roben.
+
+        [Qt] Allow popup windows from plugins when initiated by a user gesture
+
+        https://bugs.webkit.org/show_bug.cgi?id=41292
+
+        Support parameters introduced in plugin-initiate-popup-window.html
+
+        * DumpRenderTree/unix/TestNetscapePlugin/TestNetscapePlugin.cpp:
+        (webkit_test_plugin_new_instance):
+        (webkit_test_plugin_handle_event):
+
 2011-05-26  Mihai Parparita  <mihaip@chromium.org>
 
         Reviewed by Adam Barth.
index e75ca63..0506d24 100644 (file)
@@ -109,6 +109,17 @@ webkit_test_plugin_new_instance(NPMIMEType mimetype,
                 browser->setvalue(instance, NPPVpluginWindowBool, windowed);
             } else if (!strcasecmp(argn[i], "onPaintEvent") && !obj->onPaintEvent)
                 obj->onPaintEvent = strdup(argv[i]);
+            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;
+            }
         }
 
         browser->getvalue(instance, NPNVprivateModeBool, (void *)&obj->cachedPrivateBrowsingMode);
@@ -301,6 +312,8 @@ webkit_test_plugin_handle_event(NPP instance, void* event)
         case ButtonPress:
             if (obj->eventLogging)
                 pluginLog(instance, "mouseDown at (%d, %d)", evt->xbutton.x, evt->xbutton.y);
+           if (obj->evaluateScriptOnMouseDownOrKeyDown && obj->mouseDownForEvaluateScript)
+                executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown);
             break;
         case KeyRelease:
             if (obj->eventLogging)
@@ -309,6 +322,8 @@ webkit_test_plugin_handle_event(NPP instance, void* event)
         case KeyPress:
             if (obj->eventLogging)
                 pluginLog(instance, "keyDown '%c'", keyEventToChar(&evt->xkey));
+           if (obj->evaluateScriptOnMouseDownOrKeyDown && !obj->mouseDownForEvaluateScript)
+                executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown);
             break;
         case MotionNotify:
         case EnterNotify: