OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import pyauto_functional | 6 import pyauto_functional |
7 import pyauto | 7 import pyauto |
8 | 8 |
9 | 9 |
10 class IndexedDBTest(pyauto.PyUITest): | 10 class IndexedDBTest(pyauto.PyUITest): |
11 """Test of IndexedDB.""" | 11 """Test of IndexedDB.""" |
12 | 12 |
13 def _CrashBrowser(self): | 13 def _CrashBrowser(self): |
14 """Crashes the browser by navigating to special URL""" | 14 """Crashes the browser by navigating to special URL""" |
15 crash_url = 'about:inducebrowsercrashforrealz' | 15 crash_url = 'about:inducebrowsercrashforrealz' |
16 self.NavigateToURL(crash_url) | 16 self.NavigateToURL(crash_url) |
17 | 17 |
18 def _GetTestResult(self): | |
19 """Returns the result of an asynchronous test""" | |
20 js = """ | |
21 window.domAutomationController.send(window.testResult); | |
22 """ | |
23 return self.ExecuteJavascript(js) | |
24 | |
25 def _WaitForTestResult(self): | |
26 """Waits until a non-empty asynchronous test result is recorded""" | |
27 self.assertTrue(self.WaitUntil(lambda: self._GetTestResult() != '', | |
28 timeout=120), | |
29 msg='Test did not finish') | |
30 | |
31 def testIndexedDBNullKeyPathPersistence(self): | 18 def testIndexedDBNullKeyPathPersistence(self): |
32 """Verify null key path persists after restarting browser.""" | 19 """Verify null key path persists after restarting browser.""" |
33 | 20 |
34 url = self.GetHttpURLForDataPath('indexeddb', 'bug_90635.html') | 21 url = self.GetHttpURLForDataPath('indexeddb', 'bug_90635.html') |
35 | 22 |
36 self.NavigateToURL(url) | 23 self.NavigateToURL(url + '#part1') |
37 self._WaitForTestResult() | 24 self.assertTrue(self.WaitUntil(self.GetActiveTabTitle, |
38 self.assertEqual(self._GetTestResult(), | 25 expect_retval='pass - first run'), |
39 'pass - first run', | 26 msg='Key paths had unexpected values') |
40 msg='Key paths had unexpected values') | |
41 | 27 |
42 self.RestartBrowser(clear_profile=False) | 28 self.RestartBrowser(clear_profile=False) |
43 | 29 |
44 self.NavigateToURL(url) | 30 self.NavigateToURL(url + '#part2') |
45 self._WaitForTestResult() | 31 self.assertTrue(self.WaitUntil(self.GetActiveTabTitle, |
46 self.assertEqual(self._GetTestResult(), | 32 expect_retval='pass - second run'), |
47 'pass - second run', | |
48 msg='Key paths had unexpected values') | 33 msg='Key paths had unexpected values') |
49 | 34 |
50 def testVersionChangeCrashResilience(self): | 35 def testVersionChangeCrashResilience(self): |
51 """Verify that a VERSION_CHANGE transaction is rolled back | 36 """Verify that a VERSION_CHANGE transaction is rolled back |
52 after a renderer/browser crash""" | 37 after a renderer/browser crash""" |
53 | 38 |
54 url = self.GetHttpURLForDataPath('indexeddb', 'version_change_crash.html') | 39 url = self.GetHttpURLForDataPath('indexeddb', 'version_change_crash.html') |
55 | 40 |
56 self.NavigateToURL(url + '#part1') | 41 self.NavigateToURL(url + '#part1') |
57 self.assertTrue(self.WaitUntil( | 42 self.assertTrue(self.WaitUntil(self.GetActiveTabTitle, |
58 lambda: self._GetTestResult() == 'part1 - complete')) | 43 expect_retval='pass - part1 - complete'), |
| 44 msg='Failed to prepare database') |
59 | 45 |
60 self.RestartBrowser(clear_profile=False) | 46 self.RestartBrowser(clear_profile=False) |
61 | 47 |
62 self.NavigateToURL(url + '#part2') | 48 self.NavigateToURL(url + '#part2') |
63 self.assertTrue(self.WaitUntil( | 49 self.assertTrue(self.WaitUntil(self.GetActiveTabTitle, |
64 lambda: self._GetTestResult() != 'part2 - crash me')) | 50 expect_retval='pass - part2 - crash me'), |
| 51 msg='Failed to start transaction') |
| 52 |
65 self._CrashBrowser() | 53 self._CrashBrowser() |
66 | 54 |
67 self.RestartBrowser(clear_profile=False) | 55 self.RestartBrowser(clear_profile=False) |
68 | 56 |
69 self.NavigateToURL(url + '#part3') | 57 self.NavigateToURL(url + '#part3') |
70 self._WaitForTestResult() | 58 self.assertTrue(self.WaitUntil(self.GetActiveTabTitle, |
71 self.assertEqual(self._GetTestResult(), | 59 expect_retval='pass - part3 - rolled back'), |
72 'part3 - pass', | 60 msg='VERSION_CHANGE not completely aborted') |
73 msg='VERSION_CHANGE not completely aborted') | |
74 | 61 |
75 if __name__ == '__main__': | 62 if __name__ == '__main__': |
76 pyauto_functional.Main() | 63 pyauto_functional.Main() |
OLD | NEW |