| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 import re | |
| 6 | |
| 7 from telemetry.page import page as page_module | |
| 8 from telemetry.page import page_set as page_set_module | |
| 9 | |
| 10 | |
| 11 def _CreateXpathFunction(xpath): | |
| 12 return ('document.evaluate("%s",' | |
| 13 'document,' | |
| 14 'null,' | |
| 15 'XPathResult.FIRST_ORDERED_NODE_TYPE,' | |
| 16 'null)' | |
| 17 '.singleNodeValue' % re.escape(xpath)) | |
| 18 | |
| 19 | |
| 20 class IndexeddbOfflinePage(page_module.Page): | |
| 21 | |
| 22 """ Why: Simulates user input while offline and sync while online. """ | |
| 23 | |
| 24 def __init__(self, page_set): | |
| 25 super(IndexeddbOfflinePage, self).__init__( | |
| 26 url='file://endure/indexeddb_app.html', | |
| 27 page_set=page_set, | |
| 28 name='indexeddb_offline') | |
| 29 self.user_agent_type = 'desktop' | |
| 30 | |
| 31 def RunNavigateSteps(self, action_runner): | |
| 32 action_runner.NavigateToPage(self) | |
| 33 action_runner.WaitForElement(text='initialized') | |
| 34 | |
| 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"]')) | |
| 40 action_runner.Wait(1) | |
| 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"]')) | |
| 45 | |
| 46 | |
| 47 class IndexeddbOfflinePageSet(page_set_module.PageSet): | |
| 48 | |
| 49 """ Chrome Endure test for IndexedDB. """ | |
| 50 | |
| 51 def __init__(self): | |
| 52 super(IndexeddbOfflinePageSet, self).__init__( | |
| 53 user_agent_type='desktop') | |
| 54 | |
| 55 self.AddPage(IndexeddbOfflinePage(self)) | |
| OLD | NEW |