| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 os | 4 import os |
| 5 | 5 |
| 6 from telemetry import tab_test_case | 6 from telemetry import tab_test_case |
| 7 | 7 |
| 8 class InspectorPageTest(tab_test_case.TabTestCase): | 8 class InspectorPageTest(tab_test_case.TabTestCase): |
| 9 def __init__(self, *args): | 9 def __init__(self, *args): |
| 10 super(InspectorPageTest, self).__init__(*args) | 10 super(InspectorPageTest, self).__init__(*args) |
| 11 self._custom_action_called = False | |
| 12 | 11 |
| 13 def testPageNavigateToNormalUrl(self): | 12 def testPageNavigateToNormalUrl(self): |
| 14 self._tab.page.Navigate('http://www.google.com') | 13 self._tab.page.Navigate('http://www.google.com') |
| 15 self._tab.WaitForDocumentReadyStateToBeComplete() | 14 self._tab.WaitForDocumentReadyStateToBeComplete() |
| 16 | 15 |
| 17 def testPageNavigateToUrlChanger(self): | 16 def testPageNavigateToUrlChanger(self): |
| 18 # The Url that we actually load is http://www.youtube.com/. | 17 # The Url that we actually load is http://www.youtube.com/. |
| 19 self._tab.page.Navigate('http://youtube.com/') | 18 self._tab.page.Navigate('http://youtube.com/') |
| 20 | 19 |
| 21 self._tab.WaitForDocumentReadyStateToBeComplete() | 20 self._tab.WaitForDocumentReadyStateToBeComplete() |
| 22 | 21 |
| 23 def testPageNavigateToImpossibleURL(self): | 22 def testPageNavigateToImpossibleURL(self): |
| 24 self._tab.page.Navigate('http://23f09f0f9fsdflajsfaldfkj2f3f.com') | 23 self._tab.page.Navigate('http://23f09f0f9fsdflajsfaldfkj2f3f.com') |
| 25 self._tab.WaitForDocumentReadyStateToBeComplete() | 24 self._tab.WaitForDocumentReadyStateToBeComplete() |
| 26 | 25 |
| 27 def testCustomActionToNavigate(self): | 26 def testCustomActionToNavigate(self): |
| 28 unittest_data_dir = os.path.join(os.path.dirname(__file__), | 27 unittest_data_dir = os.path.join(os.path.dirname(__file__), |
| 29 '..', 'unittest_data') | 28 '..', 'unittest_data') |
| 30 self._browser.SetHTTPServerDirectory(unittest_data_dir) | 29 self._browser.SetHTTPServerDirectory(unittest_data_dir) |
| 31 self._tab.page.Navigate( | 30 self._tab.page.Navigate( |
| 32 self._browser.http_server.UrlOf('page_with_link.html')) | 31 self._browser.http_server.UrlOf('page_with_link.html')) |
| 33 self._tab.WaitForDocumentReadyStateToBeComplete() | 32 self._tab.WaitForDocumentReadyStateToBeComplete() |
| 34 self.assertEquals(self._tab.runtime.Evaluate('document.location.pathname;'), | 33 self.assertEquals(self._tab.runtime.Evaluate('document.location.pathname;'), |
| 35 '/page_with_link.html') | 34 '/page_with_link.html') |
| 36 | 35 |
| 37 self._custom_action_called = False | 36 custom_action_called = [False] |
| 38 def CustomAction(): | 37 def CustomAction(): |
| 39 self._custom_action_called = True | 38 custom_action_called[0] = True |
| 40 self._tab.runtime.Execute('document.getElementById("clickme").click();') | 39 self._tab.runtime.Execute('document.getElementById("clickme").click();') |
| 41 | 40 |
| 42 self._tab.page.PerformActionAndWaitForNavigate(CustomAction) | 41 self._tab.page.PerformActionAndWaitForNavigate(CustomAction) |
| 43 | 42 |
| 44 self.assertTrue(self._custom_action_called) | 43 self.assertTrue(custom_action_called[0]) |
| 45 self.assertEquals(self._tab.runtime.Evaluate('document.location.pathname;'), | 44 self.assertEquals(self._tab.runtime.Evaluate('document.location.pathname;'), |
| 46 '/blank.html') | 45 '/blank.html') |
| OLD | NEW |