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.
4
5from telemetry.unittest import tab_test_case
6
7
8class InspectorPageTest(tab_test_case.TabTestCase):
9  def testPageNavigateToNormalUrl(self):
10    self.Navigate('blank.html')
11
12  def testCustomActionToNavigate(self):
13    self.Navigate('page_with_link.html')
14    self.assertEquals(
15        self._tab.EvaluateJavaScript('document.location.pathname;'),
16        '/page_with_link.html')
17
18    self._tab.ExecuteJavaScript('document.getElementById("clickme").click();')
19    self._tab.WaitForNavigate()
20
21    self.assertEquals(
22        self._tab.EvaluateJavaScript('document.location.pathname;'),
23        '/blank.html')
24
25  def testGetCookieByName(self):
26    self.Navigate('blank.html')
27    self._tab.ExecuteJavaScript('document.cookie="foo=bar"')
28    self.assertEquals(self._tab.GetCookieByName('foo'), 'bar')
29
30  def testScriptToEvaluateOnCommit(self):
31    self.Navigate('blank.html',
32                  script_to_evaluate_on_commit='var foo = "bar";')
33    self._tab.WaitForDocumentReadyStateToBeComplete()
34    self.assertEquals(self._tab.EvaluateJavaScript('foo'), 'bar')
35