[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 13:54:21 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 9282d3078abb7c19433d1492183f9d7d17bb5735
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Sep 29 06:27:57 2010 +0000

    2010-09-28  Johnny Ding  <jnd at chromium.org>
    
            Reviewed by Adam Barth.
    
            https://bugs.webkit.org/show_bug.cgi?id=41292
            Some windowed plugins did not handle events through EventHandler, so we
            never set right gesture state for those events.
            This change is to set right allowPopupsFromPlugin flag to current
            execution frame, so WeKit can always get right gesture state on Mac.
            From Mac Snow Leopard, the plugin is run under "WebKitPluginHost,app"
            process, that process passes the allowPopupsFromPlugin flag to
            WKPCEvaluate(in NetscapePluginHostProxy.mm), then flag is set in
            NetscapePluginInstanceProxy::evaluate.
    
            * Plugins/WebNetscapePluginView.mm:
            (-[WebNetscapePluginView sendEvent:isDrawRect:]):
    2010-09-28  Johnny Ding  <jnd at chromium.org>
    
            Reviewed by Adam Barth.
    
            https://bugs.webkit.org/show_bug.cgi?id=41292
            Pass the right popupAllowed flag to current execution frame,
            so WebKit can get right gesture status for popups initiated
            from plugins.
            This also makes v8 binding's ScriptController::processingUserGesture
            match what jsc version.
    
            Test: plugins/plugin-initiate-popup-window.html
    
            * bindings/v8/NPV8Object.cpp:
            (_NPN_EvaluateHelper):
            * bindings/v8/ScriptController.cpp:
            (WebCore::ScriptController::ScriptController):
            (WebCore::ScriptController::processingUserGesture):
            * bindings/v8/ScriptController.h:
            (WebCore::ScriptController::setAllowPopupsFromPlugin):
            (WebCore::ScriptController::allowPopupsFromPlugin):
    2010-09-28  Johnny Ding  <jnd at 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-win/plugins/plugin-initiate-popup-window-expected.txt: Added.
            * 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-09-28  Johnny Ding  <jnd at 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 specifying 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: http://svn.webkit.org/repository/webkit/trunk@68630 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 6476393..c1b5c89 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,21 @@
+2010-09-28  Johnny Ding  <jnd at 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-win/plugins/plugin-initiate-popup-window-expected.txt: Added.
+        * 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-09-28 MORITA Hajime  <morrita at google.com>
 
         Unreviewed; update test expectations.
diff --git a/LayoutTests/platform/chromium-win/plugins/plugin-initiate-popup-window-expected.txt b/LayoutTests/platform/chromium-win/plugins/plugin-initiate-popup-window-expected.txt
new file mode 100755
index 0000000..b1e9b74
--- /dev/null
+++ b/LayoutTests/platform/chromium-win/plugins/plugin-initiate-popup-window-expected.txt
@@ -0,0 +1,19 @@
+CONSOLE MESSAGE: line 0: PLUGIN: event 71
+CONSOLE MESSAGE: line 0: PLUGIN: event 71
+CONSOLE MESSAGE: line 17: window count: 1
+CONSOLE MESSAGE: line 21: PLUGIN: getFocusEvent
+CONSOLE MESSAGE: line 21: PLUGIN: mouseDown at (20, 20)
+CONSOLE MESSAGE: line 30: window count: 2
+CONSOLE MESSAGE: line 22: PLUGIN: mouseUp at (20, 20)
+CONSOLE MESSAGE: line 42: PLUGIN: loseFocusEvent
+CONSOLE MESSAGE: line 42: PLUGIN: getFocusEvent
+CONSOLE MESSAGE: line 42: PLUGIN: mouseDown at (60, 60)
+CONSOLE MESSAGE: line 43: PLUGIN: mouseUp at (60, 60)
+CONSOLE MESSAGE: line 44: PLUGIN: keyDown 'P'
+CONSOLE MESSAGE: line 52: window count: 3
+CONSOLE MESSAGE: line 44: 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
diff --git a/LayoutTests/platform/chromium/test_expectations.txt b/LayoutTests/platform/chromium/test_expectations.txt
index 772fbbe..09eaf13 100644
--- a/LayoutTests/platform/chromium/test_expectations.txt
+++ b/LayoutTests/platform/chromium/test_expectations.txt
@@ -3157,3 +3157,6 @@ BUG_SENORBLANCO LINUX : fast/text/midword-break-after-breakable-char.html = TEXT
 
 // Flaky since 68620
 BUGWK46779 : fast/filesystem/flags-passing.html = TEXT
+
+// NPP_HandleEvent doesn't be implemented/work on mac/linux.
+BUG48033 LINUX MAC SKIP : plugins/plugin-initiate-popup-window.html = PASS TIMEOUT
diff --git a/LayoutTests/platform/gtk/Skipped b/LayoutTests/platform/gtk/Skipped
index c622259..0f74f29 100644
--- a/LayoutTests/platform/gtk/Skipped
+++ b/LayoutTests/platform/gtk/Skipped
@@ -3171,9 +3171,10 @@ media/video-poster-scale.html
 media/video-does-not-loop.html
 
 # Tests in plugins/ directory
-#   Tests failing
+#   Tests failing, need to implement NPP_HandleEvent() in TestNetscapePlugin
 plugins/embed-attributes-setting.html
 plugins/get-url-with-blank-target.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
diff --git a/LayoutTests/platform/qt/Skipped b/LayoutTests/platform/qt/Skipped
index a7abc9f..a2ebd14 100644
--- a/LayoutTests/platform/qt/Skipped
+++ b/LayoutTests/platform/qt/Skipped
@@ -406,6 +406,7 @@ plugins/embed-attributes-style.html
 # ---- depends on QuickTime support
 plugins/embed-attributes-setting.html
 fast/dom/object-embed-plugin-scripting.html
+plugins/plugin-initiate-popup-window.html
 # ---- to be reviewed
 http/tests/plugins/plugin-document-has-focus.html
 
diff --git a/LayoutTests/platform/win/Skipped b/LayoutTests/platform/win/Skipped
index adfd96c..8b18795 100644
--- a/LayoutTests/platform/win/Skipped
+++ b/LayoutTests/platform/win/Skipped
@@ -798,6 +798,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
index 0000000..321f2bf
--- /dev/null
+++ b/LayoutTests/plugins/plugin-initiate-popup-window-expected.txt
@@ -0,0 +1,20 @@
+CONSOLE MESSAGE: line 0: PLUGIN: getFocusEvent
+CONSOLE MESSAGE: line 0: PLUGIN: getFocusEvent
+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'
+CONSOLE MESSAGE: line 0: PLUGIN: loseFocusEvent
+
+
+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
diff --git a/LayoutTests/plugins/plugin-initiate-popup-window.html b/LayoutTests/plugins/plugin-initiate-popup-window.html
new file mode 100644
index 0000000..b880d3a
--- /dev/null
+++ b/LayoutTests/plugins/plugin-initiate-popup-window.html
@@ -0,0 +1,74 @@
+<html>
+<head>
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.setCanOpenWindows();
+    layoutTestController.setPopupBlockingEnabled(true);
+    layoutTestController.setCloseRemainingWindowsWhenComplete(true);
+    layoutTestController.waitUntilDone();
+}
+
+function test() {
+    if (!window.layoutTestController)
+        return;
+    // Record current window count.
+    window.windowCount = window.layoutTestController.windowCount();
+    console.log("window count: " + window.layoutTestController.windowCount());
+    // 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();
+}
+
+// This function will be called when plugin receives a mousedown event.
+function popup_by_mousedown() {
+    // Open a new window.
+    window.open("data:text/html\, open new window by mouse down", "_blank");
+    // Check the new opened window and logging the result.
+    console.log("window count: " + window.layoutTestController.windowCount());
+    if (window.layoutTestController.windowCount() == (window.windowCount + 1)) {
+        document.getElementById("mousedown_output").innerHTML = "PASSED";
+        window.windowCount++;
+    }
+   setTimeout(send_key_to_plugin, 100);
+}
+
+function send_key_to_plugin() {
+    // Send keyboard events to the plug-in.
+    eventSender.mouseMoveTo(0, 0);
+    eventSender.mouseMoveTo(60, 60);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+    eventSender.keyDown('p');
+}
+
+// This function will be called when plugin receives a keydown event.
+function popup_by_keydown() {
+    // Open a new window.
+    window.open("data:text/html\, open new window by key down", "_blank");
+    // Check the new opened window and logging the result.
+    console.log("window count: " + window.layoutTestController.windowCount());
+    if (window.layoutTestController.windowCount() == (window.windowCount + 1))
+        document.getElementById("keydown_output").innerHTML = "PASSED";
+    // Wait for plugin stopping and ending this test.
+    setTimeout(end_test, 100);
+}
+
+function end_test() {
+    // Change focus back to window to stop the plugin event logging.
+    window.focus();
+    // Close the test.
+     setTimeout(function() {layoutTestController.notifyDone();}, 1);
+}
+</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>
+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>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 20c0e2b..60d7b9c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-09-28  Johnny Ding  <jnd at chromium.org>
+
+        Reviewed by Adam Barth.
+
+        https://bugs.webkit.org/show_bug.cgi?id=41292
+        Pass the right popupAllowed flag to current execution frame,
+        so WebKit can get right gesture status for popups initiated
+        from plugins.
+        This also makes v8 binding's ScriptController::processingUserGesture
+        match what jsc version.
+
+        Test: plugins/plugin-initiate-popup-window.html
+
+        * bindings/v8/NPV8Object.cpp:
+        (_NPN_EvaluateHelper):
+        * bindings/v8/ScriptController.cpp:
+        (WebCore::ScriptController::ScriptController):
+        (WebCore::ScriptController::processingUserGesture):
+        * bindings/v8/ScriptController.h:
+        (WebCore::ScriptController::setAllowPopupsFromPlugin):
+        (WebCore::ScriptController::allowPopupsFromPlugin):
+
 2010-09-28  Kent Tamura  <tkent at chromium.org>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/bindings/v8/NPV8Object.cpp b/WebCore/bindings/v8/NPV8Object.cpp
index 1ec5e06..98d3e02 100644
--- a/WebCore/bindings/v8/NPV8Object.cpp
+++ b/WebCore/bindings/v8/NPV8Object.cpp
@@ -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,8 +279,17 @@ bool _NPN_EvaluateHelper(NPP npp, bool popupsAllowed, NPObject* npObject, NPStri
     if (!popupsAllowed)
         filename = "npscript";
 
+    // Set popupsAllowed flag to the current execution frame, so WebKit can get
+    // right gesture status for popups initiated from plugins.
+    Frame* frame = proxy->frame();
+    ASSERT(frame);
+    bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();
+    frame->script()->setAllowPopupsFromPlugin(popupsAllowed);
+
     String script = String::fromUTF8(npScript->UTF8Characters, npScript->UTF8Length);
     v8::Local<v8::Value> v8result = proxy->evaluate(ScriptSourceCode(script, KURL(ParsedURLString, filename)), 0);
+    // Restore the old flag.
+    frame->script()->setAllowPopupsFromPlugin(oldAllowPopups);
 
     if (v8result.IsEmpty())
         return false;
diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp
index 556b5c6..9819679 100644
--- a/WebCore/bindings/v8/ScriptController.cpp
+++ b/WebCore/bindings/v8/ScriptController.cpp
@@ -121,6 +121,7 @@ ScriptController::ScriptController(Frame* frame)
     , m_inExecuteScript(false)
     , m_processingTimerCallback(false)
     , m_paused(false)
+    , m_allowPopupsFromPlugin(false)
     , m_proxy(new V8Proxy(frame))
 #if ENABLE(NETSCAPE_PLUGIN_API)
     , m_windowScriptNPObject(0)
@@ -203,7 +204,8 @@ bool ScriptController::processingUserGesture()
         // This is the <a href="javascript:window.open('...')> case -> we let it through.
         return true;
     }
-
+    if (activeFrame->script()->allowPopupsFromPlugin())
+        return true;
     // This is the <script>window.open(...)</script> case or a timer callback -> block it.
     // Based on JSC version, use returned value of UserGestureIndicator::processingUserGesture for all other situations. 
     return UserGestureIndicator::processingUserGesture();
diff --git a/WebCore/bindings/v8/ScriptController.h b/WebCore/bindings/v8/ScriptController.h
index 3bc42ef..8ac9064 100644
--- a/WebCore/bindings/v8/ScriptController.h
+++ b/WebCore/bindings/v8/ScriptController.h
@@ -193,6 +193,9 @@ public:
     void evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*);
     static void getAllWorlds(Vector<DOMWrapperWorld*>& worlds);
 
+    void setAllowPopupsFromPlugin(bool allowPopupsFromPlugin) { m_allowPopupsFromPlugin = allowPopupsFromPlugin; }
+    bool allowPopupsFromPlugin() const { return m_allowPopupsFromPlugin; }
+
 private:
     Frame* m_frame;
     const String* m_sourceURL;
@@ -201,6 +204,7 @@ private:
 
     bool m_processingTimerCallback;
     bool m_paused;
+    bool m_allowPopupsFromPlugin;
 
     OwnPtr<V8Proxy> m_proxy;
     typedef HashMap<Widget*, NPObject*> PluginObjectMap;
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 5da6e93..d707720 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,20 @@
+2010-09-28  Johnny Ding  <jnd at chromium.org>
+
+        Reviewed by Adam Barth.
+
+        https://bugs.webkit.org/show_bug.cgi?id=41292
+        Some windowed plugins did not handle events through EventHandler, so we
+        never set right gesture state for those events.
+        This change is to set right allowPopupsFromPlugin flag to current
+        execution frame, so WeKit can always get right gesture state on Mac.
+        From Mac Snow Leopard, the plugin is run under "WebKitPluginHost,app"
+        process, that process passes the allowPopupsFromPlugin flag to
+        WKPCEvaluate(in NetscapePluginHostProxy.mm), then flag is set in
+        NetscapePluginInstanceProxy::evaluate.
+
+        * Plugins/WebNetscapePluginView.mm:
+        (-[WebNetscapePluginView sendEvent:isDrawRect:]):
+
 2010-09-28  Jenn Braithwaite  <jennb at chromium.org>
 
         Reviewed by Dmitry Titov.
diff --git a/WebKit/mac/Plugins/WebNetscapePluginView.mm b/WebKit/mac/Plugins/WebNetscapePluginView.mm
index 3d5d7a1..ff0ca77 100644
--- a/WebKit/mac/Plugins/WebNetscapePluginView.mm
+++ b/WebKit/mac/Plugins/WebNetscapePluginView.mm
@@ -661,13 +661,19 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
     
     // Temporarily retain self in case the plug-in view is released while sending an event. 
     [[self retain] autorelease];
-    
+
     BOOL acceptedEvent;
     [self willCallPlugInFunction];
+    // Set the pluginAllowPopup flag.
+    ASSERT(_eventHandler);
+    bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();
+    frame->script()->setAllowPopupsFromPlugin(_eventHandler->currentEventIsUserGesture());    
     {
         JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
         acceptedEvent = [_pluginPackage.get() pluginFuncs]->event(plugin, event);
     }
+    // Restore the old pluginAllowPopup flag.
+    frame->script()->setAllowPopupsFromPlugin(oldAllowPopups);     
     [self didCallPlugInFunction];
         
     if (portState) {
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 821ba57..b2a3791 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,20 @@
+2010-09-28  Johnny Ding  <jnd at 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 specifying 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-09-28  Simon Fraser  <simon.fraser at apple.com>
 
         Fix export by adding missing argument.
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp
index 5002400..1df1c76 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp
@@ -971,15 +971,18 @@ 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->testWindowOpen = FALSE;
     newInstance->testKeyboardFocusForPlugins = FALSE;
 
+    newInstance->mouseDownForEvaluateScript = FALSE;
+    newInstance->evaluateScriptOnMouseDownOrKeyDown = 0;
+
     return (NPObject*)newInstance;
 }
 
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.h b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.h
index 2c1d325..6c30578 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.h
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.h
@@ -57,6 +57,7 @@ typedef struct {
     NPBool testGetURLOnDestroy;
     NPBool testWindowOpen;
     NPBool testKeyboardFocusForPlugins;
+    NPBool mouseDownForEvaluateScript;
     char* onStreamLoad;
     char* onStreamDestroy;
     char* onDestroy;
@@ -66,6 +67,7 @@ typedef struct {
     char* firstHeaders;
     char* lastUrl;
     char* lastHeaders;
+    char* evaluateScriptOnMouseDownOrKeyDown;
 #ifdef XP_MACOSX
     NPEventModel eventModel;
 #endif
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp
index 23517e2..dd894f4 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp
@@ -218,8 +218,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
@@ -401,6 +413,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);
@@ -408,6 +422,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));
@@ -481,6 +497,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:
@@ -501,6 +519,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)", 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list