OLD | NEW |
1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging | 5 import logging |
6 import tempfile | 6 import tempfile |
7 import time | 7 import time |
8 | 8 |
9 from telemetry.core import exceptions | 9 from telemetry.core import exceptions |
10 from telemetry import decorators | 10 from telemetry import decorators |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 if (window.__one.not_defined === undefined) | 75 if (window.__one.not_defined === undefined) |
76 window.__one = 1; | 76 window.__one = 1; |
77 } | 77 } |
78 setTimeout(buggyReference, 200);""") | 78 setTimeout(buggyReference, 200);""") |
79 self._tab.WaitForJavaScriptCondition( | 79 self._tab.WaitForJavaScriptCondition( |
80 'window.__set_timeout_called === true', timeout=5) | 80 'window.__set_timeout_called === true', timeout=5) |
81 with self.assertRaises(py_utils.TimeoutException) as context: | 81 with self.assertRaises(py_utils.TimeoutException) as context: |
82 self._tab.WaitForJavaScriptCondition( | 82 self._tab.WaitForJavaScriptCondition( |
83 'window.__one === 1', timeout=1) | 83 'window.__one === 1', timeout=1) |
84 self.assertIn( | 84 self.assertIn( |
85 ("(error) :5: Uncaught TypeError: Cannot read property 'not_defined' " | 85 ("(error) :5: Uncaught TypeError: Cannot read property 'not_defined' " |
86 'of undefined\n'), | 86 'of undefined\n'), |
87 context.exception.message) | 87 context.exception.message) |
88 | 88 |
89 @decorators.Enabled('has tabs') | 89 @decorators.Enabled('has tabs') |
90 def testActivateTab(self): | 90 def testActivateTab(self): |
91 py_utils.WaitFor(lambda: _IsDocumentVisible(self._tab), timeout=5) | 91 py_utils.WaitFor(lambda: _IsDocumentVisible(self._tab), timeout=5) |
92 new_tab = self._browser.tabs.New() | 92 new_tab = self._browser.tabs.New() |
93 new_tab.Navigate('about:blank') | 93 new_tab.Navigate('about:blank') |
94 py_utils.WaitFor(lambda: _IsDocumentVisible(new_tab), timeout=5) | 94 py_utils.WaitFor(lambda: _IsDocumentVisible(new_tab), timeout=5) |
95 self.assertFalse(_IsDocumentVisible(self._tab)) | 95 self.assertFalse(_IsDocumentVisible(self._tab)) |
96 self._tab.Activate() | 96 self._tab.Activate() |
97 py_utils.WaitFor(lambda: _IsDocumentVisible(self._tab), timeout=5) | 97 py_utils.WaitFor(lambda: _IsDocumentVisible(self._tab), timeout=5) |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 self.assertIs(None, timeline_model.GetRendererThreadFromTabId(third_tab.id)) | 185 self.assertIs(None, timeline_model.GetRendererThreadFromTabId(third_tab.id)) |
186 | 186 |
187 @decorators.Disabled('android') # https://crbug.com/463933 | 187 @decorators.Disabled('android') # https://crbug.com/463933 |
188 def testTabIsAlive(self): | 188 def testTabIsAlive(self): |
189 self.assertEquals(self._tab.url, 'about:blank') | 189 self.assertEquals(self._tab.url, 'about:blank') |
190 self.assertTrue(self._tab.IsAlive()) | 190 self.assertTrue(self._tab.IsAlive()) |
191 | 191 |
192 self._tab.Navigate(self.UrlOfUnittestFile('blank.html')) | 192 self._tab.Navigate(self.UrlOfUnittestFile('blank.html')) |
193 self.assertTrue(self._tab.IsAlive()) | 193 self.assertTrue(self._tab.IsAlive()) |
194 | 194 |
195 self.assertRaises(exceptions.DevtoolsTargetCrashException, | 195 self.assertRaises( |
| 196 exceptions.DevtoolsTargetCrashException, |
196 lambda: self._tab.Navigate(self.UrlOfUnittestFile('chrome://crash'))) | 197 lambda: self._tab.Navigate(self.UrlOfUnittestFile('chrome://crash'))) |
197 self.assertFalse(self._tab.IsAlive()) | 198 self.assertFalse(self._tab.IsAlive()) |
198 | 199 |
199 | 200 |
200 class GpuTabTest(tab_test_case.TabTestCase): | 201 class GpuTabTest(tab_test_case.TabTestCase): |
201 @classmethod | 202 @classmethod |
202 def CustomizeBrowserOptions(cls, options): | 203 def CustomizeBrowserOptions(cls, options): |
203 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') | 204 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') |
204 | 205 |
205 # Test flaky on mac: crbug.com/358664, chromeos: crbug.com/483212. | 206 # Test flaky on mac: crbug.com/358664, chromeos: crbug.com/483212. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 self._tab.Navigate(self.UrlOfUnittestFile('cast.html')) | 240 self._tab.Navigate(self.UrlOfUnittestFile('cast.html')) |
240 self._tab.WaitForDocumentReadyStateToBeComplete() | 241 self._tab.WaitForDocumentReadyStateToBeComplete() |
241 self._tab.action_runner.TapElement(selector='#start_session_button') | 242 self._tab.action_runner.TapElement(selector='#start_session_button') |
242 # Wait for media router dialog | 243 # Wait for media router dialog |
243 start_time = time.time() | 244 start_time = time.time() |
244 while (time.time() - start_time < 5 and | 245 while (time.time() - start_time < 5 and |
245 len(self.tabs) != 2): | 246 len(self.tabs) != 2): |
246 time.sleep(1) | 247 time.sleep(1) |
247 self.assertEquals(len(self.tabs), 2) | 248 self.assertEquals(len(self.tabs), 2) |
248 self.assertEquals(self.tabs[1].url, 'chrome://media-router/') | 249 self.assertEquals(self.tabs[1].url, 'chrome://media-router/') |
OLD | NEW |