| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/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 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 25 matching lines...) Expand all Loading... |
| 36 'chrome://about': { 'title': 'Chrome URLs' }, | 36 'chrome://about': { 'title': 'Chrome URLs' }, |
| 37 'chrome://appcache-internals': { 'title': 'AppCache Internals' }, | 37 'chrome://appcache-internals': { 'title': 'AppCache Internals' }, |
| 38 'chrome://blob-internals': { 'title': 'Blob Storage Internals' }, | 38 'chrome://blob-internals': { 'title': 'Blob Storage Internals' }, |
| 39 'chrome://bugreport': {}, | 39 'chrome://bugreport': {}, |
| 40 'chrome://bugreport/#0': { 'title': 'Feedback' }, | 40 'chrome://bugreport/#0': { 'title': 'Feedback' }, |
| 41 'chrome://chrome-urls': { 'title': 'Chrome URLs' }, | 41 'chrome://chrome-urls': { 'title': 'Chrome URLs' }, |
| 42 'chrome://crashes': { 'title': 'Crashes' }, | 42 'chrome://crashes': { 'title': 'Crashes' }, |
| 43 'chrome://credits': { 'title': 'Credits', 'CSP': False }, | 43 'chrome://credits': { 'title': 'Credits', 'CSP': False }, |
| 44 'chrome://downloads': { 'title': 'Downloads' }, | 44 'chrome://downloads': { 'title': 'Downloads' }, |
| 45 'chrome://dns': { 'title': 'About DNS' }, | 45 'chrome://dns': { 'title': 'About DNS' }, |
| 46 'chrome://settings/extensionSettings': { 'title': 'Extensions' }, | 46 'chrome://settings/extensions': { 'title': 'Extensions' }, |
| 47 'chrome://flags': {}, | 47 'chrome://flags': {}, |
| 48 'chrome://flash': {}, | 48 'chrome://flash': {}, |
| 49 'chrome://gpu-internals': {}, | 49 'chrome://gpu-internals': {}, |
| 50 'chrome://histograms': { 'title': 'About Histograms' }, | 50 'chrome://histograms': { 'title': 'About Histograms' }, |
| 51 'chrome://history': { 'title': 'History' }, | 51 'chrome://history': { 'title': 'History' }, |
| 52 'chrome://history2': { 'title': 'History' }, | 52 'chrome://history2': { 'title': 'History' }, |
| 53 'chrome://media-internals': { 'title': 'Media Internals' }, | 53 'chrome://media-internals': { 'title': 'Media Internals' }, |
| 54 'chrome://memory-redirect': { 'title': 'About Memory' }, | 54 'chrome://memory-redirect': { 'title': 'About Memory' }, |
| 55 'chrome://net-internals': {}, | 55 'chrome://net-internals': {}, |
| 56 'chrome://net-internals/help.html': {}, | 56 'chrome://net-internals/help.html': {}, |
| 57 'chrome://newtab': { 'title': 'New Tab', 'CSP': False }, | 57 'chrome://newtab': { 'title': 'New Tab', 'CSP': False }, |
| 58 'chrome://plugins': { 'title': 'Plug-ins' }, | 58 'chrome://plugins': { 'title': 'Plug-ins' }, |
| 59 'chrome://sessions': { 'title': 'Sessions' }, | 59 'chrome://sessions': { 'title': 'Sessions' }, |
| 60 'chrome://settings': { 'title': 'Preferences - Basics' }, | 60 'chrome://settings': { 'title': 'Preferences - Basics' }, |
| 61 'chrome://stats': { 'CSP': False }, | 61 'chrome://stats': {}, |
| 62 'chrome://sync': { 'title': 'Sync Internals' }, | 62 'chrome://sync': { 'title': 'Sync Internals' }, |
| 63 'chrome://sync-internals': { 'title': 'Sync Internals' }, | 63 'chrome://sync-internals': { 'title': 'Sync Internals' }, |
| 64 'chrome://tasks': { 'title': 'Task Manager - Chromium' }, | 64 'chrome://tasks': { 'title': 'Task Manager - Chromium' }, |
| 65 'chrome://terms': { 'CSP': False }, | 65 'chrome://terms': {}, |
| 66 'chrome://textfields': { 'title': 'chrome://textfields', 'CSP': False }, | 66 'chrome://textfields': { 'title': 'chrome://textfields', 'CSP': False }, |
| 67 'chrome://version': { 'title': 'About Version' }, | 67 'chrome://version': { 'title': 'About Version' }, |
| 68 'chrome://view-http-cache': {}, | 68 'chrome://view-http-cache': {}, |
| 69 'chrome://workers': { 'title': 'Workers' }, | 69 'chrome://workers': { 'title': 'Workers' }, |
| 70 } | 70 } |
| 71 broken_special_url_tabs = { | 71 broken_special_url_tabs = { |
| 72 # crashed under debug when invoked from location bar (bug 88223). | 72 # crashed under debug when invoked from location bar (bug 88223). |
| 73 'chrome://devtools': { 'CSP': False }, | 73 'chrome://devtools': { 'CSP': False }, |
| 74 | 74 |
| 75 # returns "not available" despite having an URL constant. | 75 # returns "not available" despite having an URL constant. |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 for url, properties in tabs.iteritems(): | 274 for url, properties in tabs.iteritems(): |
| 275 logging.debug('Testing URL %s.' % url) | 275 logging.debug('Testing URL %s.' % url) |
| 276 self.NavigateToURL(url) | 276 self.NavigateToURL(url) |
| 277 expected_title = 'title' in properties and properties['title'] or url | 277 expected_title = 'title' in properties and properties['title'] or url |
| 278 actual_title = self.GetActiveTabTitle() | 278 actual_title = self.GetActiveTabTitle() |
| 279 logging.debug(' %s title was %s (%s)' % | 279 logging.debug(' %s title was %s (%s)' % |
| 280 (url, actual_title, expected_title == actual_title)) | 280 (url, actual_title, expected_title == actual_title)) |
| 281 self.assertEqual(expected_title, actual_title) | 281 self.assertEqual(expected_title, actual_title) |
| 282 include_list = [] | 282 include_list = [] |
| 283 exclude_list = [] | 283 exclude_list = [] |
| 284 if 'CSP' in properties and not properties['CSP']: | 284 no_csp = 'CSP' in properties and not properties['CSP'] |
| 285 if no_csp: |
| 285 exclude_list.extend(['X-WebKit-CSP']) | 286 exclude_list.extend(['X-WebKit-CSP']) |
| 286 else: | 287 else: |
| 287 include_list.extend(['X-WebKit-CSP']) | |
| 288 exclude_list.extend(['<script>', 'onclick=', 'onload=', | 288 exclude_list.extend(['<script>', 'onclick=', 'onload=', |
| 289 'onchange=', 'onsubmit=', 'javascript:']) | 289 'onchange=', 'onsubmit=', 'javascript:']) |
| 290 if 'includes' in properties: | 290 if 'includes' in properties: |
| 291 include_list.extend(properties['includes']) | 291 include_list.extend(properties['includes']) |
| 292 if 'excludes' in properties: | 292 if 'excludes' in properties: |
| 293 exclude_list.extend(properties['exlcudes']) | 293 exclude_list.extend(properties['exlcudes']) |
| 294 test_utils.StringContentCheck(self, self.GetTabContents(), | 294 test_utils.StringContentCheck(self, self.GetTabContents(), |
| 295 include_list, exclude_list) | 295 include_list, exclude_list) |
| 296 result = self.ExecuteJavascript(""" |
| 297 var r = 'blocked'; |
| 298 var f = 'executed'; |
| 299 var s = document.createElement('script'); |
| 300 s.textContent = 'r = f'; |
| 301 document.body.appendChild(s); |
| 302 window.domAutomationController.send(r); |
| 303 """) |
| 304 logging.debug('has csp %s, result %s.' % (not no_csp, result)) |
| 305 if no_csp: |
| 306 self.assertEqual(result, 'executed'); |
| 307 else: |
| 308 self.assertEqual(result, 'blocked'); |
| 296 | 309 |
| 297 def testAboutAppCacheTab(self): | 310 def testAboutAppCacheTab(self): |
| 298 """Test App Cache tab to confirm about page populates caches.""" | 311 """Test App Cache tab to confirm about page populates caches.""" |
| 299 self.NavigateToURL('about:appcache-internals') | 312 self.NavigateToURL('about:appcache-internals') |
| 300 self._VerifyAppCacheInternals() | 313 self._VerifyAppCacheInternals() |
| 301 self.assertEqual('AppCache Internals', self.GetActiveTabTitle()) | 314 self.assertEqual('AppCache Internals', self.GetActiveTabTitle()) |
| 302 | 315 |
| 303 def testAboutDNSTab(self): | 316 def testAboutDNSTab(self): |
| 304 """Test DNS tab to confirm DNS about page propogates records.""" | 317 """Test DNS tab to confirm DNS about page propogates records.""" |
| 305 self.NavigateToURL('about:dns') | 318 self.NavigateToURL('about:dns') |
| 306 self._VerifyAboutDNS() | 319 self._VerifyAboutDNS() |
| 307 self.assertEqual('About DNS', self.GetActiveTabTitle()) | 320 self.assertEqual('About DNS', self.GetActiveTabTitle()) |
| 308 | 321 |
| 309 def testSpecialAcceratorTabs(self): | 322 def testSpecialAcceratorTabs(self): |
| 310 """Test special tabs created by acclerators like IDC_SHOW_HISTORY, | 323 """Test special tabs created by acclerators like IDC_SHOW_HISTORY, |
| 311 IDC_SHOW_DOWNLOADS.""" | 324 IDC_SHOW_DOWNLOADS.""" |
| 312 for accel, title in self.special_accelerator_tabs.iteritems(): | 325 for accel, title in self.special_accelerator_tabs.iteritems(): |
| 313 self.RunCommand(accel) | 326 self.RunCommand(accel) |
| 314 self.assertTrue(self.WaitUntil( | 327 self.assertTrue(self.WaitUntil( |
| 315 self.GetActiveTabTitle, expect_retval=title), | 328 self.GetActiveTabTitle, expect_retval=title), |
| 316 msg='Expected "%s"' % title) | 329 msg='Expected "%s"' % title) |
| 317 | 330 |
| 318 | 331 |
| 319 if __name__ == '__main__': | 332 if __name__ == '__main__': |
| 320 pyauto_functional.Main() | 333 pyauto_functional.Main() |
| OLD | NEW |