Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / test / plugin / plugin_javascript_open_popup.cc
blob0b8daf8280ceca7a0770bf8dce0ea4d288f0d614
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(
22 NPWindow* window) {
23 #if !defined(OS_MACOSX)
24 if (window->window == NULL)
25 return NPERR_NO_ERROR;
26 #endif
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(
45 NPWindow* window) {
46 #if !defined(OS_MACOSX)
47 if (window->window == NULL)
48 return NPERR_NO_ERROR;
49 #endif
51 if (!test_completed_) {
52 if (CheckWindow(window)) {
53 SignalTestCompleted();
54 test_completed_ = true;
57 return PluginTest::SetWindow(window);
60 #if defined(OS_WIN)
61 bool ExecuteJavascriptPopupWindowTargetPluginTest::CheckWindow(
62 NPWindow* window) {
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");
69 return true;
72 return false;
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;
81 #endif
83 } // namespace NPAPIClient