| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 from telemetry import test | |
| 6 from telemetry.core import util | |
| 7 from telemetry.unittest import tab_test_case | 5 from telemetry.unittest import tab_test_case |
| 8 | 6 |
| 9 | 7 |
| 10 class InspectorPageTest(tab_test_case.TabTestCase): | 8 class InspectorPageTest(tab_test_case.TabTestCase): |
| 11 def __init__(self, *args): | 9 def __init__(self, *args): |
| 12 super(InspectorPageTest, self).__init__(*args) | 10 super(InspectorPageTest, self).__init__(*args) |
| 13 | 11 |
| 14 def setUp(self): | 12 def setUp(self): |
| 15 super(InspectorPageTest, self).setUp() | 13 super(InspectorPageTest, self).setUp() |
| 16 self._browser.SetHTTPServerDirectories(util.GetUnittestDataDir()) | |
| 17 | 14 |
| 18 def testPageNavigateToNormalUrl(self): | 15 def testPageNavigateToNormalUrl(self): |
| 19 self._tab.Navigate(self._browser.http_server.UrlOf('blank.html')) | 16 self.Navigate('blank.html') |
| 20 self._tab.WaitForDocumentReadyStateToBeComplete() | |
| 21 | 17 |
| 22 @test.Disabled('chromeos') | |
| 23 def testCustomActionToNavigate(self): | 18 def testCustomActionToNavigate(self): |
| 24 self._tab.Navigate( | 19 self.Navigate('page_with_link.html') |
| 25 self._browser.http_server.UrlOf('page_with_link.html')) | |
| 26 self._tab.WaitForDocumentReadyStateToBeComplete() | |
| 27 self.assertEquals( | 20 self.assertEquals( |
| 28 self._tab.EvaluateJavaScript('document.location.pathname;'), | 21 self._tab.EvaluateJavaScript('document.location.pathname;'), |
| 29 '/page_with_link.html') | 22 '/page_with_link.html') |
| 30 | 23 |
| 31 custom_action_called = [False] | 24 custom_action_called = [False] |
| 32 def CustomAction(): | 25 def CustomAction(): |
| 33 custom_action_called[0] = True | 26 custom_action_called[0] = True |
| 34 self._tab.ExecuteJavaScript('document.getElementById("clickme").click();') | 27 self._tab.ExecuteJavaScript('document.getElementById("clickme").click();') |
| 35 | 28 |
| 36 self._tab.PerformActionAndWaitForNavigate(CustomAction) | 29 self._tab.PerformActionAndWaitForNavigate(CustomAction) |
| 37 | 30 |
| 38 self.assertTrue(custom_action_called[0]) | 31 self.assertTrue(custom_action_called[0]) |
| 39 self.assertEquals( | 32 self.assertEquals( |
| 40 self._tab.EvaluateJavaScript('document.location.pathname;'), | 33 self._tab.EvaluateJavaScript('document.location.pathname;'), |
| 41 '/blank.html') | 34 '/blank.html') |
| 42 | 35 |
| 43 def testGetCookieByName(self): | 36 def testGetCookieByName(self): |
| 44 self._tab.Navigate( | 37 self.Navigate('blank.html') |
| 45 self._browser.http_server.UrlOf('blank.html')) | |
| 46 self._tab.WaitForDocumentReadyStateToBeComplete() | |
| 47 self._tab.ExecuteJavaScript('document.cookie="foo=bar"') | 38 self._tab.ExecuteJavaScript('document.cookie="foo=bar"') |
| 48 self.assertEquals(self._tab.GetCookieByName('foo'), 'bar') | 39 self.assertEquals(self._tab.GetCookieByName('foo'), 'bar') |
| 49 | 40 |
| 50 def testScriptToEvaluateOnCommit(self): | 41 def testScriptToEvaluateOnCommit(self): |
| 51 self._tab.Navigate( | 42 self.Navigate('blank.html', |
| 52 self._browser.http_server.UrlOf('blank.html'), | 43 script_to_evaluate_on_commit='var foo = "bar";') |
| 53 script_to_evaluate_on_commit='var foo = "bar";') | |
| 54 self._tab.WaitForDocumentReadyStateToBeComplete() | 44 self._tab.WaitForDocumentReadyStateToBeComplete() |
| 55 self.assertEquals(self._tab.EvaluateJavaScript('foo'), 'bar') | 45 self.assertEquals(self._tab.EvaluateJavaScript('foo'), 'bar') |
| OLD | NEW |