Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: chrome/test/functional/special_tabs.py

Issue 10178028: Fix pyauto test: testSpecialURLTab (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add CSP to about:tcmalloc Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/functional/PYAUTO_TESTS ('k') | content/browser/tcmalloc_internals_request_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 # crashes on chromeos=1 on linux, possibly missing real CrOS features. 131 # crashes on chromeos=1 on linux, possibly missing real CrOS features.
132 'chrome://cryptohome': { 'CSP': False}, 132 'chrome://cryptohome': { 'CSP': False},
133 'chrome://mobilesetup': { 'CSP': False }, 133 'chrome://mobilesetup': { 'CSP': False },
134 'chrome://print': { 'CSP': False }, 134 'chrome://print': { 'CSP': False },
135 'chrome://tasks': {}, 135 'chrome://tasks': {},
136 } 136 }
137 137
138 linux_special_url_tabs = { 138 linux_special_url_tabs = {
139 'chrome://linux-proxy-config': { 'title': 'Proxy Configuration Help' }, 139 'chrome://linux-proxy-config': { 'title': 'Proxy Configuration Help' },
140 'chrome://tcmalloc': { 'title': 'About tcmalloc' }, 140 'chrome://tcmalloc': { 'title': 'tcmalloc stats' },
141 'chrome://sandbox': { 'title': 'Sandbox Status' }, 141 'chrome://sandbox': { 'title': 'Sandbox Status' },
142 } 142 }
143 broken_linux_special_url_tabs = {} 143 broken_linux_special_url_tabs = {}
144 144
145 mac_special_url_tabs = { 145 mac_special_url_tabs = {
146 'chrome://settings/languages': { 'title': 'Settings - Languages' }, 146 'chrome://settings/languages': { 'title': 'Settings - Languages' },
147 } 147 }
148 broken_mac_special_url_tabs = {} 148 broken_mac_special_url_tabs = {}
149 149
150 win_special_url_tabs = { 150 win_special_url_tabs = {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 Also ensures they specify content-security-policy and not inline 265 Also ensures they specify content-security-policy and not inline
266 scripts for those pages that are expected to do so. Patches which 266 scripts for those pages that are expected to do so. Patches which
267 break this test by including new inline javascript are security 267 break this test by including new inline javascript are security
268 vulnerabilities and should be reverted.""" 268 vulnerabilities and should be reverted."""
269 tabs = self._GetPlatformSpecialURLTabs() 269 tabs = self._GetPlatformSpecialURLTabs()
270 for url, properties in tabs.iteritems(): 270 for url, properties in tabs.iteritems():
271 logging.debug('Testing URL %s.' % url) 271 logging.debug('Testing URL %s.' % url)
272 self.NavigateToURL(url) 272 self.NavigateToURL(url)
273 expected_title = 'title' in properties and properties['title'] or url 273 expected_title = 'title' in properties and properties['title'] or url
274 actual_title = self.GetActiveTabTitle() 274 actual_title = self.GetActiveTabTitle()
275 self.assertEqual(expected_title, actual_title) 275 self.assertTrue(self.WaitUntil(
276 lambda: self.GetActiveTabTitle(), expect_retval=expected_title))
276 include_list = [] 277 include_list = []
277 exclude_list = [] 278 exclude_list = []
278 no_csp = 'CSP' in properties and not properties['CSP'] 279 no_csp = 'CSP' in properties and not properties['CSP']
279 if no_csp: 280 if no_csp:
280 exclude_list.extend(['X-WebKit-CSP']) 281 exclude_list.extend(['X-WebKit-CSP'])
281 else: 282 else:
282 exclude_list.extend(['<script>', 'onclick=', 'onload=', 283 exclude_list.extend(['<script>', 'onclick=', 'onload=',
283 'onchange=', 'onsubmit=', 'javascript:']) 284 'onchange=', 'onsubmit=', 'javascript:'])
284 if 'includes' in properties: 285 if 'includes' in properties:
285 include_list.extend(properties['includes']) 286 include_list.extend(properties['includes'])
286 if 'excludes' in properties: 287 if 'excludes' in properties:
287 exclude_list.extend(properties['exlcudes']) 288 exclude_list.extend(properties['exlcudes'])
288 test_utils.StringContentCheck(self, self.GetTabContents(), 289 test_utils.StringContentCheck(self, self.GetTabContents(),
289 include_list, exclude_list) 290 include_list, exclude_list)
290 result = self.ExecuteJavascript(""" 291 result = self.ExecuteJavascript("""
291 var r = 'blocked'; 292 var r = 'blocked';
292 var f = 'executed'; 293 var f = 'executed';
293 var s = document.createElement('script'); 294 var s = document.createElement('script');
294 s.textContent = 'r = f'; 295 s.textContent = 'r = f';
295 document.body.appendChild(s); 296 document.body.appendChild(s);
296 window.domAutomationController.send(r); 297 window.domAutomationController.send(r);
297 """) 298 """)
298 logging.debug('has csp %s, result %s.' % (not no_csp, result)) 299 logging.debug('has csp %s, result %s.' % (not no_csp, result))
299 if no_csp: 300 if no_csp:
300 self.assertEqual(result, 'executed', 301 self.assertEqual(result, 'executed',
301 msg='Got %s for %s' % (result, url)) 302 msg='Got %s for %s' % (result, url))
302 else: 303 else:
303 self.assertEqual(result, 'blocked'); 304 self.assertEqual(result, 'blocked');
304 305
306 # Restart browser so that every URL gets a fresh instance.
307 self.RestartBrowser(clear_profile=False)
308
305 def testAboutAppCacheTab(self): 309 def testAboutAppCacheTab(self):
306 """Test App Cache tab to confirm about page populates caches.""" 310 """Test App Cache tab to confirm about page populates caches."""
307 self.NavigateToURL('about:appcache-internals') 311 self.NavigateToURL('about:appcache-internals')
308 self._VerifyAppCacheInternals() 312 self._VerifyAppCacheInternals()
309 self.assertEqual('AppCache Internals', self.GetActiveTabTitle()) 313 self.assertEqual('AppCache Internals', self.GetActiveTabTitle())
310 314
311 def testAboutDNSTab(self): 315 def testAboutDNSTab(self):
312 """Test DNS tab to confirm DNS about page propogates records.""" 316 """Test DNS tab to confirm DNS about page propogates records."""
313 self.NavigateToURL('about:dns') 317 self.NavigateToURL('about:dns')
314 self._VerifyAboutDNS() 318 self._VerifyAboutDNS()
315 self.assertEqual('About DNS', self.GetActiveTabTitle()) 319 self.assertEqual('About DNS', self.GetActiveTabTitle())
316 320
317 def testSpecialAcceratorTabs(self): 321 def testSpecialAcceratorTabs(self):
318 """Test special tabs created by accelerators.""" 322 """Test special tabs created by accelerators."""
319 for accel, title in self.GetSpecialAcceleratorTabs().iteritems(): 323 for accel, title in self.GetSpecialAcceleratorTabs().iteritems():
320 self.RunCommand(accel) 324 self.RunCommand(accel)
321 self.assertTrue(self.WaitUntil( 325 self.assertTrue(self.WaitUntil(
322 self.GetActiveTabTitle, expect_retval=title), 326 self.GetActiveTabTitle, expect_retval=title),
323 msg='Expected "%s", got "%s"' % (title, self.GetActiveTabTitle())) 327 msg='Expected "%s", got "%s"' % (title, self.GetActiveTabTitle()))
324 328
325 329
326 if __name__ == '__main__': 330 if __name__ == '__main__':
327 pyauto_functional.Main() 331 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « chrome/test/functional/PYAUTO_TESTS ('k') | content/browser/tcmalloc_internals_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698