| 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 import logging | 4 import logging |
| 5 | 5 |
| 6 from telemetry.core import exceptions | 6 from telemetry.core import exceptions |
| 7 from telemetry.page import page as page_module | 7 from telemetry.page import page as page_module |
| 8 from telemetry.page import page_set as page_set_module | 8 from telemetry import story |
| 9 | 9 |
| 10 | 10 |
| 11 class SafebrowsingPage(page_module.Page): | 11 class SafebrowsingPage(page_module.Page): |
| 12 | 12 |
| 13 """ | 13 """ |
| 14 Why: Expect 'malware ahead' page. Use a short navigation timeout because no | 14 Why: Expect 'malware ahead' page. Use a short navigation timeout because no |
| 15 response will be received. | 15 response will be received. |
| 16 """ | 16 """ |
| 17 | 17 |
| 18 def __init__(self, url, page_set, expect_timeout): | 18 def __init__(self, url, page_set, expect_timeout): |
| 19 super(SafebrowsingPage, self).__init__(url=url, page_set=page_set) | 19 super(SafebrowsingPage, self).__init__(url=url, page_set=page_set) |
| 20 self._expect_timeout = expect_timeout | 20 self._expect_timeout = expect_timeout |
| 21 | 21 |
| 22 def RunNavigateSteps(self, action_runner): | 22 def RunNavigateSteps(self, action_runner): |
| 23 try: | 23 try: |
| 24 action_runner.Navigate(self.url, timeout_in_seconds=5) | 24 action_runner.Navigate(self.url, timeout_in_seconds=5) |
| 25 except exceptions.TimeoutException as e: | 25 except exceptions.TimeoutException as e: |
| 26 if self._expect_timeout: | 26 if self._expect_timeout: |
| 27 logging.warning('Navigation timeout on page %s', self.url) | 27 logging.warning('Navigation timeout on page %s', self.url) |
| 28 else: | 28 else: |
| 29 raise e | 29 raise e |
| 30 | 30 |
| 31 | 31 |
| 32 class SafebrowsingPageSet(page_set_module.PageSet): | 32 class SafebrowsingStorySet(story.StorySet): |
| 33 | 33 |
| 34 """ Chrome proxy test sites """ | 34 """ Chrome proxy test sites """ |
| 35 | 35 |
| 36 def __init__(self, expect_timeout=False): | 36 def __init__(self, expect_timeout=False): |
| 37 super(SafebrowsingPageSet, self).__init__() | 37 super(SafebrowsingStorySet, self).__init__() |
| 38 | 38 |
| 39 self.AddUserStory( | 39 self.AddStory( |
| 40 SafebrowsingPage('http://www.ianfette.org/', self, expect_timeout)) | 40 SafebrowsingPage('http://www.ianfette.org/', self, expect_timeout)) |
| OLD | NEW |