| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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 #include "content/test/plugin/plugin_javascript_open_popup.h" | |
| 6 | |
| 7 #include "build/build_config.h" | |
| 8 #include "base/logging.h" | |
| 9 | |
| 10 #include "content/test/plugin/plugin_client.h" | |
| 11 | |
| 12 namespace NPAPIClient { | |
| 13 | |
| 14 ExecuteJavascriptOpenPopupWithPluginTest:: | |
| 15 ExecuteJavascriptOpenPopupWithPluginTest(NPP id, | |
| 16 NPNetscapeFuncs *host_functions) | |
| 17 : PluginTest(id, host_functions), | |
| 18 popup_window_test_started_(false) { | |
| 19 } | |
| 20 | |
| 21 int16 ExecuteJavascriptOpenPopupWithPluginTest::SetWindow( | |
| 22 NPWindow* window) { | |
| 23 #if !defined(OS_MACOSX) | |
| 24 if (window->window == NULL) | |
| 25 return NPERR_NO_ERROR; | |
| 26 #endif | |
| 27 | |
| 28 if (!popup_window_test_started_) { | |
| 29 popup_window_test_started_ = true; | |
| 30 HostFunctions()->geturl( | |
| 31 id(), "popup_window_with_target_plugin.html", "_blank"); | |
| 32 } | |
| 33 return NPERR_NO_ERROR; | |
| 34 } | |
| 35 | |
| 36 // ExecuteJavascriptPopupWindowTargetPluginTest member defines. | |
| 37 ExecuteJavascriptPopupWindowTargetPluginTest:: | |
| 38 ExecuteJavascriptPopupWindowTargetPluginTest( | |
| 39 NPP id, NPNetscapeFuncs* host_functions) | |
| 40 : PluginTest(id, host_functions), | |
| 41 test_completed_(false) { | |
| 42 } | |
| 43 | |
| 44 int16 ExecuteJavascriptPopupWindowTargetPluginTest::SetWindow( | |
| 45 NPWindow* window) { | |
| 46 #if !defined(OS_MACOSX) | |
| 47 if (window->window == NULL) | |
| 48 return NPERR_NO_ERROR; | |
| 49 #endif | |
| 50 | |
| 51 if (!test_completed_) { | |
| 52 if (CheckWindow(window)) { | |
| 53 SignalTestCompleted(); | |
| 54 test_completed_ = true; | |
| 55 } | |
| 56 } | |
| 57 return PluginTest::SetWindow(window); | |
| 58 } | |
| 59 | |
| 60 #if defined(OS_WIN) | |
| 61 bool ExecuteJavascriptPopupWindowTargetPluginTest::CheckWindow( | |
| 62 NPWindow* window) { | |
| 63 HWND window_handle = reinterpret_cast<HWND>(window->window); | |
| 64 | |
| 65 if (IsWindow(window_handle)) { | |
| 66 HWND parent_window = GetParent(window_handle); | |
| 67 if (!IsWindow(parent_window)) | |
| 68 SetError("Windowed plugin instantiated with NULL parent"); | |
| 69 return true; | |
| 70 } | |
| 71 | |
| 72 return false; | |
| 73 } | |
| 74 | |
| 75 #elif defined(OS_MACOSX) | |
| 76 bool ExecuteJavascriptPopupWindowTargetPluginTest::CheckWindow( | |
| 77 NPWindow* window) { | |
| 78 // TODO(port) scaffolding--replace with a real test once NPWindow is done. | |
| 79 return false; | |
| 80 } | |
| 81 #endif | |
| 82 | |
| 83 } // namespace NPAPIClient | |
| OLD | NEW |