OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 logging | 6 import logging |
7 import os | 7 import os |
8 | 8 |
9 import pyauto_functional # Must be imported before pyauto | 9 import pyauto_functional # Must be imported before pyauto |
10 import pyauto | 10 import pyauto |
(...skipping 23 matching lines...) Expand all Loading... |
34 'about:sync': 'chrome://sync-internals', | 34 'about:sync': 'chrome://sync-internals', |
35 'about:sync-internals': 'chrome://sync-internals', | 35 'about:sync-internals': 'chrome://sync-internals', |
36 'about:version': 'chrome://version', | 36 'about:version': 'chrome://version', |
37 } | 37 } |
38 | 38 |
39 special_url_tabs = { | 39 special_url_tabs = { |
40 'chrome://about': { 'title': 'Chrome URLs' }, | 40 'chrome://about': { 'title': 'Chrome URLs' }, |
41 'chrome://appcache-internals': { 'title': 'AppCache Internals' }, | 41 'chrome://appcache-internals': { 'title': 'AppCache Internals' }, |
42 'chrome://blob-internals': { 'title': 'Blob Storage Internals' }, | 42 'chrome://blob-internals': { 'title': 'Blob Storage Internals' }, |
43 'chrome://feedback': {}, | 43 'chrome://feedback': {}, |
44 'chrome://feedback/#0': { 'title': 'Feedback' }, | |
45 'chrome://chrome-urls': { 'title': 'Chrome URLs' }, | 44 'chrome://chrome-urls': { 'title': 'Chrome URLs' }, |
46 'chrome://crashes': { 'title': 'Crashes' }, | 45 'chrome://crashes': { 'title': 'Crashes' }, |
47 'chrome://credits': { 'title': 'Credits' }, | 46 'chrome://credits': { 'title': 'Credits' }, |
48 'chrome://downloads': { 'title': 'Downloads' }, | 47 'chrome://downloads': { 'title': 'Downloads' }, |
49 'chrome://dns': { 'title': 'About DNS' }, | 48 'chrome://dns': { 'title': 'About DNS' }, |
50 'chrome://extensions': { 'title': 'Extensions' }, | 49 'chrome://extensions': { 'title': 'Extensions' }, |
51 'chrome://flags': {}, | 50 'chrome://flags': {}, |
52 'chrome://flash': {}, | 51 'chrome://flash': {}, |
53 'chrome://gpu-internals': {}, | 52 'chrome://gpu-internals': {}, |
54 'chrome://histograms': { 'title': 'About Histograms' }, | 53 'chrome://histograms': { 'title': 'About Histograms' }, |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 scripts for those pages that are expected to do so. Patches which | 265 scripts for those pages that are expected to do so. Patches which |
267 break this test by including new inline javascript are security | 266 break this test by including new inline javascript are security |
268 vulnerabilities and should be reverted.""" | 267 vulnerabilities and should be reverted.""" |
269 tabs = self._GetPlatformSpecialURLTabs() | 268 tabs = self._GetPlatformSpecialURLTabs() |
270 for url, properties in tabs.iteritems(): | 269 for url, properties in tabs.iteritems(): |
271 logging.debug('Testing URL %s.' % url) | 270 logging.debug('Testing URL %s.' % url) |
272 self.NavigateToURL(url) | 271 self.NavigateToURL(url) |
273 expected_title = 'title' in properties and properties['title'] or url | 272 expected_title = 'title' in properties and properties['title'] or url |
274 actual_title = self.GetActiveTabTitle() | 273 actual_title = self.GetActiveTabTitle() |
275 self.assertTrue(self.WaitUntil( | 274 self.assertTrue(self.WaitUntil( |
276 lambda: self.GetActiveTabTitle(), expect_retval=expected_title)) | 275 lambda: self.GetActiveTabTitle(), expect_retval=expected_title), |
| 276 msg='Title did not match for %s. Expected: %s. Got %s' % ( |
| 277 url, expect_retval, self.GetActiveTabTitle())) |
277 include_list = [] | 278 include_list = [] |
278 exclude_list = [] | 279 exclude_list = [] |
279 no_csp = 'CSP' in properties and not properties['CSP'] | 280 no_csp = 'CSP' in properties and not properties['CSP'] |
280 if no_csp: | 281 if no_csp: |
281 exclude_list.extend(['X-WebKit-CSP']) | 282 exclude_list.extend(['X-WebKit-CSP']) |
282 else: | 283 else: |
283 exclude_list.extend(['<script>', 'onclick=', 'onload=', | 284 exclude_list.extend(['<script>', 'onclick=', 'onload=', |
284 'onchange=', 'onsubmit=', 'javascript:']) | 285 'onchange=', 'onsubmit=', 'javascript:']) |
285 if 'includes' in properties: | 286 if 'includes' in properties: |
286 include_list.extend(properties['includes']) | 287 include_list.extend(properties['includes']) |
287 if 'excludes' in properties: | 288 if 'excludes' in properties: |
288 exclude_list.extend(properties['exlcudes']) | 289 exclude_list.extend(properties['exlcudes']) |
289 test_utils.StringContentCheck(self, self.GetTabContents(), | 290 test_utils.StringContentCheck(self, self.GetTabContents(), |
290 include_list, exclude_list) | 291 include_list, exclude_list) |
291 result = self.ExecuteJavascript(""" | 292 result = self.ExecuteJavascript(""" |
292 var r = 'blocked'; | 293 var r = 'blocked'; |
293 var f = 'executed'; | 294 var f = 'executed'; |
294 var s = document.createElement('script'); | 295 var s = document.createElement('script'); |
295 s.textContent = 'r = f'; | 296 s.textContent = 'r = f'; |
296 document.body.appendChild(s); | 297 document.body.appendChild(s); |
297 window.domAutomationController.send(r); | 298 window.domAutomationController.send(r); |
298 """) | 299 """) |
299 logging.debug('has csp %s, result %s.' % (not no_csp, result)) | 300 logging.debug('has csp %s, result %s.' % (not no_csp, result)) |
300 if no_csp: | 301 if no_csp: |
301 self.assertEqual(result, 'executed', | 302 self.assertEqual(result, 'executed', |
302 msg='Got %s for %s' % (result, url)) | 303 msg='Got %s for %s' % (result, url)) |
303 else: | 304 else: |
304 self.assertEqual(result, 'blocked'); | 305 self.assertEqual(result, 'blocked', |
| 306 msg='Got %s for %s' % (result, url)) |
305 | 307 |
306 # Restart browser so that every URL gets a fresh instance. | 308 # Restart browser so that every URL gets a fresh instance. |
307 self.RestartBrowser(clear_profile=False) | 309 self.RestartBrowser(clear_profile=False) |
308 | 310 |
309 def testAboutAppCacheTab(self): | 311 def testAboutAppCacheTab(self): |
310 """Test App Cache tab to confirm about page populates caches.""" | 312 """Test App Cache tab to confirm about page populates caches.""" |
311 self.NavigateToURL('about:appcache-internals') | 313 self.NavigateToURL('about:appcache-internals') |
312 self._VerifyAppCacheInternals() | 314 self._VerifyAppCacheInternals() |
313 self.assertEqual('AppCache Internals', self.GetActiveTabTitle()) | 315 self.assertEqual('AppCache Internals', self.GetActiveTabTitle()) |
314 | 316 |
315 def testAboutDNSTab(self): | 317 def testAboutDNSTab(self): |
316 """Test DNS tab to confirm DNS about page propogates records.""" | 318 """Test DNS tab to confirm DNS about page propogates records.""" |
317 self.NavigateToURL('about:dns') | 319 self.NavigateToURL('about:dns') |
318 self._VerifyAboutDNS() | 320 self._VerifyAboutDNS() |
319 self.assertEqual('About DNS', self.GetActiveTabTitle()) | 321 self.assertEqual('About DNS', self.GetActiveTabTitle()) |
320 | 322 |
321 def testSpecialAcceratorTabs(self): | 323 def testSpecialAcceratorTabs(self): |
322 """Test special tabs created by accelerators.""" | 324 """Test special tabs created by accelerators.""" |
323 for accel, title in self.GetSpecialAcceleratorTabs().iteritems(): | 325 for accel, title in self.GetSpecialAcceleratorTabs().iteritems(): |
324 self.RunCommand(accel) | 326 self.RunCommand(accel) |
325 self.assertTrue(self.WaitUntil( | 327 self.assertTrue(self.WaitUntil( |
326 self.GetActiveTabTitle, expect_retval=title), | 328 self.GetActiveTabTitle, expect_retval=title), |
327 msg='Expected "%s", got "%s"' % (title, self.GetActiveTabTitle())) | 329 msg='Expected "%s", got "%s"' % (title, self.GetActiveTabTitle())) |
328 | 330 |
329 | 331 |
330 if __name__ == '__main__': | 332 if __name__ == '__main__': |
331 pyauto_functional.Main() | 333 pyauto_functional.Main() |
OLD | NEW |