Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: webkit/glue/plugins/test/plugin_javascript_open_popup.cc

Issue 6012002: Move the NPAPI files from webkit/glue/plugins to webkit/plugins/npapi and put... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 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 "build/build_config.h"
6 #include "webkit/glue/plugins/test/plugin_javascript_open_popup.h"
7
8 #if defined(USE_X11)
9 #include "third_party/npapi/bindings/npapi_x11.h"
10 #endif
11 #include "webkit/glue/plugins/test/plugin_client.h"
12
13 namespace NPAPIClient {
14
15 ExecuteJavascriptOpenPopupWithPluginTest::
16 ExecuteJavascriptOpenPopupWithPluginTest(NPP id,
17 NPNetscapeFuncs *host_functions)
18 : PluginTest(id, host_functions),
19 popup_window_test_started_(false) {
20 }
21
22 int16 ExecuteJavascriptOpenPopupWithPluginTest::SetWindow(
23 NPWindow* window) {
24 if (window->window == NULL)
25 return NPERR_NO_ERROR;
26
27 if (!popup_window_test_started_) {
28 popup_window_test_started_ = true;
29 HostFunctions()->geturl(
30 id(), "popup_window_with_target_plugin.html", "_blank");
31 }
32 return NPERR_NO_ERROR;
33 }
34
35 // ExecuteJavascriptPopupWindowTargetPluginTest member defines.
36 ExecuteJavascriptPopupWindowTargetPluginTest::
37 ExecuteJavascriptPopupWindowTargetPluginTest(
38 NPP id, NPNetscapeFuncs* host_functions)
39 : PluginTest(id, host_functions),
40 test_completed_(false) {
41 }
42
43 int16 ExecuteJavascriptPopupWindowTargetPluginTest::SetWindow(
44 NPWindow* window) {
45 if (window->window == NULL)
46 return NPERR_NO_ERROR;
47
48 if (!test_completed_) {
49 if (CheckWindow(window)) {
50 SignalTestCompleted();
51 test_completed_ = true;
52 }
53 }
54 return PluginTest::SetWindow(window);
55 }
56
57 #if defined(OS_WIN)
58 bool ExecuteJavascriptPopupWindowTargetPluginTest::CheckWindow(
59 NPWindow* window) {
60 HWND window_handle = reinterpret_cast<HWND>(window->window);
61
62 if (IsWindow(window_handle)) {
63 HWND parent_window = GetParent(window_handle);
64 if (!IsWindow(parent_window) || parent_window == GetDesktopWindow())
65 SetError("Windowed plugin instantiated with NULL parent");
66 return true;
67 }
68
69 return false;
70 }
71
72 #elif defined(USE_X11)
73 // This code blindly follows the same sorts of verifications done on
74 // the Windows side. Does it make sense on X? Maybe not really, but
75 // it can't hurt to do extra validations.
76 bool ExecuteJavascriptPopupWindowTargetPluginTest::CheckWindow(
77 NPWindow* window) {
78 Window xwindow = reinterpret_cast<Window>(window->window);
79 // Grab a pointer to the extra SetWindow data so we can grab the display out.
80 NPSetWindowCallbackStruct* extra =
81 static_cast<NPSetWindowCallbackStruct*>(window->ws_info);
82
83 if (xwindow) {
84 Window root, parent;
85 Status status = XQueryTree(extra->display, xwindow, &root, &parent,
86 NULL, NULL); // NULL children info.
87 DCHECK(status != 0);
88 if (!parent || parent == root)
89 SetError("Windowed plugin instantiated with NULL parent");
90 return true;
91 }
92
93 return false;
94 }
95 #elif defined(OS_MACOSX)
96 bool ExecuteJavascriptPopupWindowTargetPluginTest::CheckWindow(
97 NPWindow* window) {
98 // TODO(port) scaffolding--replace with a real test once NPWindow is done.
99 return false;
100 }
101 #endif
102
103 } // namespace NPAPIClient
OLDNEW
« no previous file with comments | « webkit/glue/plugins/test/plugin_javascript_open_popup.h ('k') | webkit/glue/plugins/test/plugin_new_fails_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698