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

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

Issue 5290003: Add pyauto tests for HTML5 notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/test/functional
Patch Set: ... Created 10 years, 1 month 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/data/notifications/notification_tester.html ('k') | no next file » | 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/python 1 #!/usr/bin/python
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 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 urllib 7 import urllib
8 8
9 import pyauto_functional 9 import pyauto_functional
10 import pyauto 10 import pyauto
11 11
12 12
13 class NotificationsTest(pyauto.PyUITest): 13 class NotificationsTest(pyauto.PyUITest):
14 """Test of HTML5 desktop notifications.""" 14 """Test of HTML5 desktop notifications."""
15 def __init__(self, methodName='runTest'): 15 def __init__(self, methodName='runTest'):
16 super(NotificationsTest, self).__init__(methodName) 16 super(NotificationsTest, self).__init__(methodName)
17 self.NO_SUCH_URL = 'http://no_such_url_exists/' 17 self.NO_SUCH_URL = 'http://no_such_url_exists/'
18 self.NO_SUCH_URL2 = 'http://no_such_url_exists2/'
19 self.NO_SUCH_URL3 = 'http://no_such_url_exists3/'
18 # Content settings for default notification permission. 20 # Content settings for default notification permission.
19 self.ALLOW_ALL_SETTING = 1 21 self.ALLOW_ALL_SETTING = 1
20 self.DENY_ALL_SETTING = 2 22 self.DENY_ALL_SETTING = 2
21 self.ASK_SETTING = 3 23 self.ASK_SETTING = 3
22 24
23 # HTML page used for notification testing. 25 # HTML page used for notification testing.
24 self.TEST_PAGE_URL = self.GetFileURLForDataPath( 26 self.TEST_PAGE_URL = self.GetFileURLForDataPath(
25 os.path.join('notifications', 'notification_tester.html')) 27 os.path.join('notifications', 'notification_tester.html'))
26 28
27 def Debug(self): 29 def Debug(self):
(...skipping 19 matching lines...) Expand all
47 """Gets the default setting for whether sites are allowed to create 49 """Gets the default setting for whether sites are allowed to create
48 notifications. 50 notifications.
49 """ 51 """
50 return self.GetPrefsInfo().Prefs( 52 return self.GetPrefsInfo().Prefs(
51 pyauto.kDesktopNotificationDefaultContentSetting) 53 pyauto.kDesktopNotificationDefaultContentSetting)
52 54
53 def _GetDeniedOrigins(self): 55 def _GetDeniedOrigins(self):
54 """Gets the list of origins that are explicitly denied to create 56 """Gets the list of origins that are explicitly denied to create
55 notifications. 57 notifications.
56 """ 58 """
57 return self.GetPrefsInfo().Prefs(pyauto.kDesktopNotificationDeniedOrigins) 59 return (self.GetPrefsInfo().Prefs(pyauto.kDesktopNotificationDeniedOrigins)
60 or [])
58 61
59 def _GetAllowedOrigins(self): 62 def _GetAllowedOrigins(self):
60 """Gets the list of origins that are explicitly allowed to create 63 """Gets the list of origins that are explicitly allowed to create
61 notifications. 64 notifications.
62 """ 65 """
63 return self.GetPrefsInfo().Prefs(pyauto.kDesktopNotificationAllowedOrigins) 66 return (self.GetPrefsInfo().Prefs(pyauto.kDesktopNotificationAllowedOrigins)
67 or [])
64 68
65 def _SetAllowedOrigins(self, origins): 69 def _SetAllowedOrigins(self, origins):
66 """Sets the list of allowed origins to the given list. 70 """Sets the list of allowed origins to the given list.
67 71
68 None of the items in the list should be explicitly denied. 72 None of the items in the list should be explicitly denied.
69 """ 73 """
70 return self.SetPrefs(pyauto.kDesktopNotificationAllowedOrigins, origins) 74 return self.SetPrefs(pyauto.kDesktopNotificationAllowedOrigins, origins)
71 75
72 def _SetDeniedOrigins(self, origins): 76 def _SetDeniedOrigins(self, origins):
73 """Sets the list of denied origins to the given list. 77 """Sets the list of denied origins to the given list.
74 78
75 None of the items in the list should be explicitly allowed. 79 None of the items in the list should be explicitly allowed.
76 """ 80 """
77 return self.SetPrefs(pyauto.kDesktopNotificationDeniedOrigins, origins) 81 return self.SetPrefs(pyauto.kDesktopNotificationDeniedOrigins, origins)
78 82
79 def _DenyOrigin(self, new_origin): 83 def _DenyOrigin(self, new_origin):
80 """Denies the given origin to create notifications. 84 """Denies the given origin to create notifications.
81 85
82 If it was explicitly allowed, that preference is dropped. 86 If it was explicitly allowed, that preference is dropped.
83 """ 87 """
84 self._DropOriginPreference(new_origin) 88 self._DropOriginPreference(new_origin)
85 denied = self._GetDeniedOrigins() or [] 89 denied = self._GetDeniedOrigins()
86 if new_origin not in denied: 90 if new_origin not in denied:
87 self._SetDeniedOrigins(denied + [new_origin]) 91 self._SetDeniedOrigins(denied + [new_origin])
88 92
89 def _AllowOrigin(self, new_origin): 93 def _AllowOrigin(self, new_origin):
90 """Allows the given origin to create notifications. If it was explicitly 94 """Allows the given origin to create notifications. If it was explicitly
91 denied, that preference is dropped. 95 denied, that preference is dropped.
92 """ 96 """
93 self._DropOriginPreference(new_origin) 97 self._DropOriginPreference(new_origin)
94 allowed = self._GetAllowedOrigins() or [] 98 allowed = self._GetAllowedOrigins()
95 if new_origin not in allowed: 99 if new_origin not in allowed:
96 self._SetAllowedOrigins(allowed + [new_origin]) 100 self._SetAllowedOrigins(allowed + [new_origin])
97 101
98 def _DropOriginPreference(self, new_origin): 102 def _DropOriginPreference(self, new_origin):
99 """Drops the preference as to whether this origin should be allowed to 103 """Drops the preference as to whether this origin should be allowed to
100 create notifications. If it was explicitly allowed or explicitly denied, 104 create notifications. If it was explicitly allowed or explicitly denied,
101 that preference is removed. 105 that preference is removed.
102 """ 106 """
103 allowed = self._GetAllowedOrigins() 107 allowed = self._GetAllowedOrigins()
104 if allowed and new_origin in allowed: 108 if allowed and new_origin in allowed:
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 img_url: url of a image to use; can be a data url 151 img_url: url of a image to use; can be a data url
148 title: title of the notification 152 title: title of the notification
149 text: text in the notification 153 text: text in the notification
150 replace_id: id string to be used for this notification. If another 154 replace_id: id string to be used for this notification. If another
151 notification is shown with the same replace_id, the former 155 notification is shown with the same replace_id, the former
152 will be replaced. 156 will be replaced.
153 tab_index: index of the tab within the given window 157 tab_index: index of the tab within the given window
154 windex: index of the window 158 windex: index of the window
155 """ 159 """
156 return self.CallJavascriptFunc('createNotification', 160 return self.CallJavascriptFunc('createNotification',
157 [img_url, title, text, replace_id], 161 [img_url, title, text, replace_id],
158 tab_index, 162 tab_index,
159 windex); 163 windex);
160 164
161 def _CreateHTMLNotification(self, content_url, replace_id='', tab_index=0, 165 def _CreateHTMLNotification(self, content_url, replace_id='', tab_index=0,
162 windex=0): 166 windex=0):
163 """Creates an HTML notification. 167 """Creates an HTML notification.
164 168
165 Returns the id of the notification, which can be used to cancel it later. 169 Returns the id of the notification, which can be used to cancel it later.
166 170
167 This executes a script in the page which shows a notification. 171 This executes a script in the page which shows a notification.
168 This will only work if the page is navigated to |TEST_PAGE_URL|. 172 This will only work if the page is navigated to |TEST_PAGE_URL|.
169 The page must also have permission to show notifications. 173 The page must also have permission to show notifications.
170 174
171 Args: 175 Args:
172 content_url: url of the page to show in the notification 176 content_url: url of the page to show in the notification
173 replace_id: id string to be used for this notification. If another 177 replace_id: id string to be used for this notification. If another
174 notification is shown with the same replace_id, the former 178 notification is shown with the same replace_id, the former
175 will be replaced. 179 will be replaced.
176 tab_index: index of the tab within the given window 180 tab_index: index of the tab within the given window
177 windex: index of the window 181 windex: index of the window
178 """ 182 """
179 return self.CallJavascriptFunc('createHTMLNotification', 183 return self.CallJavascriptFunc('createHTMLNotification',
180 [content_url, replace_id], 184 [content_url, replace_id],
181 tab_index, 185 tab_index,
182 windex) 186 windex)
183 187
184 def _RequestPermission(self, tab_index=0, windex=0): 188 def _RequestPermission(self, tab_index=0, windex=0):
185 """Requests permission to create notifications. 189 """Requests permission to create notifications.
186 190
187 This will only work if the current page is navigated to |TEST_PAGE_URL|. 191 This will only work if the current page is navigated to |TEST_PAGE_URL|.
188 192
189 Args: 193 Args:
190 tab_index: index of the tab within the given window 194 tab_index: index of the tab within the given window
191 windex: index of the window 195 windex: index of the window
192 """ 196 """
193 self.CallJavascriptFunc('requestPermission', [], windex, tab_index) 197 self.CallJavascriptFunc('requestPermission', [], tab_index, windex)
Nirnimesh 2010/11/24 23:02:59 Use named args whenever possible to avoid these pr
194 198
195 def _CancelNotification(self, notification_id, tab_index=0, windex=0): 199 def _CancelNotification(self, notification_id, tab_index=0, windex=0):
196 """Cancels a notification with the given id. 200 """Cancels a notification with the given id.
197 201
198 This canceling is done in the page that showed that notification and so 202 This canceling is done in the page that showed that notification and so
199 follows a different path than closing a notification via the UI. 203 follows a different path than closing a notification via the UI.
200 204
201 This function should NOT be called until |WaitForNotificationCount| has been 205 This function should NOT be called until |WaitForNotificationCount| has been
202 used to verify the notification is showing. This function cannot be used to 206 used to verify the notification is showing. This function cannot be used to
203 cancel a notification that is in the display queue. 207 cancel a notification that is in the display queue.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 270
267 def testAllowOnPermissionInfobar(self): 271 def testAllowOnPermissionInfobar(self):
268 """Tries to create a notification and clicks allow on the infobar.""" 272 """Tries to create a notification and clicks allow on the infobar."""
269 self.NavigateToURL(self.TEST_PAGE_URL) 273 self.NavigateToURL(self.TEST_PAGE_URL)
270 # This notification should not be shown because we do not have permission. 274 # This notification should not be shown because we do not have permission.
271 self._CreateHTMLNotification(self.NO_SUCH_URL) 275 self._CreateHTMLNotification(self.NO_SUCH_URL)
272 self.assertFalse(self.GetActiveNotifications()) 276 self.assertFalse(self.GetActiveNotifications())
273 277
274 self._RequestPermission() 278 self._RequestPermission()
275 self.assertTrue(self.WaitForInfobarCount(1)) 279 self.assertTrue(self.WaitForInfobarCount(1))
276 self.PerformActionOnInfobar('accept', infobar_index=0) 280 self.PerformActionOnInfobar('accept', 0)
277 self._CreateHTMLNotification(self.NO_SUCH_URL) 281 self._CreateHTMLNotification(self.NO_SUCH_URL)
278 self.WaitForNotificationCount(1) 282 self.WaitForNotificationCount(1)
279 283
280 def testOriginPreferencesBasic(self): 284 def testOriginPreferencesBasic(self):
281 """Tests that we can allow and deny origins.""" 285 """Tests that we can allow and deny origins."""
282 altavista = 'www.altavista.com' 286 altavista = 'www.altavista.com'
283 gmail = 'www.gmail.com' 287 gmail = 'www.gmail.com'
284 yahoo = 'www.yahoo.com' 288 yahoo = 'www.yahoo.com'
285 self._SetDeniedOrigins([altavista, gmail]) 289 self._SetDeniedOrigins([altavista, gmail])
286 self.assertEquals(altavista, self._GetDeniedOrigins()[0]) 290 self.assertEquals(altavista, self._GetDeniedOrigins()[0])
(...skipping 19 matching lines...) Expand all
306 self.assertEquals(3, len(self._GetAllowedOrigins())) 310 self.assertEquals(3, len(self._GetAllowedOrigins()))
307 self._DropOriginPreference(gmail) 311 self._DropOriginPreference(gmail)
308 self.assertEquals(2, len(self._GetAllowedOrigins())) 312 self.assertEquals(2, len(self._GetAllowedOrigins()))
309 self.assertFalse(gmail in self._GetAllowedOrigins()) 313 self.assertFalse(gmail in self._GetAllowedOrigins())
310 314
311 self._DenyOrigin(yahoo) 315 self._DenyOrigin(yahoo)
312 self.assertEquals(1, len(self._GetAllowedOrigins())) 316 self.assertEquals(1, len(self._GetAllowedOrigins()))
313 self.assertTrue(yahoo in self._GetDeniedOrigins()) 317 self.assertTrue(yahoo in self._GetDeniedOrigins())
314 self.assertFalse(yahoo in self._GetAllowedOrigins()) 318 self.assertFalse(yahoo in self._GetAllowedOrigins())
315 319
320 def testDenyOnPermissionInfobar (self):
321 """Test that no notification is created when Deny is chosen
322 from permission infobar."""
323 self.NavigateToURL(self.TEST_PAGE_URL)
324 self._RequestPermission()
325 self.assertTrue(self.WaitForInfobarCount(1))
326 self.PerformActionOnInfobar('cancel', 0)
327 self._CreateHTMLNotification(self.NO_SUCH_URL)
328 self.assertFalse(self.GetActiveNotifications())
329 self.assertEquals(['file:///'], self._GetDeniedOrigins())
330
331 def testClosePermissionInfobar(self):
332 """Test that no notification is created when permission
333 infobar is dismissed."""
334 self.NavigateToURL(self.TEST_PAGE_URL)
335 self._RequestPermission()
336 self.assertTrue(self.WaitForInfobarCount(1))
337 self.PerformActionOnInfobar('dismiss', 0)
338 self._CreateHTMLNotification(self.NO_SUCH_URL)
339 self.assertFalse(self.GetActiveNotifications())
340 self.assertFalse(self._GetDeniedOrigins())
341
342 def testNotificationWithPropertyMissing(self):
343 """Test that a notification can be created if one property is missing."""
344 self._AllowAllOrigins()
345 self.NavigateToURL(self.TEST_PAGE_URL)
346 self._CreateSimpleNotification('no_such_file.png', 'My Title', '')
347 self.assertEquals(1, len(self.GetActiveNotifications()))
348 html_data = urllib.unquote(self.GetActiveNotifications()[0]['content_url'])
349 self.assertTrue('no_such_file.png' in html_data)
350 self.assertTrue('My Title' in html_data)
351
352 def testAllowNotificationsFromAllSites(self):
353 """Verify that all domains can be allowed to show notifications."""
354 self._SetDefaultPermissionSetting(self.ALLOW_ALL_SETTING)
355 self.NavigateToURL(self.TEST_PAGE_URL)
356 self._CreateHTMLNotification(self.NO_SUCH_URL)
357 self.assertEquals(1, len(self.GetActiveNotifications()))
358 self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'])
359
360 def testDenyNotificationsFromAllSites(self):
361 """Verify that no domain can show notifications."""
362 self._SetDefaultPermissionSetting(self.DENY_ALL_SETTING)
363 self.NavigateToURL(self.TEST_PAGE_URL)
364 self._CreateHTMLNotification(self.NO_SUCH_URL)
365 self.assertFalse(self.GetActiveNotifications())
366
367 def testDenyDomainAndAllowAll(self):
368 """Verify that denying a domain and allowing all shouldn't show
369 notifications from the denied domain."""
370 self._DenyOrigin('file:///')
371 self._SetDefaultPermissionSetting(self.ALLOW_ALL_SETTING)
372 self.NavigateToURL(self.TEST_PAGE_URL)
373 self._CreateHTMLNotification(self.NO_SUCH_URL)
374 self.assertFalse(self.GetActiveNotifications())
375
376 def testAllowDomainAndDenyAll(self):
377 """Verify that allowing a domain and denying all others should show
378 notifications from the allowed domain."""
379 self._AllowOrigin('file:///')
380 self._SetDefaultPermissionSetting(self.DENY_ALL_SETTING)
381 self.NavigateToURL(self.TEST_PAGE_URL)
382 self._CreateHTMLNotification(self.NO_SUCH_URL)
383 self.assertEquals(1, len(self.GetActiveNotifications()))
384 self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'])
385
386 def testDenyAndThenAllowDomain(self):
387 """Verify that denying and again allowing should show notifications."""
388 self._DenyOrigin('file:///')
389 self.NavigateToURL(self.TEST_PAGE_URL)
390 self._CreateHTMLNotification(self.NO_SUCH_URL)
391 self.assertEquals(len(self.GetActiveNotifications()), 0)
392 self._AllowOrigin('file:///')
393 self._CreateHTMLNotification(self.NO_SUCH_URL)
394 self.assertEquals(1, len(self.GetActiveNotifications()))
395 self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'])
396
397 def testCreateDenyCloseNotifications(self):
398 """Verify able to create, deny, and close the notification."""
399 self._AllowAllOrigins()
400 self.NavigateToURL(self.TEST_PAGE_URL)
401 self._CreateHTMLNotification(self.NO_SUCH_URL)
402 self.assertEquals(1, len(self.GetActiveNotifications()))
403 origin = 'file:///'
404 self._DenyOrigin(origin)
405 self.assertTrue(origin in self._GetDeniedOrigins())
406 self.CloseNotification(0)
407 self.assertEquals(0, len(self.GetActiveNotifications()))
408
409 def testOriginPrefsNotSavedInIncognito(self):
410 """Verify that allow/deny origin preferences are not saved in incognito."""
411 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
412 self.NavigateToURL(self.TEST_PAGE_URL, 1, 0)
413 self._RequestPermission(windex=1)
414 self.assertTrue(self.WaitForInfobarCount(1, windex=1))
415 self.PerformActionOnInfobar('cancel', 0, windex=1)
416
417 self.NavigateToURL(self.TEST_PAGE_URL, 1, 0)
418 self._RequestPermission(windex=1)
419 self.assertTrue(self.WaitForInfobarCount(1, windex=1))
420 self.PerformActionOnInfobar('accept', 0, windex=1)
421 self._CreateHTMLNotification(self.NO_SUCH_URL, windex=1)
422 self.assertEquals(1, len(self.GetActiveNotifications()))
423
424 self.NavigateToURL(self.TEST_PAGE_URL, 1, 0)
425 self._RequestPermission(windex=1)
426 self.assertTrue(self.WaitForInfobarCount(1, windex=1))
427
428 self.assertFalse(self._GetDeniedOrigins())
429 self.assertFalse(self._GetAllowedOrigins())
430
431 def testExitBrowserWithInfobar(self):
432 """Exit the browser window, when the infobar appears."""
433 self.NavigateToURL(self.TEST_PAGE_URL)
434 self._RequestPermission()
435 self.assertTrue(self.WaitForInfobarCount(1))
436
437 def testCrashTabWithPermissionInfobar(self):
438 """Test crashing the tab with permission infobar doesn't crash Chrome."""
439 self.AppendTab(pyauto.GURL(self.NO_SUCH_URL))
440 self.assertTrue(self.ActivateTab(0))
441 self.NavigateToURL(self.TEST_PAGE_URL)
442 self._RequestPermission()
443 self.assertTrue(self.WaitForInfobarCount(1))
444 self.Kill(self.GetBrowserInfo()['windows'][0]['tabs'][0]['renderer_pid'])
445 self.assertTrue(self.IsBrowserRunning())
446
447 def testKillNotificationProcess(self):
448 """Test killing a notification doesn't crash Chrome."""
449 self._AllowAllOrigins()
450 self.NavigateToURL(self.TEST_PAGE_URL)
451 self._CreateHTMLNotification(self.NO_SUCH_URL)
452 self.Kill(self.GetActiveNotifications()[0]['pid'])
453 self.assertTrue(self.IsBrowserRunning())
454 self.WaitForNotificationCount(0)
455
456 def testIncognitoNotification(self):
457 """Test notifications in incognito window."""
458 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
459 self.NavigateToURL(self.TEST_PAGE_URL, 1, 0)
460 self.assertTrue(self.ActivateTab(0, 1))
461 self._RequestPermission(windex=1)
462 self.assertTrue(self.WaitForInfobarCount(1, windex=1))
463 self.PerformActionOnInfobar('accept', infobar_index=0, windex=1)
464 self._CreateHTMLNotification(self.NO_SUCH_URL, windex=1)
465 self.assertEquals(1, len(self.GetActiveNotifications()))
466
467 def testSpecialURLNotification(self):
468 """Test a page cannot create a notification to a chrome: url."""
469 self._AllowAllOrigins()
470 self.NavigateToURL(self.TEST_PAGE_URL)
471 self._CreateHTMLNotification('chrome://extensions/')
472 self._CreateHTMLNotification(self.NO_SUCH_URL)
Nirnimesh 2010/11/24 23:02:59 Why is this line needed?
473 self.assertEquals(1, len(self.GetActiveNotifications()))
474
475 def testCloseTabWithPermissionInfobar(self):
476 """Test that user can close tab when infobar present."""
477 self.AppendTab(pyauto.GURL('about:blank'))
478 self.ActivateTab(0)
479 self.NavigateToURL(self.TEST_PAGE_URL)
480 self._RequestPermission()
481 self.assertTrue(self.WaitForInfobarCount(1))
482 self.GetBrowserWindow(0).GetTab(0).Close(True)
483 self.assertTrue(self.IsBrowserRunning())
484
485 def testNavigateAwayWithPermissionInfobar(self):
486 """Test navigating away when an infobar is present, then trying to create a
487 notification from the same page."""
488 self.AppendTab(pyauto.GURL('about:blank'))
489 self.assertTrue(self.ActivateTab(0))
490 self.NavigateToURL(self.TEST_PAGE_URL)
491 self._RequestPermission()
492 self.assertTrue(self.WaitForInfobarCount(1))
493 self.NavigateToURL(self.TEST_PAGE_URL)
494 self._RequestPermission()
495 self.assertTrue(self.WaitForInfobarCount(1))
496 self.PerformActionOnInfobar('accept', 0)
497 self._CreateHTMLNotification(self.NO_SUCH_URL)
498 self.assertEquals(1, len(self.GetActiveNotifications()))
499
500 def testCrashRendererNotificationRemain(self):
501 """Test crashing renderer does not close or crash notification."""
502 self._AllowAllOrigins()
503 self.AppendTab(pyauto.GURL('about:blank'))
504 self.ActivateTab(0)
505 self.NavigateToURL(self.TEST_PAGE_URL)
506 self._CreateHTMLNotification(self.NO_SUCH_URL)
507 self.assertEquals(1, len(self.GetActiveNotifications()))
508 self.Kill(self.GetBrowserInfo()['windows'][0]['tabs'][0]['renderer_pid'])
509 self.assertTrue(self.IsBrowserRunning())
510 self.assertEquals(1, len(self.GetActiveNotifications()))
511
512 def testNotificationOrderAfterClosingOne(self):
513 """Tests that closing a notification leaves the rest
514 of the notifications in the correct order.
515 """
516 self._AllowAllOrigins()
517 self.NavigateToURL(self.TEST_PAGE_URL)
518 self._CreateHTMLNotification(self.NO_SUCH_URL)
519 self._CreateHTMLNotification(self.NO_SUCH_URL2)
520 self._CreateHTMLNotification(self.NO_SUCH_URL3)
521 self.assertEquals(3, len(self.GetActiveNotifications()))
522 self.CloseNotification(1)
523 self.assertEquals(2, len(self.GetActiveNotifications()))
524 notifications = self.GetActiveNotifications()
525 self.assertEquals(self.NO_SUCH_URL, notifications[0]['content_url'])
526 self.assertEquals(self.NO_SUCH_URL3, notifications[1]['content_url'])
527
528 def testNotificationReplacement(self):
529 """Test that we can replace a notification using the replaceId."""
530 self._AllowAllOrigins()
531 self.NavigateToURL(self.TEST_PAGE_URL)
532 self._CreateHTMLNotification(self.NO_SUCH_URL, 'chat')
533 self.WaitForNotificationCount(1)
534 self._CreateHTMLNotification(self.NO_SUCH_URL2, 'chat')
535 notifications = self.GetActiveNotifications()
536 self.assertEquals(1, len(notifications))
537 self.assertEquals(self.NO_SUCH_URL2, notifications[0]['content_url'])
538
316 539
317 if __name__ == '__main__': 540 if __name__ == '__main__':
318 pyauto_functional.Main() 541 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « chrome/test/data/notifications/notification_tester.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698