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

Side by Side Diff: chrome/browser/view_source_uitest.cc

Issue 17030: Revert 7508.7509 and 7510 (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/app/chrome_dll_resource.h" 5 #include "chrome/app/chrome_dll_resource.h"
6 #include "chrome/test/automation/browser_proxy.h" 6 #include "chrome/test/automation/browser_proxy.h"
7 #include "chrome/test/automation/tab_proxy.h" 7 #include "chrome/test/automation/tab_proxy.h"
8 #include "chrome/test/ui/ui_test.h" 8 #include "chrome/test/ui/ui_test.h"
9 #include "net/url_request/url_request_unittest.h" 9 #include "net/url_request/url_request_unittest.h"
10 10
(...skipping 20 matching lines...) Expand all
31 protected: 31 protected:
32 std::wstring test_html_; 32 std::wstring test_html_;
33 }; 33 };
34 34
35 } // namespace 35 } // namespace
36 36
37 // This test renders a page in view-source and then checks to see if a cookie 37 // This test renders a page in view-source and then checks to see if a cookie
38 // set in the html was set successfully (it shouldn't because we rendered the 38 // set in the html was set successfully (it shouldn't because we rendered the
39 // page in view source) 39 // page in view source)
40 TEST_F(ViewSourceTest, DoesBrowserRenderInViewSource) { 40 TEST_F(ViewSourceTest, DoesBrowserRenderInViewSource) {
41 scoped_refptr<HTTPTestServer> server = 41 TestServer server(kDocRoot);
42 HTTPTestServer::CreateServer(kDocRoot);
43 ASSERT_TRUE(NULL != server.get());
44 std::string cookie = "viewsource_cookie"; 42 std::string cookie = "viewsource_cookie";
45 std::string cookie_data = "foo"; 43 std::string cookie_data = "foo";
46 44
47 // First we navigate to our view-source test page 45 // First we navigate to our view-source test page
48 GURL url = server->TestServerPageW(test_html_); 46 GURL url = server.TestServerPageW(test_html_);
49 url = GURL("view-source:" + url.spec()); 47 url = GURL("view-source:" + url.spec());
50 scoped_ptr<TabProxy> tab(GetActiveTab()); 48 scoped_ptr<TabProxy> tab(GetActiveTab());
51 tab->NavigateToURL(url); 49 tab->NavigateToURL(url);
52 Sleep(kWaitForActionMsec); 50 Sleep(kWaitForActionMsec);
53 51
54 // Try to retrieve the cookie that the page sets 52 // Try to retrieve the cookie that the page sets
55 // It should not be there (because we are in view-source mode 53 // It should not be there (because we are in view-source mode
56 std::string cookie_found; 54 std::string cookie_found;
57 tab->GetCookieByName(url, cookie, &cookie_found); 55 tab->GetCookieByName(url, cookie, &cookie_found);
58 EXPECT_NE(cookie_data, cookie_found); 56 EXPECT_NE(cookie_data, cookie_found);
59 } 57 }
60 58
61 // This test renders a page normally and then renders the same page in 59 // This test renders a page normally and then renders the same page in
62 // view-source mode. This is done since we had a problem at one point during 60 // view-source mode. This is done since we had a problem at one point during
63 // implementation of the view-source: prefix being consumed (removed from the 61 // implementation of the view-source: prefix being consumed (removed from the
64 // URL) if the URL was not changed (apart from adding the view-source prefix) 62 // URL) if the URL was not changed (apart from adding the view-source prefix)
65 TEST_F(ViewSourceTest, DoesBrowserConsumeViewSourcePrefix) { 63 TEST_F(ViewSourceTest, DoesBrowserConsumeViewSourcePrefix) {
66 scoped_refptr<HTTPTestServer> server = 64 TestServer server(kDocRoot);
67 HTTPTestServer::CreateServer(kDocRoot);
68 ASSERT_TRUE(NULL != server.get());
69 65
70 // First we navigate to google.html 66 // First we navigate to google.html
71 GURL url = server->TestServerPageW(test_html_); 67 GURL url = server.TestServerPageW(test_html_);
72 NavigateToURL(url); 68 NavigateToURL(url);
73 69
74 // Then we navigate to the SAME url but with the view-source: prefix 70 // Then we navigate to the SAME url but with the view-source: prefix
75 GURL url_viewsource = GURL("view-source:" + url.spec()); 71 GURL url_viewsource = GURL("view-source:" + url.spec());
76 NavigateToURL(url_viewsource); 72 NavigateToURL(url_viewsource);
77 73
78 // The URL should still be prefixed with view-source: 74 // The URL should still be prefixed with view-source:
79 EXPECT_EQ(url_viewsource.spec(), GetActiveTabURL().spec()); 75 EXPECT_EQ(url_viewsource.spec(), GetActiveTabURL().spec());
80 } 76 }
81 77
82 // Make sure that when looking at the actual page, we can select 78 // Make sure that when looking at the actual page, we can select
83 // "View Source" from the Page menu. 79 // "View Source" from the Page menu.
84 TEST_F(ViewSourceTest, ViewSourceInPageMenuEnabledOnANormalPage) { 80 TEST_F(ViewSourceTest, ViewSourceInPageMenuEnabledOnANormalPage) {
85 scoped_refptr<HTTPTestServer> server = 81 TestServer server(kDocRoot);
86 HTTPTestServer::CreateServer(kDocRoot);
87 ASSERT_TRUE(NULL != server.get());
88 82
89 // First we navigate to google.html 83 // First we navigate to google.html
90 GURL url = server->TestServerPageW(test_html_); 84 GURL url = server.TestServerPageW(test_html_);
91 NavigateToURL(url); 85 NavigateToURL(url);
92 86
93 EXPECT_TRUE(IsPageMenuCommandEnabled(IDC_VIEW_SOURCE)); 87 EXPECT_TRUE(IsPageMenuCommandEnabled(IDC_VIEW_SOURCE));
94 } 88 }
95 89
96 // Make sure that when looking at the page source, we can't select 90 // Make sure that when looking at the page source, we can't select
97 // "View Source" from the Page menu. 91 // "View Source" from the Page menu.
98 TEST_F(ViewSourceTest, ViewSourceInPageMenuDisabledWhileViewingSource) { 92 TEST_F(ViewSourceTest, ViewSourceInPageMenuDisabledWhileViewingSource) {
99 scoped_refptr<HTTPTestServer> server = 93 TestServer server(kDocRoot);
100 HTTPTestServer::CreateServer(kDocRoot);
101 ASSERT_TRUE(NULL != server.get());
102 94
103 // First we navigate to google.html 95 // First we navigate to google.html
104 GURL url = server->TestServerPageW(test_html_); 96 GURL url = server.TestServerPageW(test_html_);
105 GURL url_viewsource = GURL("view-source:" + url.spec()); 97 GURL url_viewsource = GURL("view-source:" + url.spec());
106 NavigateToURL(url_viewsource); 98 NavigateToURL(url_viewsource);
107 99
108 EXPECT_FALSE(IsPageMenuCommandEnabled(IDC_VIEW_SOURCE)); 100 EXPECT_FALSE(IsPageMenuCommandEnabled(IDC_VIEW_SOURCE));
109 } 101 }
110 102
OLDNEW
« no previous file with comments | « chrome/browser/url_fetcher_unittest.cc ('k') | chrome/browser/views/find_bar_win_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698