Commit 9ef5541c authored by John Lee's avatar John Lee Committed by Chromium LUCI CQ

WebUI Tab Strip: Fix possible cause of flaky tests

There may be a race condition for when the JavaScript to query a child
in the shadow DOM of a tabstrip-tab-group element runs immediately after
the test adds a tab to a group. This CL waits for the tabstrip-tab-group
element to appear on the page before running this query.

Bug: 1132300
Change-Id: I228f694ffeffa5c9bf303f4952fbbabef8f2334e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2594507
Commit-Queue: John Lee <johntlee@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837839}
parent 78b21354
......@@ -110,15 +110,29 @@ IN_PROC_BROWSER_TEST_F(TabStripUIBrowserTest, ActivatingTabClosesEmbedder) {
ISOLATED_WORLD_ID_CHROME_INTERNAL));
}
// Flaky.
// TODO(https://crbug.com/1132300): Re-enable.
IN_PROC_BROWSER_TEST_F(TabStripUIBrowserTest,
DISABLED_InvokesEditDialogForGroups) {
IN_PROC_BROWSER_TEST_F(TabStripUIBrowserTest, InvokesEditDialogForGroups) {
using ::testing::_;
tab_groups::TabGroupId group_id =
browser()->tab_strip_model()->AddToNewGroup({0});
// Wait for the front-end to receive the new group and create the tab-group
// element.
const std::string get_group_promise_js =
"new Promise((resolve) => {"
" const interval = setInterval(() => {"
" if (document.querySelector('tabstrip-tab-list').shadowRoot"
" .querySelector('tabstrip-tab-group')) {"
" resolve(true);"
" clearInterval(interval);"
" }"
" }, 100);"
"});";
ASSERT_TRUE(content::EvalJs(webui_contents_.get(), get_group_promise_js,
content::EXECUTE_SCRIPT_DEFAULT_OPTIONS,
ISOLATED_WORLD_ID_CHROME_INTERNAL)
.ExtractBool());
const std::string get_chip_js =
"const chip = document.querySelector('tabstrip-tab-list')"
" .shadowRoot.querySelector('tabstrip-tab-group')"
......
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