| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include <utility> | 5 #include <utility> | 
| 6 #include <vector> | 6 #include <vector> | 
| 7 | 7 | 
| 8 #include "base/bind.h" | 8 #include "base/bind.h" | 
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" | 
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" | 
| 11 #include "base/macros.h" | 11 #include "base/macros.h" | 
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" | 
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" | 
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" | 
| 15 #include "base/test/scoped_feature_list.h" |  | 
| 16 #include "build/build_config.h" | 15 #include "build/build_config.h" | 
| 17 #include "chrome/app/chrome_command_ids.h" | 16 #include "chrome/app/chrome_command_ids.h" | 
| 18 #include "chrome/browser/history/history_service_factory.h" | 17 #include "chrome/browser/history/history_service_factory.h" | 
| 19 #include "chrome/browser/history/history_test_utils.h" | 18 #include "chrome/browser/history/history_test_utils.h" | 
| 20 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" | 
| 21 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" | 
| 22 #include "chrome/browser/ui/browser_commands.h" | 21 #include "chrome/browser/ui/browser_commands.h" | 
| 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 
| 24 #include "chrome/common/chrome_features.h" |  | 
| 25 #include "chrome/common/chrome_switches.h" |  | 
| 26 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" | 
| 27 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" | 
| 28 #include "chrome/test/base/in_process_browser_test.h" | 25 #include "chrome/test/base/in_process_browser_test.h" | 
| 29 #include "chrome/test/base/ui_test_utils.h" | 26 #include "chrome/test/base/ui_test_utils.h" | 
| 30 #include "components/history/core/browser/history_db_task.h" | 27 #include "components/history/core/browser/history_db_task.h" | 
| 31 #include "components/history/core/browser/history_service.h" | 28 #include "components/history/core/browser/history_service.h" | 
| 32 #include "components/prefs/pref_service.h" | 29 #include "components/prefs/pref_service.h" | 
| 33 #include "content/public/browser/navigation_handle.h" | 30 #include "content/public/browser/navigation_handle.h" | 
| 34 #include "content/public/browser/render_frame_host.h" | 31 #include "content/public/browser/render_frame_host.h" | 
| 35 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" | 
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 277   // Test the history length for the following page transition. | 274   // Test the history length for the following page transition. | 
| 278   // | 275   // | 
| 279   // -open-> Page 21 -redirect-> Page 22. | 276   // -open-> Page 21 -redirect-> Page 22. | 
| 280   // | 277   // | 
| 281   // If redirect occurs more than 5 seconds later after the page is loaded, | 278   // If redirect occurs more than 5 seconds later after the page is loaded, | 
| 282   // the redirect is likely to be user-initiated. | 279   // the redirect is likely to be user-initiated. | 
| 283   // Therefore, Page 21 should be in the history in addition to Page 22. | 280   // Therefore, Page 21 should be in the history in addition to Page 22. | 
| 284   LoadAndWaitForFile("history_length_test_page_21.html"); | 281   LoadAndWaitForFile("history_length_test_page_21.html"); | 
| 285 } | 282 } | 
| 286 | 283 | 
| 287 // http://crbug.com/22111 (linux), http://crbug.com/530246 (win) | 284 // TODO(crbug.com/22111): Disabled because of flakiness and because for a while | 
| 288 #if defined(OS_LINUX) || defined(OS_WIN) | 285 // MD history didn't support #q=searchTerm. Now that it does support these type | 
| 289 #define MAYBE_HistorySearchXSS DISABLED_HistorySearchXSS | 286 // of URLs (crbug.com/619799), this test could be re-enabled if somebody goes | 
| 290 #else | 287 // through the effort to wait for the various stages of the page loading. | 
| 291 #define MAYBE_HistorySearchXSS HistorySearchXSS | 288 // The loading strategy of the new, Polymer version of chrome://history is | 
| 292 #endif | 289 // sophisticated and multi-part, so we'd need to wait on or ensure a few things | 
| 293 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, MAYBE_HistorySearchXSS) { | 290 // are happening before running the test. | 
| 294   // TODO(tsergeant): Enable this test on MD History once it is possible to pass | 291 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, DISABLED_HistorySearchXSS) { | 
| 295   // in a query via URL (crbug.com/619799). |  | 
| 296   base::test::ScopedFeatureList scoped_feature_list; |  | 
| 297   scoped_feature_list.InitAndDisableFeature(features::kMaterialDesignHistory); |  | 
| 298 |  | 
| 299   GURL url(std::string(chrome::kChromeUIHistoryURL) + | 292   GURL url(std::string(chrome::kChromeUIHistoryURL) + | 
| 300       "#q=%3Cimg%20src%3Dx%3Ax%20onerror%3D%22document.title%3D'XSS'%22%3E"); | 293       "#q=%3Cimg%20src%3Dx%3Ax%20onerror%3D%22document.title%3D'XSS'%22%3E"); | 
| 301   ui_test_utils::NavigateToURL(browser(), url); | 294   ui_test_utils::NavigateToURL(browser(), url); | 
| 302   // Mainly, this is to ensure we send a synchronous message to the renderer | 295   // Mainly, this is to ensure we send a synchronous message to the renderer | 
| 303   // so that we're not susceptible (less susceptible?) to a race condition. | 296   // so that we're not susceptible (less susceptible?) to a race condition. | 
| 304   // Should a race condition ever trigger, it won't result in flakiness. | 297   // Should a race condition ever trigger, it won't result in flakiness. | 
| 305   int num = ui_test_utils::FindInPage( | 298   int num = ui_test_utils::FindInPage( | 
| 306       browser()->tab_strip_model()->GetActiveWebContents(), | 299       browser()->tab_strip_model()->GetActiveWebContents(), | 
| 307       base::ASCIIToUTF16("<img"), true, | 300       base::ASCIIToUTF16("<img"), true, | 
| 308       true, NULL, NULL); | 301       true, NULL, NULL); | 
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 615 | 608 | 
| 616   content::WebContents* active_web_contents = | 609   content::WebContents* active_web_contents = | 
| 617       browser()->tab_strip_model()->GetActiveWebContents(); | 610       browser()->tab_strip_model()->GetActiveWebContents(); | 
| 618   ASSERT_EQ(web_contents, active_web_contents); | 611   ASSERT_EQ(web_contents, active_web_contents); | 
| 619   ASSERT_EQ(history_url, active_web_contents->GetURL()); | 612   ASSERT_EQ(history_url, active_web_contents->GetURL()); | 
| 620 | 613 | 
| 621   content::WebContents* second_tab = | 614   content::WebContents* second_tab = | 
| 622       browser()->tab_strip_model()->GetWebContentsAt(1); | 615       browser()->tab_strip_model()->GetWebContentsAt(1); | 
| 623   ASSERT_NE(history_url, second_tab->GetURL()); | 616   ASSERT_NE(history_url, second_tab->GetURL()); | 
| 624 } | 617 } | 
| OLD | NEW | 
|---|