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

Side by Side Diff: chrome/browser/ui/views/location_bar/star_view_browsertest.cc

Issue 73523002: Fix windowed NPAPI plugins appearing under dialogs when DWM compositing is disabled and the tab swi… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix Created 7 years, 1 month 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 | content/browser/web_contents/web_contents_view_aura.cc » ('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 "chrome/browser/ui/views/location_bar/star_view.h" 5 #include "chrome/browser/ui/views/location_bar/star_view.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // enumerating after the first callback. 83 // enumerating after the first callback.
84 return FALSE; 84 return FALSE;
85 } 85 }
86 86
87 // Ensure that UIs like the star window, user profiler picker, omnibox 87 // Ensure that UIs like the star window, user profiler picker, omnibox
88 // popup and bookmark editor are always over a windowed NPAPI plugin even if 88 // popup and bookmark editor are always over a windowed NPAPI plugin even if
89 // kDisableDwmComposition is used. 89 // kDisableDwmComposition is used.
90 IN_PROC_BROWSER_TEST_F(StarViewTestNoDWM, WindowedNPAPIPluginHidden) { 90 IN_PROC_BROWSER_TEST_F(StarViewTestNoDWM, WindowedNPAPIPluginHidden) {
91 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize, 91 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize,
92 true); 92 true);
93 LOG(ERROR) << "1"; 93
94 // First switch to a new tab and back, to also test a scenario where we
95 // stopped watching the root window.
96 ui_test_utils::NavigateToURLWithDisposition(
97 browser(), GURL("about:blank"), NEW_FOREGROUND_TAB,
98 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
99 browser()->tab_strip_model()->ActivateTabAt(0, true);
100
94 // First load the page and wait for the NPAPI plugin's window to display. 101 // First load the page and wait for the NPAPI plugin's window to display.
95 string16 expected_title(ASCIIToUTF16("ready")); 102 string16 expected_title(ASCIIToUTF16("ready"));
96 content::WebContents* tab = 103 content::WebContents* tab =
97 browser()->tab_strip_model()->GetActiveWebContents(); 104 browser()->tab_strip_model()->GetActiveWebContents();
98 content::TitleWatcher title_watcher(tab, expected_title); 105 content::TitleWatcher title_watcher(tab, expected_title);
99 106
100 GURL url = ui_test_utils::GetTestUrl( 107 GURL url = ui_test_utils::GetTestUrl(
101 base::FilePath().AppendASCII("printing"), 108 base::FilePath().AppendASCII("printing"),
102 base::FilePath().AppendASCII("npapi_plugin.html")); 109 base::FilePath().AppendASCII("npapi_plugin.html"));
103 ui_test_utils::NavigateToURL(browser(), url); 110 ui_test_utils::NavigateToURL(browser(), url);
104 LOG(ERROR) << "2";
105 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 111 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
106 LOG(ERROR) << "3";
107 112
108 // Now get the region of the plugin before the star view is shown. 113 // Now get the region of the plugin before the star view is shown.
109 HWND hwnd = tab->GetView()->GetNativeView()->GetDispatcher()->host()-> 114 HWND hwnd = tab->GetView()->GetNativeView()->GetDispatcher()->host()->
110 GetAcceleratedWidget(); 115 GetAcceleratedWidget();
111 HWND child = NULL; 116 HWND child = NULL;
112 EnumChildWindows(hwnd, EnumerateChildren,reinterpret_cast<LPARAM>(&child)); 117 EnumChildWindows(hwnd, EnumerateChildren,reinterpret_cast<LPARAM>(&child));
113 LOG(ERROR) << "4";
114 118
115 RECT region_before, region_after; 119 RECT region_before, region_after;
116 int result = GetWindowRgnBox(child, &region_before); 120 int result = GetWindowRgnBox(child, &region_before);
117 ASSERT_EQ(result, SIMPLEREGION); 121 ASSERT_EQ(result, SIMPLEREGION);
118 122
119 // Now show the star view 123 // Now show the star view
120 BrowserView* browser_view = reinterpret_cast<BrowserView*>( 124 BrowserView* browser_view = reinterpret_cast<BrowserView*>(
121 browser()->window()); 125 browser()->window());
122 views::ImageView* star_view = 126 views::ImageView* star_view =
123 browser_view->GetToolbarView()->location_bar()->star_view(); 127 browser_view->GetToolbarView()->location_bar()->star_view();
124 128
125 scoped_refptr<content::MessageLoopRunner> runner = 129 scoped_refptr<content::MessageLoopRunner> runner =
126 new content::MessageLoopRunner; 130 new content::MessageLoopRunner;
127 LOG(ERROR) << "5";
128 // Verify that clicking once shows the bookmark bubble. 131 // Verify that clicking once shows the bookmark bubble.
129 ui_test_utils::MoveMouseToCenterAndPress( 132 ui_test_utils::MoveMouseToCenterAndPress(
130 star_view, 133 star_view,
131 ui_controls::LEFT, 134 ui_controls::LEFT,
132 ui_controls::DOWN | ui_controls::UP, 135 ui_controls::DOWN | ui_controls::UP,
133 runner->QuitClosure()); 136 runner->QuitClosure());
134 LOG(ERROR) << "6";
135 runner->Run(); 137 runner->Run();
136 LOG(ERROR) << "7";
137 138
138 EXPECT_TRUE(BookmarkBubbleView::IsShowing()); 139 EXPECT_TRUE(BookmarkBubbleView::IsShowing());
139 140
140 result = GetWindowRgnBox(child, &region_after); 141 result = GetWindowRgnBox(child, &region_after);
141 if (result == NULLREGION) { 142 if (result == NULLREGION) {
142 // Depending on the browser window size, the plugin could be full covered. 143 // Depending on the browser window size, the plugin could be full covered.
143 return; 144 return;
144 } 145 }
145 146
146 if (result == COMPLEXREGION) { 147 if (result == COMPLEXREGION) {
147 // Complex region, by definition not equal to the initial region. 148 // Complex region, by definition not equal to the initial region.
148 return; 149 return;
149 } 150 }
150 151
151 ASSERT_EQ(result, SIMPLEREGION); 152 ASSERT_EQ(result, SIMPLEREGION);
152 bool rects_equal = 153 bool rects_equal =
153 region_before.left == region_after.left && 154 region_before.left == region_after.left &&
154 region_before.top == region_after.top && 155 region_before.top == region_after.top &&
155 region_before.right == region_after.right && 156 region_before.right == region_after.right &&
156 region_before.bottom == region_after.bottom; 157 region_before.bottom == region_after.bottom;
157 ASSERT_FALSE(rects_equal); 158 ASSERT_FALSE(rects_equal);
158 } 159 }
159 160
160 #endif 161 #endif
161 162
162 } // namespace 163 } // namespace
OLDNEW
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_view_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698