diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-16 23:40:15 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-16 23:40:15 +0000 |
commit | 86a18d9f3b81fc6a7425ae20a84b17786605d762 (patch) | |
tree | 31067e682471b02ce89bff768af78dc0a007c60c /webkit | |
parent | d4e53eb321385290f47aaeecb041a9e693f9a24f (diff) | |
download | chromium_src-86a18d9f3b81fc6a7425ae20a84b17786605d762.zip chromium_src-86a18d9f3b81fc6a7425ae20a84b17786605d762.tar.gz chromium_src-86a18d9f3b81fc6a7425ae20a84b17786605d762.tar.bz2 |
Revert 41781 - Revert 41769 Fix test_shell so that eventSender works for opened windows. I've also made focus go to the webview, just like what happens in Chrome.
This is needed for https://bugs.webkit.org/show_bug.cgi?id=36147 and also fixes plugins/keyboardevents.html on Windows.
Review URL: http://codereview.chromium.org/1011005
TBR=jam@chromium.org
Review URL: http://codereview.chromium.org/997008
TBR=stuartmorgan@chromium.org
Review URL: http://codereview.chromium.org/990005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41784 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
12 files changed, 71 insertions, 40 deletions
diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/plugins/plugin-document-has-focus-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/plugins/plugin-document-has-focus-expected.txt new file mode 100644 index 0000000..07a9506 --- /dev/null +++ b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/plugins/plugin-document-has-focus-expected.txt @@ -0,0 +1,3 @@ +CONSOLE MESSAGE: line 1: PLUGIN: keyDown 'A' +CONSOLE MESSAGE: line 1: PLUGIN: keyUp 'A' +This tests that a full page plugin gets keyboard focus without the need to first click it.
\ No newline at end of file diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/plugins/README b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/plugins/README index b3f7df8..5e2667d 100644 --- a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/plugins/README +++ b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/plugins/README @@ -4,4 +4,12 @@ inner-html-display-none ----------------------- The only difference is whitespace differences in the -way functions are printed.
\ No newline at end of file +way functions are printed. + + +keyboard-events +--------------- + +On Windows, windowless plugins get the shift state of the keyboard by quering the OS, since the +WM_KEYDOWN message doesn't contain that information. This is impossible to simulate through +eventSender().
\ No newline at end of file diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/plugins/keyboard-events-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/plugins/keyboard-events-expected.txt new file mode 100644 index 0000000..c944349 --- /dev/null +++ b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/plugins/keyboard-events-expected.txt @@ -0,0 +1,11 @@ +CONSOLE MESSAGE: line 17: PLUGIN: getFocusEvent +CONSOLE MESSAGE: line 17: PLUGIN: mouseDown at (20, 20) +CONSOLE MESSAGE: line 18: PLUGIN: mouseUp at (20, 20) +CONSOLE MESSAGE: line 21: PLUGIN: keyDown 'A' +CONSOLE MESSAGE: line 21: PLUGIN: keyUp 'A' +CONSOLE MESSAGE: line 22: PLUGIN: keyDown 'B' +CONSOLE MESSAGE: line 22: PLUGIN: keyUp 'B' +CONSOLE MESSAGE: line 23: PLUGIN: keyDown 'C' +CONSOLE MESSAGE: line 23: PLUGIN: keyUp 'C' + +This test checks if a plug-in can receive keyboard events sent from eventSender. This is a test for Bug 34936. diff --git a/webkit/tools/layout_tests/test_expectations.txt b/webkit/tools/layout_tests/test_expectations.txt index 624a893..66b3cb4 100644 --- a/webkit/tools/layout_tests/test_expectations.txt +++ b/webkit/tools/layout_tests/test_expectations.txt @@ -2789,7 +2789,6 @@ BUG37896 WIN DEBUG : fast/text/firstline/001.html = PASS CRASH BUG37896 LINUX MAC DEBUG : fast/text/firstline/001.html = PASS CRASH TIMEOUT // Added in http://trac.webkit.org/changeset/55587 BUG37896 : media/video-preload.html = TEXT -BUG37896 : plugins/keyboard-events.html = TEXT BUG37896 LINUX DEBUG : fast/images/svg-as-background.html = TIMEOUT BUG37869 LINUX : fast/images/animated-svg-as-image.html = IMAGE BUG37869 MAC LINUX SKIP : inspector/timeline-network-resource.html = CRASH @@ -2831,5 +2830,9 @@ BUG36415 : fast/events/touch/basic-multi-touch-events.html = TEXT // Most touch tests flaky on WIN for reasons currently unknown. BUG38347 WIN : fast/events/touch = TEXT PASS +// Need to implement NPP_HandleEvent in the layout_test_plugin +BUG38353 MAC LINUX : plugins/keyboard-events.html = TEXT +BUG38353 MAC LINUX : http/tests/plugins/plugin-document-has-focus.html = TEXT + // will rebaseline -BUG_DGLAZKOV WIN : svg/text/text-intro-05-t.svg = FAIL +BUG_DGLAZKOV WIN : svg/text/text-intro-05-t.svg = FAIL
\ No newline at end of file diff --git a/webkit/tools/npapi_layout_test_plugin/PluginObject.cpp b/webkit/tools/npapi_layout_test_plugin/PluginObject.cpp index 4b310ef..026d74f 100644 --- a/webkit/tools/npapi_layout_test_plugin/PluginObject.cpp +++ b/webkit/tools/npapi_layout_test_plugin/PluginObject.cpp @@ -982,6 +982,7 @@ static NPObject *pluginAllocate(NPP npp, NPClass *theClass) newInstance->testDocumentOpenInDestroyStream = FALSE; newInstance->testWindowOpen = FALSE; + newInstance->testKeyboardFocusForPlugins = FALSE; return (NPObject*)newInstance; } diff --git a/webkit/tools/npapi_layout_test_plugin/PluginObject.h b/webkit/tools/npapi_layout_test_plugin/PluginObject.h index 5cab228..8cd63ef 100644 --- a/webkit/tools/npapi_layout_test_plugin/PluginObject.h +++ b/webkit/tools/npapi_layout_test_plugin/PluginObject.h @@ -38,6 +38,7 @@ typedef struct { NPStream* stream; NPBool testWindowOpen; NPBool testDocumentOpenInDestroyStream; + NPBool testKeyboardFocusForPlugins; char* onStreamLoad; char* onStreamDestroy; char* onURLNotify; diff --git a/webkit/tools/npapi_layout_test_plugin/main.cpp b/webkit/tools/npapi_layout_test_plugin/main.cpp index a644d03..9ff3ebb 100644 --- a/webkit/tools/npapi_layout_test_plugin/main.cpp +++ b/webkit/tools/npapi_layout_test_plugin/main.cpp @@ -140,7 +140,8 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, ch obj->testDocumentOpenInDestroyStream = TRUE; } else if (strcasecmp(argn[i], "testwindowopen") == 0) { obj->testWindowOpen = TRUE; - } + } else if (strcasecmp(argn[i], "src") == 0 && strstr(argv[i], "plugin-document-has-focus.pl")) + obj->testKeyboardFocusForPlugins = TRUE; } instance->pdata = obj; @@ -182,13 +183,18 @@ NPError NPP_SetWindow(NPP instance, NPWindow *window) if (obj->logSetWindow) { log(instance, "NPP_SetWindow: %d %d", (int)window->width, (int)window->height); fflush(stdout); - obj->logSetWindow = false; + obj->logSetWindow = FALSE; } if (obj->testWindowOpen) { testWindowOpen(instance); obj->testWindowOpen = FALSE; } + + if (obj->testKeyboardFocusForPlugins) { + obj->eventLogging = true; + executeScript(obj, "eventSender.keyDown('A');"); + } } return NPERR_NO_ERROR; @@ -292,17 +298,17 @@ int16 NPP_HandleEvent(NPP instance, void *event) case WM_RBUTTONDBLCLK: break; case WM_MOUSEMOVE: - log(instance, "adjustCursorEvent"); break; case WM_KEYUP: - // TODO(tc): We need to convert evt->wParam from virtual-key code - // to key code. - log(instance, "NOTIMPLEMENTED: keyUp '%c'", ' '); + log(instance, "keyUp '%c'", MapVirtualKey(evt->wParam, MAPVK_VK_TO_CHAR)); + if (obj->testKeyboardFocusForPlugins) { + obj->eventLogging = false; + obj->testKeyboardFocusForPlugins = FALSE; + executeScript(obj, "layoutTestController.notifyDone();"); + } break; case WM_KEYDOWN: - // TODO(tc): We need to convert evt->wParam from virtual-key code - // to key code. - log(instance, "NOTIMPLEMENTED: keyDown '%c'", ' '); + log(instance, "keyDown '%c'", MapVirtualKey(evt->wParam, MAPVK_VK_TO_CHAR)); break; case WM_SETCURSOR: break; diff --git a/webkit/tools/test_shell/event_sending_controller.cc b/webkit/tools/test_shell/event_sending_controller.cc index 2ab01a0..9cc100f 100644 --- a/webkit/tools/test_shell/event_sending_controller.cc +++ b/webkit/tools/test_shell/event_sending_controller.cc @@ -60,7 +60,6 @@ using WebKit::WebTouchEvent; using WebKit::WebTouchPoint; using WebKit::WebView; -TestShell* EventSendingController::shell_ = NULL; gfx::Point EventSendingController::last_mouse_pos_; WebMouseEvent::Button EventSendingController::pressed_button_ = WebMouseEvent::ButtonNone; @@ -252,13 +251,8 @@ enum KeyLocationCode { } // anonymous namespace EventSendingController::EventSendingController(TestShell* shell) - : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { - // Set static shell_ variable since we can't do it in an initializer list. - // We also need to be careful not to assign shell_ to new windows which are - // temporary. - if (NULL == shell_) - shell_ = shell; - + : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), + shell_(shell) { // Initialize the map that associates methods of this class with the names // they will use when called by JavaScript. The actual binding of those // names to their methods will be done by calling BindToJavaScript() (defined @@ -338,12 +332,10 @@ void EventSendingController::Reset() { touch_points.clear(); } -// static WebView* EventSendingController::webview() { return shell_->webView(); } -// static void EventSendingController::DoDragDrop(const WebKit::WebPoint &event_pos, const WebDragData& drag_data, WebDragOperationsMask mask) { @@ -451,7 +443,6 @@ void EventSendingController::mouseUp( } } -// static void EventSendingController::DoMouseUp(const WebMouseEvent& e) { webview()->handleInputEvent(e); @@ -530,7 +521,6 @@ void EventSendingController::mouseWheelTo( } } -// static void EventSendingController::DoMouseMove(const WebMouseEvent& e) { last_mouse_pos_.SetPoint(e.x, e.y); diff --git a/webkit/tools/test_shell/event_sending_controller.h b/webkit/tools/test_shell/event_sending_controller.h index 4c3c9f2..da7e4df 100644 --- a/webkit/tools/test_shell/event_sending_controller.h +++ b/webkit/tools/test_shell/event_sending_controller.h @@ -41,9 +41,9 @@ class EventSendingController : public CppBoundClass { void Reset(); // Simulate drag&drop system call. - static void DoDragDrop(const WebKit::WebPoint &event_pos, - const WebKit::WebDragData& drag_data, - WebKit::WebDragOperationsMask operations_mask); + void DoDragDrop(const WebKit::WebPoint &event_pos, + const WebKit::WebDragData& drag_data, + WebKit::WebDragOperationsMask operations_mask); // JS callback methods. void mouseDown(const CppArgumentList& args, CppVariant* result); @@ -93,17 +93,17 @@ class EventSendingController : public CppBoundClass { private: // Returns the test shell's webview. - static WebKit::WebView* webview(); + WebKit::WebView* webview(); // Returns true if dragMode is true. bool drag_mode() { return dragMode.isBool() && dragMode.ToBoolean(); } // Sometimes we queue up mouse move and mouse up events for drag drop // handling purposes. These methods dispatch the event. - static void DoMouseMove(const WebKit::WebMouseEvent& e); - static void DoMouseUp(const WebKit::WebMouseEvent& e); + void DoMouseMove(const WebKit::WebMouseEvent& e); + void DoMouseUp(const WebKit::WebMouseEvent& e); static void DoLeapForward(int milliseconds); - static void ReplaySavedEvents(); + void ReplaySavedEvents(); // Helper to return the button type given a button code static WebKit::WebMouseEvent::Button GetButtonTypeFromButtonNumber( @@ -125,7 +125,7 @@ class EventSendingController : public CppBoundClass { ScopedRunnableMethodFactory<EventSendingController> method_factory_; // Non-owning pointer. The LayoutTestController is owned by the host. - static TestShell* shell_; + TestShell* shell_; // Location of last mouseMoveTo event. static gfx::Point last_mouse_pos_; diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h index 10f6371..9595a47 100644 --- a/webkit/tools/test_shell/test_shell.h +++ b/webkit/tools/test_shell/test_shell.h @@ -156,6 +156,9 @@ public: TestNavigationController* navigation_controller() { return navigation_controller_.get(); } + EventSendingController* event_sending_controller() { + return event_sending_controller_.get(); + } // Resets the LayoutTestController and EventSendingController. Should be // called before loading a page, since some end-editing event notifications diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc index 8ce1bcb..8d7f8ec7 100644 --- a/webkit/tools/test_shell/test_shell_win.cc +++ b/webkit/tools/test_shell/test_shell_win.cc @@ -275,13 +275,17 @@ bool TestShell::RunFileTest(const TestParams& params) { if (inspector_test_mode_) shell->ShowDevTools(); - shell->test_is_preparing_ = true; - shell->set_test_params(¶ms); - shell->LoadURL(GURL(params.test_url)); - - shell->test_is_preparing_ = false; - shell->WaitTestFinished(); - shell->set_test_params(NULL); + GURL url(params.test_url); + if (url.is_valid()) { // Don't hang if we have an invalid path. + shell->test_is_preparing_ = true; + shell->set_test_params(¶ms); + shell->LoadURL(url); + shell->test_is_preparing_ = false; + shell->WaitTestFinished(); + shell->set_test_params(NULL); + } else { + NOTREACHED() << "Invalid url: " << url.spec(); + } return true; } diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index a03569c..5a1f2e4 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -558,7 +558,8 @@ void TestWebViewDelegate::startDragging( // When running a test, we need to fake a drag drop operation otherwise // Windows waits for real mouse events to know when the drag is over. - EventSendingController::DoDragDrop(mouse_coords, mutable_drag_data, mask); + shell_->event_sending_controller()->DoDragDrop( + mouse_coords, mutable_drag_data, mask); } else { // TODO(tc): Drag and drop is disabled in the test shell because we need // to be able to convert from WebDragData to an IDataObject. |