| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "webkit/glue/plugins/test/plugin_windowed_test.h" | 5 #include "webkit/glue/plugins/test/plugin_windowed_test.h" |
| 6 #include "webkit/glue/plugins/test/plugin_client.h" | 6 #include "webkit/glue/plugins/test/plugin_client.h" |
| 7 | 7 |
| 8 namespace NPAPIClient { | 8 namespace NPAPIClient { |
| 9 | 9 |
| 10 WindowedPluginTest::WindowedPluginTest(NPP id, NPNetscapeFuncs *host_functions) | 10 WindowedPluginTest::WindowedPluginTest(NPP id, NPNetscapeFuncs *host_functions) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 MAKEINTATOM(window_class), 0, | 57 MAKEINTATOM(window_class), 0, |
| 58 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE , | 58 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE , |
| 59 0, 0, 100, 100, parent, 0, GetModuleHandle(NULL), 0); | 59 0, 0, 100, 100, parent, 0, GetModuleHandle(NULL), 0); |
| 60 DCHECK(window_); | 60 DCHECK(window_); |
| 61 ::SetProp(window_, L"Plugin_Instance", this); | 61 ::SetProp(window_, L"Plugin_Instance", this); |
| 62 } | 62 } |
| 63 | 63 |
| 64 return NPERR_NO_ERROR; | 64 return NPERR_NO_ERROR; |
| 65 } | 65 } |
| 66 | 66 |
| 67 NPError WindowedPluginTest::Destroy() { |
| 68 if (test_name() != "ensure_scripting_works_in_destroy") |
| 69 return NPERR_NO_ERROR; |
| 70 |
| 71 // Bug 23706: ensure that scripting works with no asserts. |
| 72 NPObject *window_obj = NULL; |
| 73 HostFunctions()->getvalue(id(), NPNVWindowNPObject,&window_obj); |
| 74 |
| 75 if (!window_obj) { |
| 76 SetError("Failed to get NPObject for plugin instance"); |
| 77 } else { |
| 78 std::string script = "javascript:GetMagicNumber()"; |
| 79 NPString script_string; |
| 80 script_string.UTF8Characters = script.c_str(); |
| 81 script_string.UTF8Length = |
| 82 static_cast<unsigned int>(script.length()); |
| 83 |
| 84 NPVariant result_var; |
| 85 bool result = HostFunctions()->evaluate( |
| 86 id(), window_obj, &script_string, &result_var); |
| 87 if (!result || |
| 88 result_var.type != NPVariantType_Int32 || |
| 89 result_var.value.intValue != 42) { |
| 90 SetError("Failed to script during NPP_Destroy"); |
| 91 } |
| 92 } |
| 93 |
| 94 SignalTestCompleted(); |
| 95 return NPERR_NO_ERROR; |
| 96 } |
| 97 |
| 67 void WindowedPluginTest::CallJSFunction( | 98 void WindowedPluginTest::CallJSFunction( |
| 68 WindowedPluginTest* this_ptr, const char* function) { | 99 WindowedPluginTest* this_ptr, const char* function) { |
| 69 NPIdentifier function_id = this_ptr->HostFunctions()->getstringidentifier( | 100 NPIdentifier function_id = this_ptr->HostFunctions()->getstringidentifier( |
| 70 function); | 101 function); |
| 71 | 102 |
| 72 NPObject *window_obj = NULL; | 103 NPObject *window_obj = NULL; |
| 73 this_ptr->HostFunctions()->getvalue( | 104 this_ptr->HostFunctions()->getvalue( |
| 74 this_ptr->id(), NPNVWindowNPObject, &window_obj); | 105 this_ptr->id(), NPNVWindowNPObject, &window_obj); |
| 75 | 106 |
| 76 NPVariant rv; | 107 NPVariant rv; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 96 // and verify that we don't hang the browser. | 127 // and verify that we don't hang the browser. |
| 97 CallJSFunction(this_ptr, "CallAlert"); | 128 CallJSFunction(this_ptr, "CallAlert"); |
| 98 CallJSFunction(this_ptr, "CallAlert"); | 129 CallJSFunction(this_ptr, "CallAlert"); |
| 99 } | 130 } |
| 100 } | 131 } |
| 101 | 132 |
| 102 return DefWindowProc(window, message, wparam, lparam); | 133 return DefWindowProc(window, message, wparam, lparam); |
| 103 } | 134 } |
| 104 | 135 |
| 105 } // namespace NPAPIClient | 136 } // namespace NPAPIClient |
| OLD | NEW |