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
3 # found in the LICENSE file.
5 from telemetry import test
6 from telemetry.core import util
7 from telemetry.unittest import tab_test_case
10 class InspectorPageTest(tab_test_case.TabTestCase):
11 def __init__(self, *args):
12 super(InspectorPageTest, self).__init__(*args)
15 super(InspectorPageTest, self).setUp()
16 self._browser.SetHTTPServerDirectories(util.GetUnittestDataDir())
18 def testPageNavigateToNormalUrl(self):
19 self._tab.Navigate(self._browser.http_server.UrlOf('blank.html'))
20 self._tab.WaitForDocumentReadyStateToBeComplete()
22 @test.Disabled('chromeos')
23 def testCustomActionToNavigate(self):
25 self._browser.http_server.UrlOf('page_with_link.html'))
26 self._tab.WaitForDocumentReadyStateToBeComplete()
28 self._tab.EvaluateJavaScript('document.location.pathname;'),
29 '/page_with_link.html')
31 custom_action_called = [False]
33 custom_action_called[0] = True
34 self._tab.ExecuteJavaScript('document.getElementById("clickme").click();')
36 self._tab.PerformActionAndWaitForNavigate(CustomAction)
38 self.assertTrue(custom_action_called[0])
40 self._tab.EvaluateJavaScript('document.location.pathname;'),
43 def testGetCookieByName(self):
45 self._browser.http_server.UrlOf('blank.html'))
46 self._tab.WaitForDocumentReadyStateToBeComplete()
47 self._tab.ExecuteJavaScript('document.cookie="foo=bar"')
48 self.assertEquals(self._tab.GetCookieByName('foo'), 'bar')
50 def testScriptToEvaluateOnCommit(self):
52 self._browser.http_server.UrlOf('blank.html'),
53 script_to_evaluate_on_commit='var foo = "bar";')
54 self._tab.WaitForDocumentReadyStateToBeComplete()
55 self.assertEquals(self._tab.EvaluateJavaScript('foo'), 'bar')