| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #define STRSAFE_NO_DEPRECATE | |
| 6 #include "webkit/glue/plugins/test/plugin_execute_script_delete_test.h" | |
| 7 #include "webkit/glue/plugins/test/plugin_client.h" | |
| 8 | |
| 9 namespace NPAPIClient { | |
| 10 | |
| 11 ExecuteScriptDeleteTest::ExecuteScriptDeleteTest( | |
| 12 NPP id, NPNetscapeFuncs *host_functions, const std::string& test_name) | |
| 13 : PluginTest(id, host_functions), | |
| 14 test_name_(test_name) { | |
| 15 } | |
| 16 | |
| 17 int16 ExecuteScriptDeleteTest::HandleEvent(void* event) { | |
| 18 | |
| 19 NPNetscapeFuncs* browser = NPAPIClient::PluginClient::HostFunctions(); | |
| 20 | |
| 21 NPBool supports_windowless = 0; | |
| 22 NPError result = browser->getvalue(id(), NPNVSupportsWindowless, | |
| 23 &supports_windowless); | |
| 24 if ((result != NPERR_NO_ERROR) || (supports_windowless != TRUE)) { | |
| 25 SetError("Failed to read NPNVSupportsWindowless value"); | |
| 26 SignalTestCompleted(); | |
| 27 return PluginTest::HandleEvent(event); | |
| 28 } | |
| 29 | |
| 30 NPEvent* np_event = reinterpret_cast<NPEvent*>(event); | |
| 31 if (WM_PAINT == np_event->event && | |
| 32 base::strcasecmp(test_name_.c_str(), | |
| 33 "execute_script_delete_in_paint") == 0) { | |
| 34 NPUTF8* urlString = "javascript:DeletePluginWithinScript()"; | |
| 35 NPUTF8* targetString = NULL; | |
| 36 browser->geturl(id(), urlString, targetString); | |
| 37 SignalTestCompleted(); | |
| 38 } else if (WM_MOUSEMOVE == np_event->event && | |
| 39 base::strcasecmp(test_name_.c_str(), | |
| 40 "execute_script_delete_in_mouse_move") == 0) { | |
| 41 std::string script = "javascript:DeletePluginWithinScript()"; | |
| 42 NPString script_string; | |
| 43 script_string.UTF8Characters = script.c_str(); | |
| 44 script_string.UTF8Length = | |
| 45 static_cast<unsigned int>(script.length()); | |
| 46 | |
| 47 NPObject *window_obj = NULL; | |
| 48 browser->getvalue(id(), NPNVWindowNPObject, &window_obj); | |
| 49 NPVariant result_var; | |
| 50 NPError result = browser->evaluate(id(), window_obj, | |
| 51 &script_string, &result_var); | |
| 52 SignalTestCompleted(); | |
| 53 } | |
| 54 // If this test failed, then we'd have crashed by now. | |
| 55 return PluginTest::HandleEvent(event); | |
| 56 } | |
| 57 | |
| 58 } // namespace NPAPIClient | |
| OLD | NEW |