OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/profiles/profile.h" | 5 #include "chrome/browser/profiles/profile.h" |
6 #include "chrome/browser/ui/browser.h" | 6 #include "chrome/browser/ui/browser.h" |
7 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 7 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
8 #include "chrome/browser/ui/webui/password_manager_internals/password_manager_in
ternals_ui.h" | 8 #include "chrome/browser/ui/webui/password_manager_internals/password_manager_in
ternals_ui.h" |
9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 PasswordManagerInternalsWebUIBrowserTest:: | 37 PasswordManagerInternalsWebUIBrowserTest:: |
38 PasswordManagerInternalsWebUIBrowserTest() | 38 PasswordManagerInternalsWebUIBrowserTest() |
39 : controller_(NULL) {} | 39 : controller_(NULL) {} |
40 | 40 |
41 PasswordManagerInternalsWebUIBrowserTest:: | 41 PasswordManagerInternalsWebUIBrowserTest:: |
42 ~PasswordManagerInternalsWebUIBrowserTest() {} | 42 ~PasswordManagerInternalsWebUIBrowserTest() {} |
43 | 43 |
44 void PasswordManagerInternalsWebUIBrowserTest::SetUpOnMainThread() { | 44 void PasswordManagerInternalsWebUIBrowserTest::SetUpOnMainThread() { |
45 WebUIBrowserTest::SetUpOnMainThread(); | 45 WebUIBrowserTest::SetUpOnMainThread(); |
46 OpenInternalsPage(CURRENT_TAB); | 46 OpenInternalsPage(WindowOpenDisposition::CURRENT_TAB); |
47 AddLibrary(base::FilePath( | 47 AddLibrary(base::FilePath( |
48 FILE_PATH_LITERAL("password_manager_internals_browsertest.js"))); | 48 FILE_PATH_LITERAL("password_manager_internals_browsertest.js"))); |
49 } | 49 } |
50 | 50 |
51 content::WebContents* | 51 content::WebContents* |
52 PasswordManagerInternalsWebUIBrowserTest::GetWebContents() { | 52 PasswordManagerInternalsWebUIBrowserTest::GetWebContents() { |
53 return browser()->tab_strip_model()->GetActiveWebContents(); | 53 return browser()->tab_strip_model()->GetActiveWebContents(); |
54 } | 54 } |
55 | 55 |
56 void PasswordManagerInternalsWebUIBrowserTest::OpenInternalsPage( | 56 void PasswordManagerInternalsWebUIBrowserTest::OpenInternalsPage( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 93 } |
94 | 94 |
95 // Test that a single internals page is flushed on reload. | 95 // Test that a single internals page is flushed on reload. |
96 IN_PROC_BROWSER_TEST_F(PasswordManagerInternalsWebUIBrowserTest, | 96 IN_PROC_BROWSER_TEST_F(PasswordManagerInternalsWebUIBrowserTest, |
97 LogSavePasswordProgress_FlushedOnReload) { | 97 LogSavePasswordProgress_FlushedOnReload) { |
98 password_manager::PasswordManagerInternalsService* service = | 98 password_manager::PasswordManagerInternalsService* service = |
99 password_manager::PasswordManagerInternalsServiceFactory:: | 99 password_manager::PasswordManagerInternalsServiceFactory:: |
100 GetForBrowserContext(browser()->profile()); | 100 GetForBrowserContext(browser()->profile()); |
101 ASSERT_TRUE(service); | 101 ASSERT_TRUE(service); |
102 service->ProcessLog("<script> text for testing"); | 102 service->ProcessLog("<script> text for testing"); |
103 OpenInternalsPage(CURRENT_TAB); // Reload. | 103 OpenInternalsPage(WindowOpenDisposition::CURRENT_TAB); // Reload. |
104 ASSERT_TRUE(RunJavascriptTest("testLogEmpty")); | 104 ASSERT_TRUE(RunJavascriptTest("testLogEmpty")); |
105 } | 105 } |
106 | 106 |
107 // Test that if two tabs with the internals page are open, the second displays | 107 // Test that if two tabs with the internals page are open, the second displays |
108 // the same logs. In particular, this checks that both the second tab gets the | 108 // the same logs. In particular, this checks that both the second tab gets the |
109 // logs created before the second tab was opened, and also that the second tab | 109 // logs created before the second tab was opened, and also that the second tab |
110 // waits with displaying until the internals page is ready (trying to display | 110 // waits with displaying until the internals page is ready (trying to display |
111 // the old logs just on construction time would fail). | 111 // the old logs just on construction time would fail). |
112 IN_PROC_BROWSER_TEST_F(PasswordManagerInternalsWebUIBrowserTest, | 112 IN_PROC_BROWSER_TEST_F(PasswordManagerInternalsWebUIBrowserTest, |
113 LogSavePasswordProgress_MultipleTabsIdentical) { | 113 LogSavePasswordProgress_MultipleTabsIdentical) { |
114 // First, open one tab with the internals page, and log something. | 114 // First, open one tab with the internals page, and log something. |
115 password_manager::PasswordManagerInternalsService* service = | 115 password_manager::PasswordManagerInternalsService* service = |
116 password_manager::PasswordManagerInternalsServiceFactory:: | 116 password_manager::PasswordManagerInternalsServiceFactory:: |
117 GetForBrowserContext(browser()->profile()); | 117 GetForBrowserContext(browser()->profile()); |
118 ASSERT_TRUE(service); | 118 ASSERT_TRUE(service); |
119 service->ProcessLog("<script> text for testing"); | 119 service->ProcessLog("<script> text for testing"); |
120 ASSERT_TRUE(RunJavascriptTest("testLogText")); | 120 ASSERT_TRUE(RunJavascriptTest("testLogText")); |
121 // Now open a second tab with the internals page, but do not log anything. | 121 // Now open a second tab with the internals page, but do not log anything. |
122 OpenInternalsPage(NEW_FOREGROUND_TAB); | 122 OpenInternalsPage(WindowOpenDisposition::NEW_FOREGROUND_TAB); |
123 // The previously logged text should have made it to the page. | 123 // The previously logged text should have made it to the page. |
124 ASSERT_TRUE(RunJavascriptTest("testLogText")); | 124 ASSERT_TRUE(RunJavascriptTest("testLogText")); |
125 } | 125 } |
126 | 126 |
127 // Test that in the presence of more internals pages, reload does not cause | 127 // Test that in the presence of more internals pages, reload does not cause |
128 // flushing the logs. | 128 // flushing the logs. |
129 IN_PROC_BROWSER_TEST_F(PasswordManagerInternalsWebUIBrowserTest, | 129 IN_PROC_BROWSER_TEST_F(PasswordManagerInternalsWebUIBrowserTest, |
130 LogSavePasswordProgress_NotFlushedOnReloadIfMultiple) { | 130 LogSavePasswordProgress_NotFlushedOnReloadIfMultiple) { |
131 // Open one more tab with the internals page. | 131 // Open one more tab with the internals page. |
132 OpenInternalsPage(NEW_FOREGROUND_TAB); | 132 OpenInternalsPage(WindowOpenDisposition::NEW_FOREGROUND_TAB); |
133 // Now log something. | 133 // Now log something. |
134 password_manager::PasswordManagerInternalsService* service = | 134 password_manager::PasswordManagerInternalsService* service = |
135 password_manager::PasswordManagerInternalsServiceFactory:: | 135 password_manager::PasswordManagerInternalsServiceFactory:: |
136 GetForBrowserContext(browser()->profile()); | 136 GetForBrowserContext(browser()->profile()); |
137 ASSERT_TRUE(service); | 137 ASSERT_TRUE(service); |
138 service->ProcessLog("<script> text for testing"); | 138 service->ProcessLog("<script> text for testing"); |
139 // Reload. | 139 // Reload. |
140 OpenInternalsPage(CURRENT_TAB); | 140 OpenInternalsPage(WindowOpenDisposition::CURRENT_TAB); |
141 // The text should still be there. | 141 // The text should still be there. |
142 ASSERT_TRUE(RunJavascriptTest("testLogText")); | 142 ASSERT_TRUE(RunJavascriptTest("testLogText")); |
143 } | 143 } |
144 | 144 |
145 // Test that navigation away from the internals page works OK. | 145 // Test that navigation away from the internals page works OK. |
146 IN_PROC_BROWSER_TEST_F(PasswordManagerInternalsWebUIBrowserTest, | 146 IN_PROC_BROWSER_TEST_F(PasswordManagerInternalsWebUIBrowserTest, |
147 LogSavePasswordProgress_NavigateAway) { | 147 LogSavePasswordProgress_NavigateAway) { |
148 password_manager::PasswordManagerInternalsService* service = | 148 password_manager::PasswordManagerInternalsService* service = |
149 password_manager::PasswordManagerInternalsServiceFactory:: | 149 password_manager::PasswordManagerInternalsServiceFactory:: |
150 GetForBrowserContext(browser()->profile()); | 150 GetForBrowserContext(browser()->profile()); |
(...skipping 13 matching lines...) Expand all Loading... |
164 } | 164 } |
165 | 165 |
166 // Test that the description is correct in an Incognito tab. | 166 // Test that the description is correct in an Incognito tab. |
167 IN_PROC_BROWSER_TEST_F(PasswordManagerInternalsWebUIBrowserTest, | 167 IN_PROC_BROWSER_TEST_F(PasswordManagerInternalsWebUIBrowserTest, |
168 IncognitoMessage) { | 168 IncognitoMessage) { |
169 Browser* incognito = CreateIncognitoBrowser(); | 169 Browser* incognito = CreateIncognitoBrowser(); |
170 password_manager::PasswordManagerInternalsService* service = | 170 password_manager::PasswordManagerInternalsService* service = |
171 password_manager::PasswordManagerInternalsServiceFactory:: | 171 password_manager::PasswordManagerInternalsServiceFactory:: |
172 GetForBrowserContext(incognito->profile()->GetOffTheRecordProfile()); | 172 GetForBrowserContext(incognito->profile()->GetOffTheRecordProfile()); |
173 EXPECT_FALSE(service); // There should be no service for Incognito. | 173 EXPECT_FALSE(service); // There should be no service for Incognito. |
174 OpenInternalsPageWithBrowser(incognito, CURRENT_TAB); | 174 OpenInternalsPageWithBrowser(incognito, WindowOpenDisposition::CURRENT_TAB); |
175 SetWebUIInstance( | 175 SetWebUIInstance( |
176 incognito->tab_strip_model()->GetActiveWebContents()->GetWebUI()); | 176 incognito->tab_strip_model()->GetActiveWebContents()->GetWebUI()); |
177 ASSERT_TRUE(RunJavascriptTest("testIncognitoDescription")); | 177 ASSERT_TRUE(RunJavascriptTest("testIncognitoDescription")); |
178 } | 178 } |
OLD | NEW |