OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import os | 6 import os |
7 import time | 7 import time |
8 | 8 |
9 import pyauto_functional # Must be imported before pyauto | 9 import pyauto_functional # Must be imported before pyauto |
10 import pyauto | 10 import pyauto |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 test_utils.RemoveDownloadedTestFile(self, zip_file) | 148 test_utils.RemoveDownloadedTestFile(self, zip_file) |
149 # We shouldn't have any history | 149 # We shouldn't have any history |
150 history = self.GetHistoryInfo().History() | 150 history = self.GetHistoryInfo().History() |
151 self.assertEqual(0, len(history)) | 151 self.assertEqual(0, len(history)) |
152 | 152 |
153 def testRedirectHistory(self): | 153 def testRedirectHistory(self): |
154 """HTTP meta-refresh redirects should have separate history entries.""" | 154 """HTTP meta-refresh redirects should have separate history entries.""" |
155 assert not self.GetHistoryInfo().History(), 'Expecting clean history.' | 155 assert not self.GetHistoryInfo().History(), 'Expecting clean history.' |
156 file_url = self.GetFileURLForDataPath('History', 'redirector.html') | 156 file_url = self.GetFileURLForDataPath('History', 'redirector.html') |
157 landing_url = self.GetFileURLForDataPath('History', 'landing.html') | 157 landing_url = self.GetFileURLForDataPath('History', 'landing.html') |
158 tab = self.GetBrowserWindow(0).GetTab(0) | 158 self.NavigateToURL(file_url, 0, 0, navigation_count=2) |
159 tab.NavigateToURLBlockUntilNavigationsComplete(pyauto.GURL(file_url), 2) | |
160 self.assertEqual(landing_url, self.GetActiveTabURL().spec()) | 159 self.assertEqual(landing_url, self.GetActiveTabURL().spec()) |
161 # We should have two history items | 160 # We should have two history items |
162 history = self.GetHistoryInfo().History() | 161 history = self.GetHistoryInfo().History() |
163 self.assertEqual(2, len(history)) | 162 self.assertEqual(2, len(history)) |
164 self.assertEqual(landing_url, history[0]['url']) | 163 self.assertEqual(landing_url, history[0]['url']) |
165 | 164 |
166 def testForge(self): | 165 def testForge(self): |
167 """Brief test of forging history items. | 166 """Brief test of forging history items. |
168 | 167 |
169 Note the history system can tweak values (e.g. lower-case a URL or | 168 Note the history system can tweak values (e.g. lower-case a URL or |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 """Verify that reloading a page brings it to top of history list.""" | 263 """Verify that reloading a page brings it to top of history list.""" |
265 url1 = self.GetFileURLForDataPath('title2.html') | 264 url1 = self.GetFileURLForDataPath('title2.html') |
266 title1 = 'Title Of Awesomeness' | 265 title1 = 'Title Of Awesomeness' |
267 self._NavigateAndCheckHistory(title1, 'title2.html', 1) | 266 self._NavigateAndCheckHistory(title1, 'title2.html', 1) |
268 | 267 |
269 url2 = self.GetFileURLForDataPath('title3.html') | 268 url2 = self.GetFileURLForDataPath('title3.html') |
270 title2 = 'Title Of More Awesomeness' | 269 title2 = 'Title Of More Awesomeness' |
271 self.AppendTab(pyauto.GURL(url2)) | 270 self.AppendTab(pyauto.GURL(url2)) |
272 self._CheckHistory(title2, url2, 2) | 271 self._CheckHistory(title2, url2, 2) |
273 | 272 |
274 self.ActivateTab(0) | 273 self.ReloadTab() |
275 self.ReloadActiveTab() | |
276 self._CheckHistory(title1, url1, 2) | 274 self._CheckHistory(title1, url1, 2) |
277 | 275 |
278 def testBackForwardBringPageToTop(self): | 276 def testBackForwardBringPageToTop(self): |
279 """Verify that back/forward brings current page to top of history list.""" | 277 """Verify that back/forward brings current page to top of history list.""" |
280 url1 = self.GetFileURLForDataPath('title2.html') | 278 url1 = self.GetFileURLForDataPath('title2.html') |
281 title1 = 'Title Of Awesomeness' | 279 title1 = 'Title Of Awesomeness' |
282 self._NavigateAndCheckHistory(title1, 'title2.html', 1) | 280 self._NavigateAndCheckHistory(title1, 'title2.html', 1) |
283 | 281 |
284 url2 = self.GetFileURLForDataPath('title3.html') | 282 url2 = self.GetFileURLForDataPath('title3.html') |
285 title2 = 'Title Of More Awesomeness' | 283 title2 = 'Title Of More Awesomeness' |
286 self._NavigateAndCheckHistory(title2, 'title3.html', 2) | 284 self._NavigateAndCheckHistory(title2, 'title3.html', 2) |
287 | 285 |
288 tab = self.GetBrowserWindow(0).GetTab(0) | 286 self.TabGoBack() |
289 tab.GoBack() | |
290 self._CheckHistory(title1, url1, 2) | 287 self._CheckHistory(title1, url1, 2) |
291 tab.GoForward() | 288 self.TabGoForward() |
292 self._CheckHistory(title2, url2, 2) | 289 self._CheckHistory(title2, url2, 2) |
293 | 290 |
294 def testAppendTabAddPage(self): | 291 def testAppendTabAddPage(self): |
295 """Verify that opening a new tab adds that page to history.""" | 292 """Verify that opening a new tab adds that page to history.""" |
296 self._NavigateAndCheckHistory('Title Of Awesomeness', 'title2.html', 1) | 293 self._NavigateAndCheckHistory('Title Of Awesomeness', 'title2.html', 1) |
297 | 294 |
298 url2 = self.GetFileURLForDataPath('title3.html') | 295 url2 = self.GetFileURLForDataPath('title3.html') |
299 title2 = 'Title Of More Awesomeness' | 296 title2 = 'Title Of More Awesomeness' |
300 self.AppendTab(pyauto.GURL(url2)) | 297 self.AppendTab(pyauto.GURL(url2)) |
301 self._CheckHistory(title2, url2, 2) | 298 self._CheckHistory(title2, url2, 2) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 history_url, tab1url, | 349 history_url, tab1url, |
353 msg='Tab 1: History page not expected.') | 350 msg='Tab 1: History page not expected.') |
354 | 351 |
355 self.assertTrue( | 352 self.assertTrue( |
356 self.WaitUntil(lambda: 'History' == self.GetActiveTabTitle()), | 353 self.WaitUntil(lambda: 'History' == self.GetActiveTabTitle()), |
357 msg='History page is not activated.') | 354 msg='History page is not activated.') |
358 | 355 |
359 | 356 |
360 if __name__ == '__main__': | 357 if __name__ == '__main__': |
361 pyauto_functional.Main() | 358 pyauto_functional.Main() |
OLD | NEW |