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.
5 #include "content/test/plugin/plugin_javascript_open_popup.h"
7 #include "build/build_config.h"
8 #include "base/logging.h"
10 #include "content/test/plugin/plugin_client.h"
12 namespace NPAPIClient
{
14 ExecuteJavascriptOpenPopupWithPluginTest::
15 ExecuteJavascriptOpenPopupWithPluginTest(NPP id
,
16 NPNetscapeFuncs
*host_functions
)
17 : PluginTest(id
, host_functions
),
18 popup_window_test_started_(false) {
21 int16
ExecuteJavascriptOpenPopupWithPluginTest::SetWindow(
23 #if !defined(OS_MACOSX)
24 if (window
->window
== NULL
)
25 return NPERR_NO_ERROR
;
28 if (!popup_window_test_started_
) {
29 popup_window_test_started_
= true;
30 HostFunctions()->geturl(
31 id(), "popup_window_with_target_plugin.html", "_blank");
33 return NPERR_NO_ERROR
;
36 // ExecuteJavascriptPopupWindowTargetPluginTest member defines.
37 ExecuteJavascriptPopupWindowTargetPluginTest::
38 ExecuteJavascriptPopupWindowTargetPluginTest(
39 NPP id
, NPNetscapeFuncs
* host_functions
)
40 : PluginTest(id
, host_functions
),
41 test_completed_(false) {
44 int16
ExecuteJavascriptPopupWindowTargetPluginTest::SetWindow(
46 #if !defined(OS_MACOSX)
47 if (window
->window
== NULL
)
48 return NPERR_NO_ERROR
;
51 if (!test_completed_
) {
52 if (CheckWindow(window
)) {
53 SignalTestCompleted();
54 test_completed_
= true;
57 return PluginTest::SetWindow(window
);
61 bool ExecuteJavascriptPopupWindowTargetPluginTest::CheckWindow(
63 HWND window_handle
= reinterpret_cast<HWND
>(window
->window
);
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");
75 #elif defined(OS_MACOSX)
76 bool ExecuteJavascriptPopupWindowTargetPluginTest::CheckWindow(
78 // TODO(port) scaffolding--replace with a real test once NPWindow is done.
83 } // namespace NPAPIClient