Commit 7adee5e6 authored by warx's avatar warx Committed by Commit bot

Enable ExtensionTabsTest.QueryLastFocusedWindowTabs test

Changes include:
(1) Suspect content::RunAllPendingInMessageLoop is the reason for flaky, since BrowserWindow::IsActive is asynchronous on Mac and Linux.

(2) Construct a non-empty url as there is a DCHECK here: https://cs.chromium.org/chromium/src/chrome/browser/ui/browser_navigator.cc?type=cs&sq=package:chromium&rcl=1476314269&l=530

(3) function->set_extension as there is a DCHECK here:
https://cs.chromium.org/chromium/src/chrome/browser/extensions/browser_extension_window_controller.cc?type=cs&q=browser_extension_window_controller.cc&sq=package:chromium&l=87

BUG=136562
TEST=change is on test itself
If flaky is still observed, please disable the test again.

Review-Url: https://codereview.chromium.org/2419763002
Cr-Commit-Position: refs/heads/master@{#427214}
parent 85d28b11
...@@ -69,8 +69,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, MAYBE_GetLastFocusedWindow) { ...@@ -69,8 +69,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, MAYBE_GetLastFocusedWindow) {
EXPECT_TRUE(result.get()->GetList(keys::kTabsKey, &tabs)); EXPECT_TRUE(result.get()->GetList(keys::kTabsKey, &tabs));
} }
// Flaky: http://crbug.com/136562 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryLastFocusedWindowTabs) {
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) {
const size_t kExtraWindows = 2; const size_t kExtraWindows = 2;
for (size_t i = 0; i < kExtraWindows; ++i) for (size_t i = 0; i < kExtraWindows; ++i)
CreateBrowser(browser()->profile()); CreateBrowser(browser()->profile());
...@@ -82,11 +81,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) { ...@@ -82,11 +81,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) {
ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
focused_window->window()->GetNativeWindow())); focused_window->window()->GetNativeWindow()));
#endif #endif
ui_test_utils::BrowserActivationWaiter waiter(focused_window);
waiter.WaitForActivation();
// Needed on Mac and Linux so that the BrowserWindow::IsActive calls work. GURL url("about:blank");
content::RunAllPendingInMessageLoop();
GURL url;
AddTabAtIndexToBrowser(focused_window, 0, url, ui::PAGE_TRANSITION_LINK, AddTabAtIndexToBrowser(focused_window, 0, url, ui::PAGE_TRANSITION_LINK,
true); true);
int focused_window_id = int focused_window_id =
...@@ -95,6 +93,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) { ...@@ -95,6 +93,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) {
// Get tabs in the 'last focused' window called from non-focused browser. // Get tabs in the 'last focused' window called from non-focused browser.
scoped_refptr<extensions::TabsQueryFunction> function = scoped_refptr<extensions::TabsQueryFunction> function =
new extensions::TabsQueryFunction(); new extensions::TabsQueryFunction();
scoped_refptr<extensions::Extension> extension(
extensions::test_util::CreateEmptyExtension());
function->set_extension(extension.get());
std::unique_ptr<base::ListValue> result( std::unique_ptr<base::ListValue> result(
utils::ToList(utils::RunFunctionAndReturnSingleResult( utils::ToList(utils::RunFunctionAndReturnSingleResult(
function.get(), "[{\"lastFocusedWindow\":true}]", browser()))); function.get(), "[{\"lastFocusedWindow\":true}]", browser())));
...@@ -111,6 +112,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) { ...@@ -111,6 +112,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) {
// Get tabs NOT in the 'last focused' window called from the focused browser. // Get tabs NOT in the 'last focused' window called from the focused browser.
function = new extensions::TabsQueryFunction(); function = new extensions::TabsQueryFunction();
function->set_extension(extension.get());
result.reset(utils::ToList( result.reset(utils::ToList(
utils::RunFunctionAndReturnSingleResult(function.get(), utils::RunFunctionAndReturnSingleResult(function.get(),
"[{\"lastFocusedWindow\":false}]", "[{\"lastFocusedWindow\":false}]",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment