OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 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 |
| 4 # found in the LICENSE file. |
| 5 |
| 6 import pyauto_functional |
| 7 import webrtc_test_base |
| 8 |
| 9 |
| 10 class WebrtcBrutalityTest(webrtc_test_base.WebrtcTestBase): |
| 11 """Tests how WebRTC deals with inconvenient reloads, etc.""" |
| 12 |
| 13 def testReloadsAfterGetUserMedia(self): |
| 14 """Tests how we deal with reloads. |
| 15 |
| 16 This test will quickly reload the page after running getUserMedia, which |
| 17 will remove the pending request. This crashed the browser before the fix |
| 18 for crbug.com/135043. |
| 19 |
| 20 The test will make repeated getUserMedia requests with refreshes between |
| 21 them. Sometimes it will click past the bar and then refresh. |
| 22 """ |
| 23 url = self.GetFileURLForDataPath('webrtc', 'webrtc_jsep_test.html') |
| 24 self.NavigateToURL(url) |
| 25 |
| 26 for i in range(1, 100): |
| 27 if i % 10 == 0: |
| 28 self.GetUserMedia(tab_index=0, action='allow') |
| 29 else: |
| 30 self._GetUserMediaWithoutTakingAction(tab_index=0) |
| 31 self.ReloadTab(tab_index=0) |
| 32 |
| 33 def testRepeatedGetUserMediaRequests(self): |
| 34 """Tests how we deal with lots of consecutive getUserMedia requests. |
| 35 |
| 36 The test will alternate unanswered requests with requests that get answered. |
| 37 """ |
| 38 url = self.GetFileURLForDataPath('webrtc', 'webrtc_jsep_test.html') |
| 39 self.NavigateToURL(url) |
| 40 |
| 41 for i in range(1, 100): |
| 42 if i % 10 == 0: |
| 43 self.GetUserMedia(tab_index=0, action='allow') |
| 44 else: |
| 45 self._GetUserMediaWithoutTakingAction(tab_index=0) |
| 46 |
| 47 def testSuccessfulGetUserMediaAndThenReload(self): |
| 48 """Waits for WebRTC to respond, and immediately reloads the tab.""" |
| 49 url = self.GetFileURLForDataPath('webrtc', 'webrtc_jsep_test.html') |
| 50 self.NavigateToURL(url) |
| 51 |
| 52 self.GetUserMedia(tab_index=0, action='allow') |
| 53 self.ReloadTab(tab_index=0) |
| 54 |
| 55 def testClosingTabAfterGetUserMedia(self): |
| 56 """Tests closing the tab right after a getUserMedia call.""" |
| 57 url = self.GetFileURLForDataPath('webrtc', 'webrtc_jsep_test.html') |
| 58 self.NavigateToURL(url) |
| 59 |
| 60 tab = self.GetBrowserWindow(0).GetTab(0) |
| 61 self._GetUserMediaWithoutTakingAction(tab_index=0) |
| 62 tab.Close() |
| 63 |
| 64 def testSuccessfulGetUserMediaAndThenClose(self): |
| 65 """Waits for WebRTC to respond, and closes the tab.""" |
| 66 url = self.GetFileURLForDataPath('webrtc', 'webrtc_jsep_test.html') |
| 67 self.NavigateToURL(url) |
| 68 |
| 69 tab = self.GetBrowserWindow(0).GetTab(0) |
| 70 self.GetUserMedia(tab_index=0, action='allow') |
| 71 tab.Close() |
| 72 |
| 73 def _GetUserMediaWithoutTakingAction(self, tab_index): |
| 74 self.assertEquals('ok-requested', self.ExecuteJavascript( |
| 75 'getUserMedia(true, true)', tab_index=0)) |
| 76 |
| 77 |
| 78 if __name__ == '__main__': |
| 79 pyauto_functional.Main() |
OLD | NEW |