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

Side by Side Diff: chrome/browser/chrome_plugin_browsertest.cc

Issue 152913002: Merge 247881 "Fix windowed plugins not appearing if opened in th..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1750/src/
Patch Set: Created 6 years, 10 months 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
« no previous file with comments | « no previous file | chrome/test/data/windowed_npapi_plugin.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/prefs/pref_service.h"
13 #include "base/process/kill.h" 14 #include "base/process/kill.h"
14 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
15 #include "chrome/browser/plugins/plugin_prefs.h" 16 #include "chrome/browser/plugins/plugin_prefs.h"
17 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 19 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "chrome/common/pref_names.h"
18 #include "chrome/test/base/in_process_browser_test.h" 21 #include "chrome/test/base/in_process_browser_test.h"
19 #include "chrome/test/base/ui_test_utils.h" 22 #include "chrome/test/base/ui_test_utils.h"
20 #include "content/public/browser/browser_child_process_host_iterator.h" 23 #include "content/public/browser/browser_child_process_host_iterator.h"
21 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/child_process_data.h" 25 #include "content/public/browser/child_process_data.h"
23 #include "content/public/browser/plugin_service.h" 26 #include "content/public/browser/plugin_service.h"
27 #include "content/public/browser/web_contents.h"
24 #include "content/public/common/content_constants.h" 28 #include "content/public/common/content_constants.h"
25 #include "content/public/common/content_paths.h" 29 #include "content/public/common/content_paths.h"
26 #include "content/public/common/process_type.h" 30 #include "content/public/common/process_type.h"
27 #include "content/public/common/webplugininfo.h" 31 #include "content/public/common/webplugininfo.h"
28 #include "content/public/test/browser_test_utils.h" 32 #include "content/public/test/browser_test_utils.h"
29 #include "content/public/test/test_utils.h" 33 #include "content/public/test/test_utils.h"
30 #include "net/base/net_util.h" 34 #include "net/base/net_util.h"
31 35
36 #if defined(OS_WIN)
37 #include "content/public/browser/web_contents_view.h"
38 #include "ui/aura/root_window.h"
39 #include "ui/aura/window.h"
40 #endif
41
32 using content::BrowserThread; 42 using content::BrowserThread;
33 43
34 namespace { 44 namespace {
35 45
36 class CallbackBarrier : public base::RefCountedThreadSafe<CallbackBarrier> { 46 class CallbackBarrier : public base::RefCountedThreadSafe<CallbackBarrier> {
37 public: 47 public:
38 explicit CallbackBarrier(const base::Closure& target_callback) 48 explicit CallbackBarrier(const base::Closure& target_callback)
39 : target_callback_(target_callback), 49 : target_callback_(target_callback),
40 outstanding_callbacks_(0), 50 outstanding_callbacks_(0),
41 did_enable_(true) { 51 did_enable_(true) {
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 std::vector<content::WebPluginInfo> plugins = GetPlugins(); 265 std::vector<content::WebPluginInfo> plugins = GetPlugins();
256 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(expected); ++i) { 266 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(expected); ++i) {
257 size_t j = 0; 267 size_t j = 0;
258 for (; j < plugins.size(); ++j) { 268 for (; j < plugins.size(); ++j) {
259 if (plugins[j].name == ASCIIToUTF16(expected[i])) 269 if (plugins[j].name == ASCIIToUTF16(expected[i]))
260 break; 270 break;
261 } 271 }
262 ASSERT_TRUE(j != plugins.size()) << "Didn't find " << expected[i]; 272 ASSERT_TRUE(j != plugins.size()) << "Didn't find " << expected[i];
263 } 273 }
264 } 274 }
275
276 #if defined(OS_WIN)
277
278 namespace {
279
280 BOOL CALLBACK EnumerateChildren(HWND hwnd, LPARAM l_param) {
281 HWND* child = reinterpret_cast<HWND*>(l_param);
282 *child = hwnd;
283 // The first child window is the plugin, then its children. So stop
284 // enumerating after the first callback.
285 return FALSE;
286 }
287
288 }
289
290 // Test that if a background tab loads an NPAPI plugin, they are displayed after
291 // switching to that page. http://crbug.com/335900
292 IN_PROC_BROWSER_TEST_F(ChromePluginTest, WindowedNPAPIPluginHidden) {
293 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize,
294 true);
295
296 // First load the page in the background and wait for the NPAPI plugin's
297 // window to be created.
298 GURL url = ui_test_utils::GetTestUrl(
299 base::FilePath(),
300 base::FilePath().AppendASCII("windowed_npapi_plugin.html"));
301
302 ui_test_utils::NavigateToURLWithDisposition(
303 browser(), url, NEW_BACKGROUND_TAB,
304 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
305
306 // We create a third window just to trigger the second one to update its
307 // constrained window list. Normally this would be triggered by the status bar
308 // animation closing after the user middle clicked a link.
309 ui_test_utils::NavigateToURLWithDisposition(
310 browser(), GURL("about:blank"), NEW_BACKGROUND_TAB,
311 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
312
313 base::string16 expected_title(base::ASCIIToUTF16("created"));
314 content::WebContents* tab =
315 browser()->tab_strip_model()->GetWebContentsAt(1);
316 if (tab->GetTitle() != expected_title) {
317 content::TitleWatcher title_watcher(tab, expected_title);
318 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
319 }
320
321 // Now activate the tab and verify that the plugin painted.
322 browser()->tab_strip_model()->ActivateTabAt(1, true);
323
324 base::string16 expected_title2(base::ASCIIToUTF16("shown"));
325 content::TitleWatcher title_watcher2(tab, expected_title2);
326 EXPECT_EQ(expected_title2, title_watcher2.WaitAndGetTitle());
327
328 HWND child = NULL;
329 HWND hwnd = tab->GetView()->GetNativeView()->GetDispatcher()->host()->
330 GetAcceleratedWidget();
331 EnumChildWindows(hwnd, EnumerateChildren,reinterpret_cast<LPARAM>(&child));
332
333 RECT region;
334 int result = GetWindowRgnBox(child, &region);
335 ASSERT_NE(result, NULLREGION);
336 }
337
338 #endif
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/windowed_npapi_plugin.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698