This source file includes following definitions.
- popup_window_test_started_
- SetWindow
- test_completed_
- SetWindow
- CheckWindow
- CheckWindow
- CheckWindow
#include "content/test/plugin/plugin_javascript_open_popup.h"
#include "build/build_config.h"
#include "base/logging.h"
#if defined(USE_X11)
#include "third_party/npapi/bindings/npapi_x11.h"
#endif
#include "content/test/plugin/plugin_client.h"
namespace NPAPIClient {
ExecuteJavascriptOpenPopupWithPluginTest::
ExecuteJavascriptOpenPopupWithPluginTest(NPP id,
NPNetscapeFuncs *host_functions)
: PluginTest(id, host_functions),
popup_window_test_started_(false) {
}
int16 ExecuteJavascriptOpenPopupWithPluginTest::SetWindow(
NPWindow* window) {
#if !defined(OS_MACOSX)
if (window->window == NULL)
return NPERR_NO_ERROR;
#endif
if (!popup_window_test_started_) {
popup_window_test_started_ = true;
HostFunctions()->geturl(
id(), "popup_window_with_target_plugin.html", "_blank");
}
return NPERR_NO_ERROR;
}
ExecuteJavascriptPopupWindowTargetPluginTest::
ExecuteJavascriptPopupWindowTargetPluginTest(
NPP id, NPNetscapeFuncs* host_functions)
: PluginTest(id, host_functions),
test_completed_(false) {
}
int16 ExecuteJavascriptPopupWindowTargetPluginTest::SetWindow(
NPWindow* window) {
#if !defined(OS_MACOSX)
if (window->window == NULL)
return NPERR_NO_ERROR;
#endif
if (!test_completed_) {
if (CheckWindow(window)) {
SignalTestCompleted();
test_completed_ = true;
}
}
return PluginTest::SetWindow(window);
}
#if defined(OS_WIN)
bool ExecuteJavascriptPopupWindowTargetPluginTest::CheckWindow(
NPWindow* window) {
HWND window_handle = reinterpret_cast<HWND>(window->window);
if (IsWindow(window_handle)) {
HWND parent_window = GetParent(window_handle);
if (!IsWindow(parent_window))
SetError("Windowed plugin instantiated with NULL parent");
return true;
}
return false;
}
#elif defined(USE_X11)
bool ExecuteJavascriptPopupWindowTargetPluginTest::CheckWindow(
NPWindow* window) {
Window xwindow = reinterpret_cast<Window>(window->window);
NPSetWindowCallbackStruct* extra =
static_cast<NPSetWindowCallbackStruct*>(window->ws_info);
if (xwindow) {
Window root, parent;
Window* wins = NULL;
unsigned int num_child;
Status status = XQueryTree(extra->display, xwindow, &root, &parent,
&wins, &num_child);
if (wins)
XFree(wins);
DCHECK(status != 0);
if (!parent || parent == root)
SetError("Windowed plugin instantiated with NULL parent");
return true;
}
return false;
}
#elif defined(OS_MACOSX)
bool ExecuteJavascriptPopupWindowTargetPluginTest::CheckWindow(
NPWindow* window) {
return false;
}
#endif
}