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
3 # found in the LICENSE file.
7 from telemetry
.page
import page
as page_module
8 from telemetry
.page
import page_set
as page_set_module
11 def _CreateXpathFunction(xpath
):
12 return ('document.evaluate("%s",'
15 'XPathResult.FIRST_ORDERED_NODE_TYPE,'
17 '.singleNodeValue' % re
.escape(xpath
))
20 class IndexeddbOfflinePage(page_module
.Page
):
22 """ Why: Simulates user input while offline and sync while online. """
24 def __init__(self
, page_set
):
25 super(IndexeddbOfflinePage
, self
).__init
__(
26 url
='file://endure/indexeddb_app.html',
28 name
='indexeddb_offline')
29 self
.user_agent_type
= 'desktop'
31 def RunNavigateSteps(self
, action_runner
):
32 action_runner
.NavigateToPage(self
)
33 action_runner
.WaitForElement(text
='initialized')
35 def RunEndure(self
, action_runner
):
36 action_runner
.WaitForElement('button[id="online"]:not(disabled)')
37 action_runner
.ClickElement('button[id="online"]:not(disabled)')
38 action_runner
.WaitForElement(
39 element_function
=_CreateXpathFunction('id("state")[text()="online"]'))
41 action_runner
.WaitForElement('button[id="offline"]:not(disabled)')
42 action_runner
.ClickElement('button[id="offline"]:not(disabled)')
43 action_runner
.WaitForElement(
44 element_function
=_CreateXpathFunction('id("state")[text()="offline"]'))
47 class IndexeddbOfflinePageSet(page_set_module
.PageSet
):
49 """ Chrome Endure test for IndexedDB. """
52 super(IndexeddbOfflinePageSet
, self
).__init
__(
53 user_agent_type
='desktop')
55 self
.AddPage(IndexeddbOfflinePage(self
))