OLD | NEW |
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 re | 7 import re |
8 import types | 8 import types |
9 | 9 |
10 import pyauto_functional | 10 import pyauto_functional |
(...skipping 25 matching lines...) Expand all Loading... |
36 """Get info about Flash processes, if any.""" | 36 """Get info about Flash processes, if any.""" |
37 return [x for x in self.GetBrowserInfo()['child_processes'] | 37 return [x for x in self.GetBrowserInfo()['child_processes'] |
38 if x['type'] == self._flash_plugin_type and | 38 if x['type'] == self._flash_plugin_type and |
39 x['name'] == 'Shockwave Flash'] | 39 x['name'] == 'Shockwave Flash'] |
40 | 40 |
41 def testCanLoadFlash(self): | 41 def testCanLoadFlash(self): |
42 """Verify that we can play Flash. | 42 """Verify that we can play Flash. |
43 | 43 |
44 We merely check that the Flash process kicks in. | 44 We merely check that the Flash process kicks in. |
45 """ | 45 """ |
46 flash_url = self.GetFileURLForDataPath('plugin', 'flash.swf') | 46 flash_url = self.GetFileURLForContentDataPath('plugin', 'flash.swf') |
47 self.NavigateToURL(flash_url) | 47 self.NavigateToURL(flash_url) |
48 self._AssertFlashProcessPresent() | 48 self._AssertFlashProcessPresent() |
49 | 49 |
50 def testSingleFlashPluginProcess(self): | 50 def testSingleFlashPluginProcess(self): |
51 """Verify there's only one Flash plugin process shared across all uses.""" | 51 """Verify there's only one Flash plugin process shared across all uses.""" |
52 flash_url = self.GetFileURLForDataPath('plugin', 'flash.swf') | 52 flash_url = self.GetFileURLForContentDataPath('plugin', 'flash.swf') |
53 self.NavigateToURL(flash_url) | 53 self.NavigateToURL(flash_url) |
54 for _ in range(2): | 54 for _ in range(2): |
55 self.AppendTab(pyauto.GURL(flash_url)) | 55 self.AppendTab(pyauto.GURL(flash_url)) |
56 # Open flash in new window. | 56 # Open flash in new window. |
57 self.OpenNewBrowserWindow(True) | 57 self.OpenNewBrowserWindow(True) |
58 self.NavigateToURL(flash_url, 1, 0) | 58 self.NavigateToURL(flash_url, 1, 0) |
59 # Open flash in new incognito window. | 59 # Open flash in new incognito window. |
60 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) | 60 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) |
61 self.NavigateToURL(flash_url, 1, 0) | 61 self.NavigateToURL(flash_url, 1, 0) |
62 # Verify there's only 1 flash process. | 62 # Verify there's only 1 flash process. |
63 self.assertEqual(1, len(self._GetFlashProcessesInfo())) | 63 self.assertEqual(1, len(self._GetFlashProcessesInfo())) |
64 | 64 |
65 def testFlashLoadsAfterKill(self): | 65 def testFlashLoadsAfterKill(self): |
66 """Verify that Flash process reloads after crashing (or being killed).""" | 66 """Verify that Flash process reloads after crashing (or being killed).""" |
67 flash_url = self.GetFileURLForDataPath('plugin', 'flash.swf') | 67 flash_url = self.GetFileURLForContentDataPath('plugin', 'flash.swf') |
68 self.NavigateToURL(flash_url) | 68 self.NavigateToURL(flash_url) |
69 flash_process_id1 = self._GetFlashProcessesInfo()[0]['pid'] | 69 flash_process_id1 = self._GetFlashProcessesInfo()[0]['pid'] |
70 self.Kill(flash_process_id1) | 70 self.Kill(flash_process_id1) |
71 | 71 |
72 def _GotFlashProcess(pid): | 72 def _GotFlashProcess(pid): |
73 flash_processes = self._GetFlashProcessesInfo() | 73 flash_processes = self._GetFlashProcessesInfo() |
74 return len(flash_processes) == 1 and flash_processes[0]['pid'] == pid | 74 return len(flash_processes) == 1 and flash_processes[0]['pid'] == pid |
75 | 75 |
76 self.assertTrue(self.WaitUntil( | 76 self.assertTrue(self.WaitUntil( |
77 lambda: not _GotFlashProcess(flash_process_id1)), | 77 lambda: not _GotFlashProcess(flash_process_id1)), |
(...skipping 11 matching lines...) Expand all Loading... |
89 for mime_type in plugin['mimeTypes']: | 89 for mime_type in plugin['mimeTypes']: |
90 if mime_type['mimeType'] == 'application/x-shockwave-flash': | 90 if mime_type['mimeType'] == 'application/x-shockwave-flash': |
91 return True | 91 return True |
92 return False | 92 return False |
93 self.assertTrue(self.WaitUntil(_GotFlashPluginInfo)) | 93 self.assertTrue(self.WaitUntil(_GotFlashPluginInfo)) |
94 for plugin in self.GetPluginsInfo().Plugins(): | 94 for plugin in self.GetPluginsInfo().Plugins(): |
95 if re.search('Shockwave Flash', plugin['name']): | 95 if re.search('Shockwave Flash', plugin['name']): |
96 self.assertTrue(plugin['enabled']) | 96 self.assertTrue(plugin['enabled']) |
97 # Toggle plugin to disable flash. | 97 # Toggle plugin to disable flash. |
98 self.DisablePlugin(plugin['path']) | 98 self.DisablePlugin(plugin['path']) |
99 flash_url = self.GetFileURLForDataPath('plugin', 'flash.html') | 99 flash_url = self.GetFileURLForContentDataPath('plugin', 'flash.html') |
100 self.NavigateToURL(flash_url) | 100 self.NavigateToURL(flash_url) |
101 # Verify shockwave flash process not present. | 101 # Verify shockwave flash process not present. |
102 self._AssertFlashProcessNotPresent() | 102 self._AssertFlashProcessNotPresent() |
103 | 103 |
104 def testFlashIncognitoMode(self): | 104 def testFlashIncognitoMode(self): |
105 """Verify we can play flash on an incognito window.""" | 105 """Verify we can play flash on an incognito window.""" |
106 # Verify no flash process is currently running | 106 # Verify no flash process is currently running |
107 self._AssertFlashProcessNotPresent() | 107 self._AssertFlashProcessNotPresent() |
108 flash_url = self.GetFileURLForDataPath('plugin', 'flash.swf') | 108 flash_url = self.GetFileURLForContentDataPath('plugin', 'flash.swf') |
109 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) | 109 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) |
110 self.NavigateToURL(flash_url, 1, 0) | 110 self.NavigateToURL(flash_url, 1, 0) |
111 self._AssertFlashProcessPresent() | 111 self._AssertFlashProcessPresent() |
112 | 112 |
113 def testFlashWithMultipleTabs(self): | 113 def testFlashWithMultipleTabs(self): |
114 """Verify we can play flash in multiple tabs.""" | 114 """Verify we can play flash in multiple tabs.""" |
115 flash_url = self.GetFileURLForDataPath('plugin', 'flash.swf') | 115 flash_url = self.GetFileURLForContentDataPath('plugin', 'flash.swf') |
116 # Verify no flash process is currently running | 116 # Verify no flash process is currently running |
117 self._AssertFlashProcessNotPresent() | 117 self._AssertFlashProcessNotPresent() |
118 self.NavigateToURL(flash_url) | 118 self.NavigateToURL(flash_url) |
119 # Open 5 new tabs | 119 # Open 5 new tabs |
120 for _ in range(5): | 120 for _ in range(5): |
121 self.AppendTab(pyauto.GURL(flash_url)) | 121 self.AppendTab(pyauto.GURL(flash_url)) |
122 self._AssertFlashProcessPresent() | 122 self._AssertFlashProcessPresent() |
123 | 123 |
124 | 124 |
125 if __name__ == '__main__': | 125 if __name__ == '__main__': |
126 pyauto_functional.Main() | 126 pyauto_functional.Main() |
OLD | NEW |