Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1634)

Unified Diff: chrome/browser/dom_distiller/tab_utils_browsertest.cc

Issue 1058193002: Add support for not owning distilled WebContents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix issues. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/dom_distiller/tab_utils_browsertest.cc
diff --git a/chrome/browser/dom_distiller/tab_utils_browsertest.cc b/chrome/browser/dom_distiller/tab_utils_browsertest.cc
index 1b48e427b4d3ff1b3fa564efce6d7eec7cc07830..124aaaff0347520a4521ac3c6f5920a31c686340 100644
--- a/chrome/browser/dom_distiller/tab_utils_browsertest.cc
+++ b/chrome/browser/dom_distiller/tab_utils_browsertest.cc
@@ -21,6 +21,7 @@
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
+#include "content/public/test/browser_test_utils.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -93,4 +94,53 @@ IN_PROC_BROWSER_TEST_F(DomDistillerTabUtilsBrowserTest,
base::UTF16ToUTF8(after_web_contents->GetTitle()));
}
+IN_PROC_BROWSER_TEST_F(DomDistillerTabUtilsBrowserTest,
+ TestDistillIntoWebContents) {
+ ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
+
+ content::WebContents* source_web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ const GURL& article_url = embedded_test_server()->GetURL(kSimpleArticlePath);
+
+ // This blocks until the navigation has completely finished.
+ ui_test_utils::NavigateToURL(browser(), article_url);
+
+ // Create destination WebContents.
+ content::WebContents::CreateParams create_params(
+ source_web_contents->GetBrowserContext());
+ content::WebContents* destination_web_contents =
+ content::WebContents::Create(create_params);
+ DCHECK(destination_web_contents);
+
+ browser()->tab_strip_model()->AppendWebContents(destination_web_contents,
+ true);
+ ASSERT_EQ(destination_web_contents,
+ browser()->tab_strip_model()->GetWebContentsAt(1));
+
+ DistillAndView(source_web_contents, destination_web_contents);
+
+ // Wait until the destination WebContents has fully navigated.
+ base::RunLoop new_url_loaded_runner;
+ scoped_ptr<WebContentsMainFrameHelper> distilled_page_loaded(
+ new WebContentsMainFrameHelper(destination_web_contents,
+ new_url_loaded_runner.QuitClosure()));
+ new_url_loaded_runner.Run();
+
+ // Verify that the source WebContents is showing the original article.
+ EXPECT_EQ(article_url, source_web_contents->GetLastCommittedURL());
+ EXPECT_EQ("Test Page Title",
+ base::UTF16ToUTF8(source_web_contents->GetTitle()));
+
+ // Verify the destination WebContents is showing distilled content.
+ EXPECT_TRUE(destination_web_contents->GetLastCommittedURL().SchemeIs(
+ kDomDistillerScheme));
+ EXPECT_EQ("Test Page Title",
+ base::UTF16ToUTF8(destination_web_contents->GetTitle()));
+
+ content::WebContentsDestroyedWatcher destroyed_watcher(
+ destination_web_contents);
+ browser()->tab_strip_model()->CloseWebContentsAt(1, 0);
+ destroyed_watcher.Wait();
+}
+
} // namespace dom_distiller
« no previous file with comments | « chrome/browser/dom_distiller/tab_utils_android.cc ('k') | components/dom_distiller/content/distiller_page_web_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698