Commit 7949a0e5 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Local NTP tests cleanup: Rewrite LoadsIframe to use the real local NTP

Before, it used local_ntp_browsertest.html instead, for no good reason.

Bug: 788166
Change-Id: Iba4fe5c06eab1bc9fafebe6f528955c208c24359
Reviewed-on: https://chromium-review.googlesource.com/787897Reviewed-by: default avatarChris Pickel <sfiera@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519737}
parent bb1d8a86
...@@ -542,26 +542,10 @@ content::RenderFrameHost* GetMostVisitedIframe(content::WebContents* tab) { ...@@ -542,26 +542,10 @@ content::RenderFrameHost* GetMostVisitedIframe(content::WebContents* tab) {
} // namespace } // namespace
IN_PROC_BROWSER_TEST_F(LocalNTPJavascriptTest, LoadsIframe) { IN_PROC_BROWSER_TEST_F(LocalNTPTest, LoadsIframe) {
content::WebContents* active_tab = local_ntp_test_utils::OpenNewTab( content::WebContents* active_tab =
browser(), GURL(chrome::kChromeUINewTabURL)); local_ntp_test_utils::OpenNewTab(browser(), GURL("about:blank"));
ASSERT_TRUE(search::IsInstantNTP(active_tab)); NavigateToNTPAndWaitUntilLoaded();
content::DOMMessageQueue msg_queue;
bool result = false;
ASSERT_TRUE(instant_test_utils::GetBoolFromJS(
active_tab, "!!setupAdvancedTest(true)", &result));
ASSERT_TRUE(result);
// Wait for the MV iframe to load.
std::string message;
// First get rid of the "true" message from the GetBoolFromJS call above.
ASSERT_TRUE(msg_queue.PopMessage(&message));
ASSERT_EQ("true", message);
// Now wait for the "loaded" message.
ASSERT_TRUE(msg_queue.WaitForMessage(&message));
ASSERT_EQ("\"loaded\"", message);
// Get the iframe and check that the tiles loaded correctly. // Get the iframe and check that the tiles loaded correctly.
content::RenderFrameHost* iframe = GetMostVisitedIframe(active_tab); content::RenderFrameHost* iframe = GetMostVisitedIframe(active_tab);
......
...@@ -93,18 +93,8 @@ function initLocalNTP(isGooglePage) { ...@@ -93,18 +93,8 @@ function initLocalNTP(isGooglePage) {
// Advanced tests are controlled from the native side. The helpers here are // Advanced tests are controlled from the native side. The helpers here are
// called from native code to set up the page and to check results. // called from native code to set up the page and to check results.
function handlePostMessage(event) {
if (event.data.cmd == 'loaded') {
domAutomationController.send('loaded');
}
}
function setupAdvancedTest(opt_waitForIframeLoaded) {
if (opt_waitForIframeLoaded) {
window.addEventListener('message', handlePostMessage);
}
function setupAdvancedTest() {
setUpPage('local-ntp-template'); setUpPage('local-ntp-template');
initLocalNTP(/*isGooglePage=*/true); initLocalNTP(/*isGooglePage=*/true);
......
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