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 "base/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "chrome/app/chrome_command_ids.h" | 6 #include "chrome/app/chrome_command_ids.h" |
7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
8 #include "chrome/browser/ui/browser_commands.h" | 8 #include "chrome/browser/ui/browser_commands.h" |
9 #include "chrome/browser/ui/browser_tabstrip.h" | 9 #include "chrome/browser/ui/browser_tabstrip.h" |
10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
11 #include "chrome/test/base/in_process_browser_test.h" | 11 #include "chrome/test/base/in_process_browser_test.h" |
12 #include "chrome/test/base/ui_test_utils.h" | 12 #include "chrome/test/base/ui_test_utils.h" |
13 #include "content/public/browser/navigation_entry.h" | 13 #include "content/public/browser/navigation_entry.h" |
14 #include "content/public/browser/notification_service.h" | 14 #include "content/public/browser/notification_service.h" |
15 #include "content/public/browser/notification_types.h" | 15 #include "content/public/browser/notification_types.h" |
16 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
18 #include "content/public/test/browser_test_utils.h" | 18 #include "content/public/test/browser_test_utils.h" |
19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
20 #include "net/test/test_server.h" | 20 #include "net/test/test_server.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 const char kTestHtml[] = "files/viewsource/test.html"; | 23 const char kTestHtml[] = "files/viewsource/test.html"; |
24 const char kTestMedia[] = "files/media/pink_noise_140ms.wav"; | |
wolenetz
2013/01/04 22:58:37
@ jam@: Is referencing a test data file from media
jam
2013/01/04 23:48:41
I'm not sure what you mean? pink_noise_140ms.wav i
wolenetz
2013/01/05 00:05:19
Yes (and the test passes). The question really is
| |
24 } | 25 } |
25 | 26 |
26 typedef InProcessBrowserTest ViewSourceTest; | 27 typedef InProcessBrowserTest ViewSourceTest; |
27 | 28 |
28 // This test renders a page in view-source and then checks to see if the title | 29 // This test renders a page in view-source and then checks to see if the title |
29 // set in the html was set successfully (it shouldn't because we rendered the | 30 // set in the html was set successfully (it shouldn't because we rendered the |
30 // page in view source). | 31 // page in view source). |
31 // Flaky; see http://crbug.com/72201. | 32 // Flaky; see http://crbug.com/72201. |
32 IN_PROC_BROWSER_TEST_F(ViewSourceTest, DoesBrowserRenderInViewSource) { | 33 IN_PROC_BROWSER_TEST_F(ViewSourceTest, DoesBrowserRenderInViewSource) { |
33 ASSERT_TRUE(test_server()->Start()); | 34 ASSERT_TRUE(test_server()->Start()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 // from the menu. | 69 // from the menu. |
69 IN_PROC_BROWSER_TEST_F(ViewSourceTest, ViewSourceInMenuEnabledOnANormalPage) { | 70 IN_PROC_BROWSER_TEST_F(ViewSourceTest, ViewSourceInMenuEnabledOnANormalPage) { |
70 ASSERT_TRUE(test_server()->Start()); | 71 ASSERT_TRUE(test_server()->Start()); |
71 | 72 |
72 GURL url(test_server()->GetURL(kTestHtml)); | 73 GURL url(test_server()->GetURL(kTestHtml)); |
73 ui_test_utils::NavigateToURL(browser(), url); | 74 ui_test_utils::NavigateToURL(browser(), url); |
74 | 75 |
75 EXPECT_TRUE(chrome::CanViewSource(browser())); | 76 EXPECT_TRUE(chrome::CanViewSource(browser())); |
76 } | 77 } |
77 | 78 |
79 // For page that is media content, make sure that we cannot select "View Source" | |
80 // See http://crbug.com/83714 | |
81 IN_PROC_BROWSER_TEST_F(ViewSourceTest, ViewSourceInMenuDisabledOnAMediaPage) { | |
82 ASSERT_TRUE(test_server()->Start()); | |
83 | |
84 GURL url(test_server()->GetURL(kTestMedia)); | |
85 ui_test_utils::NavigateToURL(browser(), url); | |
86 | |
87 const char* mime_type = chrome::GetActiveWebContents(browser())-> | |
88 GetContentsMimeType().c_str(); | |
89 | |
90 EXPECT_STREQ("audio/wav", mime_type); | |
91 EXPECT_FALSE(chrome::CanViewSource(browser())); | |
92 } | |
93 | |
78 // Make sure that when looking at the page source, we can't select "View Source" | 94 // Make sure that when looking at the page source, we can't select "View Source" |
79 // from the menu. | 95 // from the menu. |
80 IN_PROC_BROWSER_TEST_F(ViewSourceTest, | 96 IN_PROC_BROWSER_TEST_F(ViewSourceTest, |
81 ViewSourceInMenuDisabledWhileViewingSource) { | 97 ViewSourceInMenuDisabledWhileViewingSource) { |
82 ASSERT_TRUE(test_server()->Start()); | 98 ASSERT_TRUE(test_server()->Start()); |
83 | 99 |
84 GURL url_viewsource(chrome::kViewSourceScheme + std::string(":") + | 100 GURL url_viewsource(chrome::kViewSourceScheme + std::string(":") + |
85 test_server()->GetURL(kTestHtml).spec()); | 101 test_server()->GetURL(kTestHtml).spec()); |
86 ui_test_utils::NavigateToURL(browser(), url_viewsource); | 102 ui_test_utils::NavigateToURL(browser(), url_viewsource); |
87 | 103 |
(...skipping 18 matching lines...) Expand all Loading... | |
106 ASSERT_TRUE(content::ExecuteScript(chrome::GetWebContentsAt(browser(), 0), | 122 ASSERT_TRUE(content::ExecuteScript(chrome::GetWebContentsAt(browser(), 0), |
107 "window.location.reload();")); | 123 "window.location.reload();")); |
108 | 124 |
109 content::WindowedNotificationObserver observer2( | 125 content::WindowedNotificationObserver observer2( |
110 content::NOTIFICATION_LOAD_STOP, | 126 content::NOTIFICATION_LOAD_STOP, |
111 content::NotificationService::AllSources()); | 127 content::NotificationService::AllSources()); |
112 observer2.Wait(); | 128 observer2.Wait(); |
113 ASSERT_TRUE(chrome::GetWebContentsAt(browser(), 0)->GetController(). | 129 ASSERT_TRUE(chrome::GetWebContentsAt(browser(), 0)->GetController(). |
114 GetActiveEntry()->IsViewSourceMode()); | 130 GetActiveEntry()->IsViewSourceMode()); |
115 } | 131 } |
OLD | NEW |