Fix flaky EmailAliasesBrowserTest.ContextMenuAuthorized (#36161)
The test intermittently failed with "deepQuery is not defined" because InjectHelpers() could execute on the bubble's WebContents before its WebUI page (chrome://email-aliases.panel/) had finished loading. When the WebUI document committed after injection, the JavaScript context was replaced and deepQuery was lost. Add WaitForLoadStop() in InjectHelpers() to ensure the target WebContents has finished loading before injecting helper functions. This matches the pattern used by brave_wallet_tab_helper_browsertest. Resolves brave/brave-browser#54889
This commit is contained in:
@@ -178,6 +178,7 @@ class EmailAliasesBrowserTestBase : public InProcessBrowserTest {
|
||||
}
|
||||
|
||||
void InjectHelpers(content::WebContents* contents) {
|
||||
ASSERT_TRUE(content::WaitForLoadStop(contents));
|
||||
constexpr char kDeepQuery[] = R"js(
|
||||
function deepQuery(selector) {
|
||||
const query = (root, selector) =>{
|
||||
|
||||
Reference in New Issue
Block a user