| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/path_service.h" | 5 #include "base/path_service.h" |
| 6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/apps/app_browsertest_util.h" | 8 #include "chrome/browser/apps/app_browsertest_util.h" |
| 9 #include "chrome/browser/chrome_content_browser_client.h" | 9 #include "chrome/browser/chrome_content_browser_client.h" |
| 10 #include "chrome/browser/prerender/prerender_link_manager.h" | 10 #include "chrome/browser/prerender/prerender_link_manager.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } // namespace | 160 } // namespace |
| 161 | 161 |
| 162 // This class intercepts media access request from the embedder. The request | 162 // This class intercepts media access request from the embedder. The request |
| 163 // should be triggered only if the embedder API (from tests) allows the request | 163 // should be triggered only if the embedder API (from tests) allows the request |
| 164 // in Javascript. | 164 // in Javascript. |
| 165 // We do not issue the actual media request; the fact that the request reached | 165 // We do not issue the actual media request; the fact that the request reached |
| 166 // embedder's WebContents is good enough for our tests. This is also to make | 166 // embedder's WebContents is good enough for our tests. This is also to make |
| 167 // the test run successfully on trybots. | 167 // the test run successfully on trybots. |
| 168 class MockWebContentsDelegate : public content::WebContentsDelegate { | 168 class MockWebContentsDelegate : public content::WebContentsDelegate { |
| 169 public: | 169 public: |
| 170 MockWebContentsDelegate() : requested_(false) {} | 170 MockWebContentsDelegate() |
| 171 : requested_(false), |
| 172 checked_(false) {} |
| 171 virtual ~MockWebContentsDelegate() {} | 173 virtual ~MockWebContentsDelegate() {} |
| 172 | 174 |
| 173 virtual void RequestMediaAccessPermission( | 175 virtual void RequestMediaAccessPermission( |
| 174 content::WebContents* web_contents, | 176 content::WebContents* web_contents, |
| 175 const content::MediaStreamRequest& request, | 177 const content::MediaStreamRequest& request, |
| 176 const content::MediaResponseCallback& callback) OVERRIDE { | 178 const content::MediaResponseCallback& callback) OVERRIDE { |
| 177 requested_ = true; | 179 requested_ = true; |
| 178 if (message_loop_runner_.get()) | 180 if (request_message_loop_runner_.get()) |
| 179 message_loop_runner_->Quit(); | 181 request_message_loop_runner_->Quit(); |
| 180 } | 182 } |
| 181 | 183 |
| 182 void WaitForSetMediaPermission() { | 184 virtual bool CheckMediaAccessPermission( |
| 185 content::WebContents* web_contents, |
| 186 const GURL& security_origin, |
| 187 content::MediaStreamType type) OVERRIDE { |
| 188 checked_ = true; |
| 189 if (check_message_loop_runner_.get()) |
| 190 check_message_loop_runner_->Quit(); |
| 191 return true; |
| 192 } |
| 193 |
| 194 void WaitForRequestMediaPermission() { |
| 183 if (requested_) | 195 if (requested_) |
| 184 return; | 196 return; |
| 185 message_loop_runner_ = new content::MessageLoopRunner; | 197 request_message_loop_runner_ = new content::MessageLoopRunner; |
| 186 message_loop_runner_->Run(); | 198 request_message_loop_runner_->Run(); |
| 199 } |
| 200 |
| 201 void WaitForCheckMediaPermission() { |
| 202 if (checked_) |
| 203 return; |
| 204 check_message_loop_runner_ = new content::MessageLoopRunner; |
| 205 check_message_loop_runner_->Run(); |
| 187 } | 206 } |
| 188 | 207 |
| 189 private: | 208 private: |
| 190 bool requested_; | 209 bool requested_; |
| 191 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 210 bool checked_; |
| 211 scoped_refptr<content::MessageLoopRunner> request_message_loop_runner_; |
| 212 scoped_refptr<content::MessageLoopRunner> check_message_loop_runner_; |
| 192 | 213 |
| 193 DISALLOW_COPY_AND_ASSIGN(MockWebContentsDelegate); | 214 DISALLOW_COPY_AND_ASSIGN(MockWebContentsDelegate); |
| 194 }; | 215 }; |
| 195 | 216 |
| 196 // This class intercepts download request from the guest. | 217 // This class intercepts download request from the guest. |
| 197 class MockDownloadWebContentsDelegate : public content::WebContentsDelegate { | 218 class MockDownloadWebContentsDelegate : public content::WebContentsDelegate { |
| 198 public: | 219 public: |
| 199 explicit MockDownloadWebContentsDelegate( | 220 explicit MockDownloadWebContentsDelegate( |
| 200 content::WebContentsDelegate* orig_delegate) | 221 content::WebContentsDelegate* orig_delegate) |
| 201 : orig_delegate_(orig_delegate), | 222 : orig_delegate_(orig_delegate), |
| (...skipping 1556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1758 | 1779 |
| 1759 ExtensionTestMessageListener done_listener("TEST_PASSED", false); | 1780 ExtensionTestMessageListener done_listener("TEST_PASSED", false); |
| 1760 done_listener.set_failure_message("TEST_FAILED"); | 1781 done_listener.set_failure_message("TEST_FAILED"); |
| 1761 EXPECT_TRUE( | 1782 EXPECT_TRUE( |
| 1762 content::ExecuteScript( | 1783 content::ExecuteScript( |
| 1763 embedder_web_contents, | 1784 embedder_web_contents, |
| 1764 base::StringPrintf("startAllowTest('%s')", | 1785 base::StringPrintf("startAllowTest('%s')", |
| 1765 test_name.c_str()))); | 1786 test_name.c_str()))); |
| 1766 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); | 1787 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); |
| 1767 | 1788 |
| 1768 mock->WaitForSetMediaPermission(); | 1789 mock->WaitForRequestMediaPermission(); |
| 1769 } | 1790 } |
| 1770 | 1791 |
| 1771 IN_PROC_BROWSER_TEST_F(WebViewTest, ContextMenusAPI_Basic) { | 1792 IN_PROC_BROWSER_TEST_F(WebViewTest, ContextMenusAPI_Basic) { |
| 1772 LoadAppWithGuest("web_view/context_menus/basic"); | 1793 LoadAppWithGuest("web_view/context_menus/basic"); |
| 1773 | 1794 |
| 1774 content::WebContents* guest_web_contents = GetGuestWebContents(); | 1795 content::WebContents* guest_web_contents = GetGuestWebContents(); |
| 1775 content::WebContents* embedder = GetEmbedderWebContents(); | 1796 content::WebContents* embedder = GetEmbedderWebContents(); |
| 1776 ASSERT_TRUE(embedder); | 1797 ASSERT_TRUE(embedder); |
| 1777 | 1798 |
| 1778 // 1. Basic property test. | 1799 // 1. Basic property test. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1830 } | 1851 } |
| 1831 | 1852 |
| 1832 IN_PROC_BROWSER_TEST_F(WebViewTest, MediaAccessAPIAllow_TestAllowTwice) { | 1853 IN_PROC_BROWSER_TEST_F(WebViewTest, MediaAccessAPIAllow_TestAllowTwice) { |
| 1833 MediaAccessAPIAllowTestHelper("testAllowTwice"); | 1854 MediaAccessAPIAllowTestHelper("testAllowTwice"); |
| 1834 } | 1855 } |
| 1835 | 1856 |
| 1836 IN_PROC_BROWSER_TEST_F(WebViewTest, MediaAccessAPIAllow_TestAllowAsync) { | 1857 IN_PROC_BROWSER_TEST_F(WebViewTest, MediaAccessAPIAllow_TestAllowAsync) { |
| 1837 MediaAccessAPIAllowTestHelper("testAllowAsync"); | 1858 MediaAccessAPIAllowTestHelper("testAllowAsync"); |
| 1838 } | 1859 } |
| 1839 | 1860 |
| 1861 IN_PROC_BROWSER_TEST_F(WebViewTest, MediaAccessAPIAllow_TestCheck) { |
| 1862 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. |
| 1863 LoadAndLaunchPlatformApp("web_view/media_access/check", "Launched"); |
| 1864 |
| 1865 content::WebContents* embedder_web_contents = GetFirstAppWindowWebContents(); |
| 1866 ASSERT_TRUE(embedder_web_contents); |
| 1867 scoped_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate()); |
| 1868 embedder_web_contents->SetDelegate(mock.get()); |
| 1869 |
| 1870 ExtensionTestMessageListener done_listener("TEST_PASSED", false); |
| 1871 done_listener.set_failure_message("TEST_FAILED"); |
| 1872 EXPECT_TRUE( |
| 1873 content::ExecuteScript( |
| 1874 embedder_web_contents, |
| 1875 base::StringPrintf("startCheckTest('')"))); |
| 1876 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); |
| 1877 |
| 1878 mock->WaitForCheckMediaPermission(); |
| 1879 } |
| 1880 |
| 1840 // Checks that window.screenX/screenY/screenLeft/screenTop works correctly for | 1881 // Checks that window.screenX/screenY/screenLeft/screenTop works correctly for |
| 1841 // guests. | 1882 // guests. |
| 1842 IN_PROC_BROWSER_TEST_F(WebViewTest, ScreenCoordinates) { | 1883 IN_PROC_BROWSER_TEST_F(WebViewTest, ScreenCoordinates) { |
| 1843 ASSERT_TRUE(RunPlatformAppTestWithArg( | 1884 ASSERT_TRUE(RunPlatformAppTestWithArg( |
| 1844 "platform_apps/web_view/common", "screen_coordinates")) | 1885 "platform_apps/web_view/common", "screen_coordinates")) |
| 1845 << message_; | 1886 << message_; |
| 1846 } | 1887 } |
| 1847 | 1888 |
| 1848 #if defined(OS_CHROMEOS) | 1889 #if defined(OS_CHROMEOS) |
| 1849 IN_PROC_BROWSER_TEST_F(WebViewTest, ChromeVoxInjection) { | 1890 IN_PROC_BROWSER_TEST_F(WebViewTest, ChromeVoxInjection) { |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2276 // http://crbug.com/403325 | 2317 // http://crbug.com/403325 |
| 2277 #define MAYBE_WebViewInBackgroundPage \ | 2318 #define MAYBE_WebViewInBackgroundPage \ |
| 2278 DISABLED_WebViewInBackgroundPage | 2319 DISABLED_WebViewInBackgroundPage |
| 2279 #else | 2320 #else |
| 2280 #define MAYBE_WebViewInBackgroundPage WebViewInBackgroundPage | 2321 #define MAYBE_WebViewInBackgroundPage WebViewInBackgroundPage |
| 2281 #endif | 2322 #endif |
| 2282 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_WebViewInBackgroundPage) { | 2323 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_WebViewInBackgroundPage) { |
| 2283 ASSERT_TRUE(RunExtensionTest("platform_apps/web_view/background")) | 2324 ASSERT_TRUE(RunExtensionTest("platform_apps/web_view/background")) |
| 2284 << message_; | 2325 << message_; |
| 2285 } | 2326 } |
| OLD | NEW |