OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "base/metrics/histogram_base.h" | 9 #include "base/metrics/histogram_base.h" |
10 #include "base/metrics/histogram_samples.h" | 10 #include "base/metrics/histogram_samples.h" |
(...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 EXPECT_TRUE(ExecuteScript(stream.str())); | 1358 EXPECT_TRUE(ExecuteScript(stream.str())); |
1359 observer.Wait(); | 1359 observer.Wait(); |
1360 | 1360 |
1361 // Update Most Visited state. | 1361 // Update Most Visited state. |
1362 EXPECT_TRUE(UpdateSearchState(overlay)); | 1362 EXPECT_TRUE(UpdateSearchState(overlay)); |
1363 | 1363 |
1364 // Make sure we have the same number of items as before. | 1364 // Make sure we have the same number of items as before. |
1365 EXPECT_EQ(most_visited_items_count_, old_most_visited_items_count); | 1365 EXPECT_EQ(most_visited_items_count_, old_most_visited_items_count); |
1366 } | 1366 } |
1367 | 1367 |
1368 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, ThemeBackgroundAccess) { | |
1369 InstallThemeSource(); | |
1370 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); | |
1371 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | |
1372 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); | |
1373 | 1368 |
1374 // The "Instant" New Tab should have access to chrome-search: scheme but not | |
1375 // chrome: scheme. | |
1376 ui_test_utils::NavigateToURLWithDisposition( | |
1377 browser(), | |
1378 GURL(chrome::kChromeUINewTabURL), | |
1379 NEW_FOREGROUND_TAB, | |
1380 ui_test_utils::BROWSER_TEST_NONE); | |
1381 | |
1382 content::RenderViewHost* rvh = | |
1383 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); | |
1384 | |
1385 const std::string chrome_url("chrome://theme/IDR_THEME_NTP_BACKGROUND"); | |
1386 const std::string search_url( | |
1387 "chrome-search://theme/IDR_THEME_NTP_BACKGROUND"); | |
1388 bool loaded = false; | |
1389 ASSERT_TRUE(LoadImage(rvh, chrome_url, &loaded)); | |
1390 EXPECT_FALSE(loaded) << chrome_url; | |
1391 ASSERT_TRUE(LoadImage(rvh, search_url, &loaded)); | |
1392 EXPECT_TRUE(loaded) << search_url; | |
1393 } | |
1394 | 1369 |
1395 // TODO(dhollowa): Fix flakes. http://crbug.com/179930. | 1370 // TODO(dhollowa): Fix flakes. http://crbug.com/179930. |
1396 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_FaviconAccess) { | 1371 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_FaviconAccess) { |
1397 // Create a favicon. | 1372 // Create a favicon. |
1398 history::TopSites* top_sites = browser()->profile()->GetTopSites(); | 1373 history::TopSites* top_sites = browser()->profile()->GetTopSites(); |
1399 GURL url("http://www.google.com/foo.html"); | 1374 GURL url("http://www.google.com/foo.html"); |
1400 gfx::Image thumbnail(CreateBitmap(SK_ColorWHITE)); | 1375 gfx::Image thumbnail(CreateBitmap(SK_ColorWHITE)); |
1401 ThumbnailScore high_score(0.0, true, true, base::Time::Now()); | 1376 ThumbnailScore high_score(0.0, true, true, base::Time::Now()); |
1402 EXPECT_TRUE(top_sites->SetPageThumbnail(url, thumbnail, high_score)); | 1377 EXPECT_TRUE(top_sites->SetPageThumbnail(url, thumbnail, high_score)); |
1403 | 1378 |
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2890 browser()->tab_strip_model()->ActivateTabAt(0, false); | 2865 browser()->tab_strip_model()->ActivateTabAt(0, false); |
2891 | 2866 |
2892 // Switch back to new tab. | 2867 // Switch back to new tab. |
2893 browser()->tab_strip_model()->ActivateTabAt(1, false); | 2868 browser()->tab_strip_model()->ActivateTabAt(1, false); |
2894 | 2869 |
2895 // Confirm that new tab got no onmostvisitedchanged event. | 2870 // Confirm that new tab got no onmostvisitedchanged event. |
2896 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); | 2871 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
2897 EXPECT_TRUE(UpdateSearchState(active_tab)); | 2872 EXPECT_TRUE(UpdateSearchState(active_tab)); |
2898 EXPECT_EQ(2, on_most_visited_change_calls_); | 2873 EXPECT_EQ(2, on_most_visited_change_calls_); |
2899 } | 2874 } |
| 2875 |
| 2876 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, ThemeBackgroundAccess) { |
| 2877 InstallThemeSource(); |
| 2878 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); |
| 2879 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 2880 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 2881 |
| 2882 // The "Instant" New Tab should have access to chrome-search: scheme but not |
| 2883 ui_test_utils::NavigateToURLWithDisposition( |
| 2884 browser(), |
| 2885 GURL(chrome::kChromeUINewTabURL), |
| 2886 NEW_FOREGROUND_TAB, |
| 2887 ui_test_utils::BROWSER_TEST_NONE); |
| 2888 |
| 2889 content::RenderViewHost* rvh = |
| 2890 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); |
| 2891 |
| 2892 const std::string chrome_url("chrome://theme/IDR_THEME_NTP_BACKGROUND"); |
| 2893 const std::string search_url( |
| 2894 "chrome-search://theme/IDR_THEME_NTP_BACKGROUND"); |
| 2895 bool loaded = false; |
| 2896 ASSERT_TRUE(LoadImage(rvh, chrome_url, &loaded)); |
| 2897 EXPECT_FALSE(loaded) << chrome_url; |
| 2898 ASSERT_TRUE(LoadImage(rvh, search_url, &loaded)); |
| 2899 EXPECT_TRUE(loaded) << search_url; |
| 2900 } |
| 2901 |
| 2902 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, |
| 2903 NoThemeBackgroundChangeEventOnTabSwitch) { |
| 2904 InstallThemeSource(); |
| 2905 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); |
| 2906 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 2907 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 2908 |
| 2909 // The "Instant" New Tab should have access to chrome-search: scheme but not |
| 2910 // chrome: scheme. |
| 2911 ui_test_utils::NavigateToURLWithDisposition( |
| 2912 browser(), |
| 2913 GURL(chrome::kChromeUINewTabURL), |
| 2914 NEW_FOREGROUND_TAB, |
| 2915 ui_test_utils::BROWSER_TEST_NONE); |
| 2916 |
| 2917 content::RenderViewHost* rvh = |
| 2918 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); |
| 2919 |
| 2920 const std::string chrome_url("chrome://theme/IDR_THEME_NTP_BACKGROUND"); |
| 2921 const std::string search_url( |
| 2922 "chrome-search://theme/IDR_THEME_NTP_BACKGROUND"); |
| 2923 bool loaded = false; |
| 2924 ASSERT_TRUE(LoadImage(rvh, chrome_url, &loaded)); |
| 2925 EXPECT_FALSE(loaded) << chrome_url; |
| 2926 ASSERT_TRUE(LoadImage(rvh, search_url, &loaded)); |
| 2927 EXPECT_TRUE(loaded) << search_url; |
| 2928 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 2929 |
| 2930 // Make sure new tab received the onthemechanged event once. |
| 2931 content::WebContents* active_tab = |
| 2932 browser()->tab_strip_model()->GetActiveWebContents(); |
| 2933 ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 2934 int on_theme_changed_calls = 0; |
| 2935 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls", |
| 2936 &on_theme_changed_calls)); |
| 2937 EXPECT_EQ(1, on_theme_changed_calls); |
| 2938 |
| 2939 // Activate the previous tab. |
| 2940 browser()->tab_strip_model()->ActivateTabAt(0, false); |
| 2941 ASSERT_EQ(0, browser()->tab_strip_model()->active_index()); |
| 2942 |
| 2943 // Switch back to new tab. |
| 2944 browser()->tab_strip_model()->ActivateTabAt(1, false); |
| 2945 ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 2946 |
| 2947 // Confirm that new tab got no onthemechanged event. |
| 2948 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 2949 on_theme_changed_calls = 0; |
| 2950 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls", |
| 2951 &on_theme_changed_calls)); |
| 2952 EXPECT_EQ(1, on_theme_changed_calls); |
| 2953 } |
OLD | NEW |