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

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

Issue 10447117: Unwire the clear on exit preference from the storage systems. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 8 years, 6 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
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 os 6 import os
7 import logging 7 import logging
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 self.assertEquals({u'cookies': 2}, 136 self.assertEquals({u'cookies': 2},
137 self.GetPrefsInfo().Prefs(pyauto.kDefaultContentSettings), 137 self.GetPrefsInfo().Prefs(pyauto.kDefaultContentSettings),
138 msg='Cookie setting did not persist after restarting session.') 138 msg='Cookie setting did not persist after restarting session.')
139 self.assertFalse(self.GetCookie(pyauto.GURL(file_url)), 139 self.assertFalse(self.GetCookie(pyauto.GURL(file_url)),
140 msg='Cookies are not blocked.') 140 msg='Cookies are not blocked.')
141 self.assertFalse(self.GetCookie(pyauto.GURL(http_url)), 141 self.assertFalse(self.GetCookie(pyauto.GURL(http_url)),
142 msg='Cookies are not blocked.') 142 msg='Cookies are not blocked.')
143 self.assertFalse(self.GetCookie(pyauto.GURL(https_url)), 143 self.assertFalse(self.GetCookie(pyauto.GURL(https_url)),
144 msg='Cookies are not blocked.') 144 msg='Cookies are not blocked.')
145 145
146 def testClearCookiesOnEndingSession(self):
147 """Verify that cookies are cleared when the browsing session is closed."""
148
149 # This test fails on ChromeOS because kRestoreOnStartup is ignored and
150 # the startup preference is always "continue where I left off."
151 if self.IsChromeOS():
152 logging.info('Skipping testClearCookiesOnEndingSession on ChromeOS')
153 return
154
155 file_url = self.GetFileURLForDataPath('setcookie.html')
156 self.assertFalse(self.GetCookie(pyauto.GURL(file_url)),
157 msg='There should be no cookies on %s' % file_url)
158
159 # Set the option to clear cookies when the browser session is closed.
160 self.SetPrefs(pyauto.kClearSiteDataOnExit, True)
161
162 self.NavigateToURL(file_url)
163 self.assertEqual('name=Good', self.GetCookie(pyauto.GURL(file_url)),
164 msg='Unable to retrieve the cookie name=Good')
165
166 # Restart and verify that cookie does not persist
167 self.RestartBrowser(clear_profile=False)
168 self.assertFalse(self.GetCookie(pyauto.GURL(file_url)),
169 msg='Cookie persisted after restarting session.')
170
171 def testAllowCookiesUsingExceptions(self): 146 def testAllowCookiesUsingExceptions(self):
172 """Verify that cookies can be allowed and set using exceptions for 147 """Verify that cookies can be allowed and set using exceptions for
173 particular website(s) when all others are blocked.""" 148 particular website(s) when all others are blocked."""
174 http_url = 'http://%s' % self.test_host 149 http_url = 'http://%s' % self.test_host
175 self.assertFalse(self.GetCookie(pyauto.GURL(http_url)), 150 self.assertFalse(self.GetCookie(pyauto.GURL(http_url)),
176 msg='There should be no cookies on %s' % http_url) 151 msg='There should be no cookies on %s' % http_url)
177 152
178 # Set the preference to block all cookies. 153 # Set the preference to block all cookies.
179 self.SetPrefs(pyauto.kDefaultContentSettings, {u'cookies': 2}) 154 self.SetPrefs(pyauto.kDefaultContentSettings, {u'cookies': 2})
180 155
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 # Restart the browser to check that the cookie doesn't persist. 216 # Restart the browser to check that the cookie doesn't persist.
242 # (This fails on ChromeOS because kRestoreOnStartup is ignored and 217 # (This fails on ChromeOS because kRestoreOnStartup is ignored and
243 # the startup preference is always "continue where I left off.") 218 # the startup preference is always "continue where I left off.")
244 if not self.IsChromeOS(): 219 if not self.IsChromeOS():
245 self.RestartBrowser(clear_profile=False) 220 self.RestartBrowser(clear_profile=False)
246 self.assertFalse(self.GetCookie(pyauto.GURL(http_url)), 221 self.assertFalse(self.GetCookie(pyauto.GURL(http_url)),
247 msg='Cookie persisted after restarting session.') 222 msg='Cookie persisted after restarting session.')
248 223
249 if __name__ == '__main__': 224 if __name__ == '__main__':
250 pyauto_functional.Main() 225 pyauto_functional.Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698