Commit a67e3ac3 authored by Adithya Srinivasan's avatar Adithya Srinivasan Committed by Commit Bot

Portals: Use EvalJs to wait for promises

It seems that unlike EvalJs, ExecJs doesn't wait for promises to resolve
before returning. This fixes existing portal browsertests to use EvalJs
when waiting for a promise.

Change-Id: Ib1cdb50e79b19fd8296f6b29fd8fbf9931c92ccd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1976193Reviewed-by: default avatarLucas Gadani <lfg@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Adithya Srinivasan <adithyas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726509}
parent 0dab3ab2
...@@ -44,13 +44,13 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest, MAYBE_PortalActivation) { ...@@ -44,13 +44,13 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest, MAYBE_PortalActivation) {
WebContents* contents = tab_strip_model->GetActiveWebContents(); WebContents* contents = tab_strip_model->GetActiveWebContents();
EXPECT_EQ(1, tab_strip_model->count()); EXPECT_EQ(1, tab_strip_model->count());
EXPECT_TRUE(content::ExecJs(contents, "loadPromise")); EXPECT_EQ(true, content::EvalJs(contents, "loadPromise"));
std::vector<WebContents*> inner_web_contents = std::vector<WebContents*> inner_web_contents =
contents->GetInnerWebContents(); contents->GetInnerWebContents();
EXPECT_EQ(1u, inner_web_contents.size()); EXPECT_EQ(1u, inner_web_contents.size());
WebContents* portal_contents = inner_web_contents[0]; WebContents* portal_contents = inner_web_contents[0];
EXPECT_TRUE(content::ExecJs(contents, "activate()")); EXPECT_EQ(true, content::EvalJs(contents, "activate()"));
EXPECT_EQ(1, tab_strip_model->count()); EXPECT_EQ(1, tab_strip_model->count());
EXPECT_EQ(portal_contents, tab_strip_model->GetActiveWebContents()); EXPECT_EQ(portal_contents, tab_strip_model->GetActiveWebContents());
} }
...@@ -70,7 +70,7 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest, ...@@ -70,7 +70,7 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest,
ui_test_utils::NavigateToURL(browser(), url); ui_test_utils::NavigateToURL(browser(), url);
WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
EXPECT_TRUE(content::ExecJs(contents, "loadPromise")); EXPECT_EQ(true, content::EvalJs(contents, "loadPromise"));
DevToolsWindow* dev_tools_window = DevToolsWindow* dev_tools_window =
DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), true); DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), true);
WebContents* main_web_contents = WebContents* main_web_contents =
...@@ -78,7 +78,7 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest, ...@@ -78,7 +78,7 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest,
EXPECT_EQ(main_web_contents, EXPECT_EQ(main_web_contents,
DevToolsWindow::GetInTabWebContents(contents, nullptr)); DevToolsWindow::GetInTabWebContents(contents, nullptr));
EXPECT_TRUE(content::ExecJs(contents, "activate()")); EXPECT_EQ(true, content::EvalJs(contents, "activate()"));
EXPECT_EQ(main_web_contents, EXPECT_EQ(main_web_contents,
DevToolsWindow::GetInTabWebContents( DevToolsWindow::GetInTabWebContents(
browser()->tab_strip_model()->GetActiveWebContents(), nullptr)); browser()->tab_strip_model()->GetActiveWebContents(), nullptr));
......
...@@ -3,11 +3,12 @@ ...@@ -3,11 +3,12 @@
<portal src="activate-portal.html"></portal> <portal src="activate-portal.html"></portal>
<script> <script>
var loadPromise = new Promise(r => { var loadPromise = new Promise(r => {
window.onload = r; window.onload = () => r(true);
}); });
function activate() { function activate() {
return document.querySelector("portal").activate(); return document.querySelector("portal").activate().then(
() => true, () => false);
} }
</script> </script>
</body> </body>
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