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

Unified Diff: chrome/browser/pdf/pdf_extension_test.cc

Issue 2568903002: PDF viewer: Specify tabId when navigating with chrome.tabs.update. (Closed)
Patch Set: Add test. Created 4 years 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
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/navigator.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/pdf/pdf_extension_test.cc
diff --git a/chrome/browser/pdf/pdf_extension_test.cc b/chrome/browser/pdf/pdf_extension_test.cc
index 8220c234d88aaa73165586d9e4c8542b93f44e91..543bf911baab125b03ce175671c9ce2a53e44d40 100644
--- a/chrome/browser/pdf/pdf_extension_test.cc
+++ b/chrome/browser/pdf/pdf_extension_test.cc
@@ -905,3 +905,36 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkShiftLeftClick) {
IN_PROC_BROWSER_TEST_F(PDFExtensionTest, RedirectsFailInPlugin) {
RunTestsInFile("redirects_fail_test.js", "test.pdf");
}
+
+IN_PROC_BROWSER_TEST_F(PDFExtensionTest, NavigationOnCorrectTab) {
raymes 2016/12/14 01:43:28 nit: You may want to link to the bug above here an
Kevin McNee 2016/12/14 16:03:33 Done.
+ GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test.pdf"));
+ content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url);
+ ASSERT_TRUE(guest_contents);
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), GURL("about:blank"),
+ WindowOpenDisposition::NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+ content::WebContents* active_web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
raymes 2016/12/14 01:43:28 nit: may want to assert that active_web_contents i
Kevin McNee 2016/12/14 16:03:33 Done.
+
+ ASSERT_TRUE(content::ExecuteScript(
+ guest_contents,
+ "var navMessage = new MessageEvent("
+ " 'message',"
+ " {"
+ " data: {"
+ " type: 'navigate',"
+ " url: 'www.example.com',"
+ " disposition: Navigator.WindowOpenDisposition.CURRENT_TAB"
+ " }"
+ " });"
+ "var plugin = document.getElementsByTagName('embed')[0];"
+ "plugin.dispatchEvent(navMessage);"));
raymes 2016/12/14 01:43:28 nit: I was thinking we could just fire the navigat
Kevin McNee 2016/12/14 16:03:33 Done.
+
+ EXPECT_TRUE(web_contents->GetController().GetPendingEntry());
+ EXPECT_FALSE(active_web_contents->GetController().GetPendingEntry());
+}
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/navigator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698