Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #define STRSAFE_NO_DEPRECATE | 5 #define STRSAFE_NO_DEPRECATE |
| 6 #include "webkit/glue/plugins/test/plugin_windowless_test.h" | 6 #include "webkit/glue/plugins/test/plugin_windowless_test.h" |
| 7 #include "webkit/glue/plugins/test/plugin_client.h" | 7 #include "webkit/glue/plugins/test/plugin_client.h" |
| 8 | 8 |
| 9 namespace NPAPIClient { | 9 namespace NPAPIClient { |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 NPError result = browser->getvalue(id(), NPNVSupportsWindowless, | 22 NPError result = browser->getvalue(id(), NPNVSupportsWindowless, |
| 23 &supports_windowless); | 23 &supports_windowless); |
| 24 if ((result != NPERR_NO_ERROR) || (supports_windowless != TRUE)) { | 24 if ((result != NPERR_NO_ERROR) || (supports_windowless != TRUE)) { |
| 25 SetError("Failed to read NPNVSupportsWindowless value"); | 25 SetError("Failed to read NPNVSupportsWindowless value"); |
| 26 SignalTestCompleted(); | 26 SignalTestCompleted(); |
| 27 return PluginTest::HandleEvent(event); | 27 return PluginTest::HandleEvent(event); |
| 28 } | 28 } |
| 29 | 29 |
| 30 NPEvent* np_event = reinterpret_cast<NPEvent*>(event); | 30 NPEvent* np_event = reinterpret_cast<NPEvent*>(event); |
| 31 if (WM_PAINT == np_event->event && | 31 if (WM_PAINT == np_event->event && |
| 32 base::strcasecmp(test_name_.c_str(), | 32 test_name_ == "execute_script_delete_in_paint") { |
| 33 "execute_script_delete_in_paint") == 0) { | |
| 34 HDC paint_dc = reinterpret_cast<HDC>(np_event->wParam); | 33 HDC paint_dc = reinterpret_cast<HDC>(np_event->wParam); |
| 35 if (paint_dc == NULL) { | 34 if (paint_dc == NULL) { |
| 36 SetError("Invalid Window DC passed to HandleEvent for WM_PAINT"); | 35 SetError("Invalid Window DC passed to HandleEvent for WM_PAINT"); |
| 37 SignalTestCompleted(); | 36 SignalTestCompleted(); |
| 38 return NPERR_GENERIC_ERROR; | 37 return NPERR_GENERIC_ERROR; |
| 39 } | 38 } |
| 40 | 39 |
| 41 HRGN clipping_region = CreateRectRgn(0, 0, 0, 0); | 40 HRGN clipping_region = CreateRectRgn(0, 0, 0, 0); |
| 42 if (!GetClipRgn(paint_dc, clipping_region)) { | 41 if (!GetClipRgn(paint_dc, clipping_region)) { |
| 43 SetError("No clipping region set in window DC"); | 42 SetError("No clipping region set in window DC"); |
| 44 DeleteObject(clipping_region); | 43 DeleteObject(clipping_region); |
| 45 SignalTestCompleted(); | 44 SignalTestCompleted(); |
| 46 return NPERR_GENERIC_ERROR; | 45 return NPERR_GENERIC_ERROR; |
| 47 } | 46 } |
| 48 | 47 |
| 49 DeleteObject(clipping_region); | 48 DeleteObject(clipping_region); |
| 50 | 49 |
| 51 NPUTF8* urlString = "javascript:DeletePluginWithinScript()"; | 50 NPUTF8* urlString = "javascript:DeletePluginWithinScript()"; |
| 52 NPUTF8* targetString = NULL; | 51 NPUTF8* targetString = NULL; |
| 53 browser->geturl(id(), urlString, targetString); | 52 browser->geturl(id(), urlString, targetString); |
| 54 SignalTestCompleted(); | 53 SignalTestCompleted(); |
| 55 } else if (WM_MOUSEMOVE == np_event->event && | 54 } else if (WM_MOUSEMOVE == np_event->event && |
| 56 base::strcasecmp(test_name_.c_str(), | 55 test_name_ == "execute_script_delete_in_mouse_move") { |
| 57 "execute_script_delete_in_mouse_move") == 0) { | |
| 58 std::string script = "javascript:DeletePluginWithinScript()"; | 56 std::string script = "javascript:DeletePluginWithinScript()"; |
| 59 NPString script_string; | 57 NPString script_string; |
| 60 script_string.UTF8Characters = script.c_str(); | 58 script_string.UTF8Characters = script.c_str(); |
| 61 script_string.UTF8Length = | 59 script_string.UTF8Length = static_cast<unsigned int>(script.length()); |
| 62 static_cast<unsigned int>(script.length()); | |
| 63 | 60 |
| 64 NPObject *window_obj = NULL; | 61 NPObject *window_obj = NULL; |
| 65 browser->getvalue(id(), NPNVWindowNPObject, &window_obj); | 62 browser->getvalue(id(), NPNVWindowNPObject, &window_obj); |
| 66 NPVariant result_var; | 63 NPVariant result_var; |
| 67 NPError result = browser->evaluate(id(), window_obj, | 64 NPError result = browser->evaluate(id(), window_obj, |
| 68 &script_string, &result_var); | 65 &script_string, &result_var); |
| 69 SignalTestCompleted(); | 66 SignalTestCompleted(); |
| 67 } else if (WM_LBUTTONUP == np_event->event && | |
| 68 test_name_ == "delete_frame_test") { | |
| 69 std::string script = | |
| 70 "javascript:parent.document.getElementById('frame').outerHTML = ''"; | |
| 71 NPString script_string; | |
| 72 script_string.UTF8Characters = script.c_str(); | |
| 73 script_string.UTF8Length = static_cast<unsigned int>(script.length()); | |
| 74 | |
| 75 NPObject *window_obj = NULL; | |
| 76 browser->getvalue(id(), NPNVWindowNPObject, &window_obj); | |
| 77 NPVariant result_var; | |
| 78 NPError result = browser->evaluate(id(), window_obj, | |
|
ananta
2009/04/16 16:37:24
For consistency should we call SignalTestCompleted
jam
2009/04/16 17:56:13
I think it would confuse things since this isn't r
| |
| 79 &script_string, &result_var); | |
| 70 } | 80 } |
| 71 // If this test failed, then we'd have crashed by now. | 81 // If this test failed, then we'd have crashed by now. |
| 72 return PluginTest::HandleEvent(event); | 82 return PluginTest::HandleEvent(event); |
| 73 } | 83 } |
| 74 | 84 |
| 75 } // namespace NPAPIClient | 85 } // namespace NPAPIClient |
| OLD | NEW |