OLD | NEW |
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 |
11 namespace { | 11 namespace { |
12 | 12 |
13 const wchar_t kDocRoot[] = L"chrome/test/data"; | 13 const wchar_t kDocRoot[] = L"chrome/test/data"; |
14 | 14 |
15 class ViewSourceTest : public UITest { | 15 class ViewSourceTest : public UITest { |
16 protected: | 16 protected: |
17 ViewSourceTest() : UITest() { | 17 ViewSourceTest() : UITest() { |
18 test_html_ = L"files/viewsource/test.html"; | 18 test_html_ = L"files/viewsource/test.html"; |
19 } | 19 } |
20 | 20 |
21 bool IsPageMenuCommandEnabled(int command) { | 21 bool IsPageMenuCommandEnabled(int command) { |
22 scoped_ptr<BrowserProxy> window_proxy(automation()->GetBrowserWindow(0)); | 22 scoped_refptr<BrowserProxy> window_proxy(automation()->GetBrowserWindow(0)); |
23 if (!window_proxy.get()) | 23 if (!window_proxy.get()) |
24 return false; | 24 return false; |
25 | 25 |
26 bool timed_out; | 26 bool timed_out; |
27 return window_proxy->IsPageMenuCommandEnabledWithTimeout( | 27 return window_proxy->IsPageMenuCommandEnabledWithTimeout( |
28 command, 5000, &timed_out) && !timed_out; | 28 command, 5000, &timed_out) && !timed_out; |
29 } | 29 } |
30 | 30 |
31 protected: | 31 protected: |
32 std::wstring test_html_; | 32 std::wstring test_html_; |
33 }; | 33 }; |
34 | 34 |
35 // This test renders a page in view-source and then checks to see if a cookie | 35 // This test renders a page in view-source and then checks to see if a cookie |
36 // set in the html was set successfully (it shouldn't because we rendered the | 36 // set in the html was set successfully (it shouldn't because we rendered the |
37 // page in view source) | 37 // page in view source) |
38 TEST_F(ViewSourceTest, DoesBrowserRenderInViewSource) { | 38 TEST_F(ViewSourceTest, DoesBrowserRenderInViewSource) { |
39 scoped_refptr<HTTPTestServer> server = | 39 scoped_refptr<HTTPTestServer> server = |
40 HTTPTestServer::CreateServer(kDocRoot, NULL); | 40 HTTPTestServer::CreateServer(kDocRoot, NULL); |
41 ASSERT_TRUE(NULL != server.get()); | 41 ASSERT_TRUE(NULL != server.get()); |
42 std::string cookie = "viewsource_cookie"; | 42 std::string cookie = "viewsource_cookie"; |
43 std::string cookie_data = "foo"; | 43 std::string cookie_data = "foo"; |
44 | 44 |
45 // First we navigate to our view-source test page | 45 // First we navigate to our view-source test page |
46 GURL url = server->TestServerPageW(test_html_); | 46 GURL url = server->TestServerPageW(test_html_); |
47 url = GURL("view-source:" + url.spec()); | 47 url = GURL("view-source:" + url.spec()); |
48 scoped_ptr<TabProxy> tab(GetActiveTab()); | 48 scoped_refptr<TabProxy> tab(GetActiveTab()); |
49 tab->NavigateToURL(url); | 49 tab->NavigateToURL(url); |
50 PlatformThread::Sleep(sleep_timeout_ms()); | 50 PlatformThread::Sleep(sleep_timeout_ms()); |
51 | 51 |
52 // Try to retrieve the cookie that the page sets | 52 // Try to retrieve the cookie that the page sets |
53 // 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 |
54 std::string cookie_found; | 54 std::string cookie_found; |
55 tab->GetCookieByName(url, cookie, &cookie_found); | 55 tab->GetCookieByName(url, cookie, &cookie_found); |
56 EXPECT_NE(cookie_data, cookie_found); | 56 EXPECT_NE(cookie_data, cookie_found); |
57 } | 57 } |
58 | 58 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 // First we navigate to google.html | 101 // First we navigate to google.html |
102 GURL url = server->TestServerPageW(test_html_); | 102 GURL url = server->TestServerPageW(test_html_); |
103 GURL url_viewsource = GURL("view-source:" + url.spec()); | 103 GURL url_viewsource = GURL("view-source:" + url.spec()); |
104 NavigateToURL(url_viewsource); | 104 NavigateToURL(url_viewsource); |
105 | 105 |
106 EXPECT_FALSE(IsPageMenuCommandEnabled(IDC_VIEW_SOURCE)); | 106 EXPECT_FALSE(IsPageMenuCommandEnabled(IDC_VIEW_SOURCE)); |
107 } | 107 } |
108 | 108 |
109 } // namespace | 109 } // namespace |
OLD | NEW |