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) {
EXPECT_TRUE(result.get()->GetList(keys::kTabsKey, &tabs));
}
// Flaky: http://crbug.com/136562
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) {
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryLastFocusedWindowTabs) {
const size_t kExtraWindows = 2;
for (size_t i = 0; i < kExtraWindows; ++i)
CreateBrowser(browser()->profile());
......@@ -82,11 +81,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) {
ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(
focused_window->window()->GetNativeWindow()));
#endif
ui_test_utils::BrowserActivationWaiter waiter(focused_window);
waiter.WaitForActivation();
// Needed on Mac and Linux so that the BrowserWindow::IsActive calls work.
content::RunAllPendingInMessageLoop();
GURL url;
GURL url("about:blank");
AddTabAtIndexToBrowser(focused_window, 0, url, ui::PAGE_TRANSITION_LINK,
true);
int focused_window_id =
......@@ -95,6 +93,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DISABLED_QueryLastFocusedWindowTabs) {
// Get tabs in the 'last focused' window called from non-focused browser.
scoped_refptr<extensions::TabsQueryFunction> function =
new extensions::TabsQueryFunction();
scoped_refptr<extensions::Extension> extension(
extensions::test_util::CreateEmptyExtension());
function->set_extension(extension.get());
std::unique_ptr<base::ListValue> result(
utils::ToList(utils::RunFunctionAndReturnSingleResult(
function.get(), "[{\"lastFocusedWindow\":true}]", browser())));
......@@ -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.
function = new extensions::TabsQueryFunction();
function->set_extension(extension.get());
result.reset(utils::ToList(
utils::RunFunctionAndReturnSingleResult(function.get(),
"[{\"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