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

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

Issue 150073002: Fix windowed plugins not appearing if opened in the background until the browser resizes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 std::vector<content::WebPluginInfo> plugins = GetPlugins(); 266 std::vector<content::WebPluginInfo> plugins = GetPlugins();
257 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(expected); ++i) { 267 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(expected); ++i) {
258 size_t j = 0; 268 size_t j = 0;
259 for (; j < plugins.size(); ++j) { 269 for (; j < plugins.size(); ++j) {
260 if (plugins[j].name == base::ASCIIToUTF16(expected[i])) 270 if (plugins[j].name == base::ASCIIToUTF16(expected[i]))
261 break; 271 break;
262 } 272 }
263 ASSERT_TRUE(j != plugins.size()) << "Didn't find " << expected[i]; 273 ASSERT_TRUE(j != plugins.size()) << "Didn't find " << expected[i];
264 } 274 }
265 } 275 }
276
277 #if defined(OS_WIN)
278
279 namespace {
280
281 BOOL CALLBACK EnumerateChildren(HWND hwnd, LPARAM l_param) {
282 HWND* child = reinterpret_cast<HWND*>(l_param);
283 *child = hwnd;
284 // The first child window is the plugin, then its children. So stop
285 // enumerating after the first callback.
286 return FALSE;
287 }
288
289 }
290
291 // Test that if a background tab loads an NPAPI plugin, they are displayed after
292 // switching to that page. http://crbug.com/335900
293 IN_PROC_BROWSER_TEST_F(ChromePluginTest, WindowedNPAPIPluginHidden) {
294 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize,
295 true);
296
297 // First load the page in the background and wait for the NPAPI plugin's
298 // window to be created.
299 GURL url = ui_test_utils::GetTestUrl(
300 base::FilePath(),
301 base::FilePath().AppendASCII("windowed_npapi_plugin.html"));
302
303 ui_test_utils::NavigateToURLWithDisposition(
304 browser(), url, NEW_BACKGROUND_TAB,
305 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
306
307 // We create a third window just to trigger the second one to update its
308 // constrained window list. Normally this would be triggered by the status bar
309 // animation closing after the user middle clicked a link.
310 ui_test_utils::NavigateToURLWithDisposition(
311 browser(), GURL("about:blank"), NEW_BACKGROUND_TAB,
312 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
313
314 base::string16 expected_title(base::ASCIIToUTF16("created"));
315 content::WebContents* tab =
316 browser()->tab_strip_model()->GetWebContentsAt(1);
317 if (tab->GetTitle() != expected_title) {
318 content::TitleWatcher title_watcher(tab, expected_title);
319 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
320 }
321
322 // Now activate the tab and verify that the plugin painted.
323 browser()->tab_strip_model()->ActivateTabAt(1, true);
324
325 base::string16 expected_title2(base::ASCIIToUTF16("shown"));
326 content::TitleWatcher title_watcher2(tab, expected_title2);
327 EXPECT_EQ(expected_title2, title_watcher2.WaitAndGetTitle());
328
329 HWND child = NULL;
330 HWND hwnd = tab->GetView()->GetNativeView()->GetDispatcher()->host()->
331 GetAcceleratedWidget();
332 EnumChildWindows(hwnd, EnumerateChildren,reinterpret_cast<LPARAM>(&child));
333
334 RECT region;
335 int result = GetWindowRgnBox(child, &region);
336 ASSERT_NE(result, NULLREGION);
337 }
338
339 #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