15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 57d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "base/basictypes.h" 6a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "base/command_line.h" 77d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#if defined(OS_MACOSX) 87d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "base/mac/mac_util.h" 97d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#endif 10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/stringprintf.h" 11c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "base/win/windows_version.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/extensions/extension_apitest.h" 13c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/browser/extensions/extension_service.h" 142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/extensions/extension_test_message_listener.h" 15c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/browser/extensions/tab_helper.h" 16c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/browser/profiles/profile.h" 17eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "chrome/browser/ui/fullscreen/fullscreen_controller.h" 18c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/common/chrome_switches.h" 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/chrome_version_info.h" 20c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/common/extensions/features/base_feature_provider.h" 21c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/common/extensions/features/complex_feature.h" 22c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/common/extensions/features/simple_feature.h" 23a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)#include "chrome/test/base/test_switches.h" 242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/browser/render_process_host.h" 252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/browser/render_view_host.h" 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/common/content_switches.h" 27f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "extensions/common/feature_switch.h" 283551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "extensions/common/features/feature.h" 291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "ui/compositor/compositor_switches.h" 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace { 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 33c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)const char kExtensionId[] = "ddchlicdkolnonkihahngkmmmjnjlkkf"; 34c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TabCaptureApiTest : public ExtensionApiTest { 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 37c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) TabCaptureApiTest() {} 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 39c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch virtual void SetUp() OVERRIDE { 40c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch // TODO(danakj): The GPU Video Decoder needs real GL bindings. 41c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch // crbug.com/269087 42c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch UseRealGLBindings(); 43c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch 441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // These test should be using OSMesa on CrOS, which would make this 451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // unneeded. 461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // crbug.com/313128 471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#if !defined(OS_CHROMEOS) 481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) UseRealGLContexts(); 491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#endif 501e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 51c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch ExtensionApiTest::SetUp(); 52c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch } 53c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch 54c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) void AddExtensionToCommandLineWhitelist() { 55c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) CommandLine::ForCurrentProcess()->AppendSwitchASCII( 56c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) switches::kWhitelistedExtensionID, kExtensionId); 57c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) } 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 62f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, ApiTests) { 63558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch#if defined(OS_WIN) && defined(USE_ASH) 64558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch // Disable this test in Metro+Ash for now (http://crbug.com/262796). 65a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 66558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch return; 67558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch#endif 68558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch 69c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#if defined(OS_WIN) 70c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // TODO(justinlin): Disabled for WinXP due to timeout issues. 71c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) if (base::win::GetVersion() < base::win::VERSION_VISTA) { 72c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return; 73c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) } 74c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#endif 75c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 76c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) AddExtensionToCommandLineWhitelist(); 772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_TRUE(RunExtensionSubtest("tab_capture/experimental", 782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) "api_tests.html")) << message_; 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 811e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, ApiTestsAudio) { 82c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#if defined(OS_WIN) 83c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // TODO(justinlin): Disabled for WinXP due to timeout issues. 84c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) if (base::win::GetVersion() < base::win::VERSION_VISTA) { 85c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return; 86c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) } 87c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#endif 88c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 89c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) AddExtensionToCommandLineWhitelist(); 902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_TRUE(RunExtensionSubtest("tab_capture/experimental", 912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) "api_tests_audio.html")) << message_; 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 941e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// http://crbug.com/177163 95a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// http://crbug.com/326328 96a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#if (defined(OS_WIN) && !defined(NDEBUG)) || defined(OS_MACOSX) 977d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#define MAYBE_EndToEnd DISABLED_EndToEnd 987d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#else 997d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#define MAYBE_EndToEnd EndToEnd 1007d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#endif 1017d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_EndToEnd) { 1027d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#if defined(OS_WIN) 1037d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) // TODO(justinlin): Disabled for WinXP due to timeout issues. 1047d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) if (base::win::GetVersion() < base::win::VERSION_VISTA) { 1057d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) return; 1067d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) } 1077d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#endif 1087d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 1097d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) AddExtensionToCommandLineWhitelist(); 1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_TRUE(RunExtensionSubtest("tab_capture/experimental", 1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) "end_to_end.html")) << message_; 1122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 114868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// http://crbug.com/177163 115868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#if defined(OS_WIN) && !defined(NDEBUG) 116868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#define MAYBE_GetUserMediaTest DISABLED_GetUserMediaTest 117868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#else 118868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#define MAYBE_GetUserMediaTest GetUserMediaTest 119868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#endif 1202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Test that we can't get tabCapture streams using GetUserMedia directly. 121868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_GetUserMediaTest) { 1222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ExtensionTestMessageListener listener("ready", true); 1232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ASSERT_TRUE(RunExtensionSubtest("tab_capture/experimental", 1252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) "get_user_media_test.html")) << message_; 1262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(listener.WaitUntilSatisfied()); 1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) content::OpenURLParams params(GURL("about:blank"), content::Referrer(), 1302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) NEW_FOREGROUND_TAB, 1312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) content::PAGE_TRANSITION_LINK, false); 1322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) content::WebContents* web_contents = browser()->OpenURL(params); 1332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) content::RenderViewHost* const rvh = web_contents->GetRenderViewHost(); 1352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int render_process_id = rvh->GetProcess()->GetID(); 1362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int routing_id = rvh->GetRoutingID(); 1372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) listener.Reply(base::StringPrintf("%i:%i", render_process_id, routing_id)); 1392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ResultCatcher catcher; 1412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) catcher.RestrictToProfile(browser()->profile()); 1422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 145868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// http://crbug.com/177163 1461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#if defined(OS_WIN) && !defined(NDEBUG) 147868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#define MAYBE_ActiveTabPermission DISABLED_ActiveTabPermission 148868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#else 149868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#define MAYBE_ActiveTabPermission ActiveTabPermission 150868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#endif 151c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Make sure tabCapture.capture only works if the tab has been granted 152c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// permission via an extension icon click or the extension is whitelisted. 153868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_ActiveTabPermission) { 154c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ExtensionTestMessageListener before_open_tab("ready1", true); 155c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ExtensionTestMessageListener before_grant_permission("ready2", true); 156c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ExtensionTestMessageListener before_open_new_tab("ready3", true); 157c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ExtensionTestMessageListener before_whitelist_extension("ready4", true); 158c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 159c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ASSERT_TRUE(RunExtensionSubtest( 160c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) "tab_capture/experimental", "active_tab_permission_test.html")) 161c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) << message_; 162c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 163c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Open a new tab and make sure capture is denied. 164c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_TRUE(before_open_tab.WaitUntilSatisfied()); 165c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) content::OpenURLParams params(GURL("http://google.com"), content::Referrer(), 166c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) NEW_FOREGROUND_TAB, 167c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) content::PAGE_TRANSITION_LINK, false); 168c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) content::WebContents* web_contents = browser()->OpenURL(params); 169c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) before_open_tab.Reply(""); 170c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 171c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Grant permission and make sure capture succeeds. 172c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_TRUE(before_grant_permission.WaitUntilSatisfied()); 173c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ExtensionService* extension_service = 174c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) Profile::FromBrowserContext(web_contents->GetBrowserContext()) 175c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ->GetExtensionService(); 176c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) const extensions::Extension* extension = 177c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) extension_service->GetExtensionById(kExtensionId, false); 178c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) extensions::TabHelper::FromWebContents(web_contents) 179c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ->active_tab_permission_granter()->GrantIfRequested(extension); 180c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) before_grant_permission.Reply(""); 181c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 182c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Open a new tab and make sure capture is denied. 183c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_TRUE(before_open_new_tab.WaitUntilSatisfied()); 184c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) browser()->OpenURL(params); 185c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) before_open_new_tab.Reply(""); 186c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 187c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Add extension to whitelist and make sure capture succeeds. 188c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_TRUE(before_whitelist_extension.WaitUntilSatisfied()); 189c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) AddExtensionToCommandLineWhitelist(); 190c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) before_whitelist_extension.Reply(""); 191c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 192c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ResultCatcher catcher; 193c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) catcher.RestrictToProfile(browser()->profile()); 194c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 195c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 196c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 197eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// http://crbug.com/177163 198eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#if defined(OS_WIN) && !defined(NDEBUG) 199eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#define MAYBE_FullscreenEvents DISABLED_FullscreenEvents 200eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#elif defined(USE_AURA) || defined(OS_MACOSX) 201eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// These don't always fire fullscreen events when run in tests. Tested manually. 202eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#define MAYBE_FullscreenEvents DISABLED_FullscreenEvents 203eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#elif defined(OS_LINUX) 204eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// Flaky to get out of fullscreen in tests. Tested manually. 205eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#define MAYBE_FullscreenEvents DISABLED_FullscreenEvents 206eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#else 207eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#define MAYBE_FullscreenEvents FullscreenEvents 208eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#endif 209eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen MurdochIN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_FullscreenEvents) { 210eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#if defined(OS_WIN) 211eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // TODO(justinlin): Disabled for WinXP due to timeout issues. 212eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch if (base::win::GetVersion() < base::win::VERSION_VISTA) { 213eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch return; 214eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch } 215eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#endif 216eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 217eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch AddExtensionToCommandLineWhitelist(); 218eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 219eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch content::OpenURLParams params(GURL("chrome://version"), 220eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch content::Referrer(), 221eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch CURRENT_TAB, 222eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch content::PAGE_TRANSITION_LINK, false); 223eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch content::WebContents* web_contents = browser()->OpenURL(params); 224eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 225eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch ExtensionTestMessageListener listeners_setup("ready1", true); 226eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch ExtensionTestMessageListener fullscreen_entered("ready2", true); 227eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 228eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch ASSERT_TRUE(RunExtensionSubtest("tab_capture/experimental", 229eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch "fullscreen_test.html")) << message_; 230eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_TRUE(listeners_setup.WaitUntilSatisfied()); 231eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 232eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Toggle fullscreen after setting up listeners. 233eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch browser()->fullscreen_controller()->ToggleFullscreenModeForTab(web_contents, 234eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch true); 235eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch listeners_setup.Reply(""); 236eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 237eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch // Toggle again after JS should have the event. 238eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_TRUE(fullscreen_entered.WaitUntilSatisfied()); 239eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch browser()->fullscreen_controller()->ToggleFullscreenModeForTab(web_contents, 240eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch false); 241eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch fullscreen_entered.Reply(""); 242eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 243eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch ResultCatcher catcher; 244eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch catcher.RestrictToProfile(browser()->profile()); 245eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 246eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch} 247eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 248a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Times out on Win dbg bots: http://crbug.com/177163 249a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// #if defined(OS_WIN) && !defined(NDEBUG) 250a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Times out on all Win bots: http://crbug.com/294431 251a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#if defined(OS_WIN) 252a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#define MAYBE_GrantForChromePages DISABLED_GrantForChromePages 253a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#else 254a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#define MAYBE_GrantForChromePages GrantForChromePages 255a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#endif 256d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// Make sure tabCapture API can be granted for Chrome:// pages. 257a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_GrantForChromePages) { 258d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) ExtensionTestMessageListener before_open_tab("ready1", true); 259d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) ASSERT_TRUE(RunExtensionSubtest("tab_capture/experimental", 260d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) "active_tab_chrome_pages.html")) << message_; 261d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) EXPECT_TRUE(before_open_tab.WaitUntilSatisfied()); 262d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 263d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // Open a tab on a chrome:// page and make sure we can capture. 264d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) content::OpenURLParams params(GURL("chrome://version"), content::Referrer(), 265d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) NEW_FOREGROUND_TAB, 266d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) content::PAGE_TRANSITION_LINK, false); 267d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) content::WebContents* web_contents = browser()->OpenURL(params); 268d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) ExtensionService* extension_service = 269d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) Profile::FromBrowserContext(web_contents->GetBrowserContext()) 270d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) ->GetExtensionService(); 271d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) extensions::TabHelper::FromWebContents(web_contents) 272d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) ->active_tab_permission_granter()->GrantIfRequested( 273d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) extension_service->GetExtensionById(kExtensionId, false)); 274d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) before_open_tab.Reply(""); 275d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 276d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) ResultCatcher catcher; 277d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) catcher.RestrictToProfile(browser()->profile()); 278d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 279d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)} 280d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 281a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#if (defined(OS_WIN) && !defined(NDEBUG)) || defined(OS_MACOSX) 282a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// http://crbug.com/326319 2834e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#define MAYBE_CaptureInSplitIncognitoMode DISABLED_CaptureInSplitIncognitoMode 2844e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#else 2854e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#define MAYBE_CaptureInSplitIncognitoMode CaptureInSplitIncognitoMode 2864e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#endif 2874e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// Test that a tab can be captured in split incognito mode. 2884e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_CaptureInSplitIncognitoMode) { 2894e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) AddExtensionToCommandLineWhitelist(); 2904e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) ASSERT_TRUE(RunExtensionSubtest("tab_capture/experimental", 2914e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) "incognito.html", 2924e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) kFlagEnableIncognito | kFlagUseIncognito)) 2934e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) << message_; 2944e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)} 2951e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 2961e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#if defined(OS_WIN) && !defined(NDEBUG) 2971e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#define MAYBE_Constraints DISABLED_Constraints 2981e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#else 2991e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#define MAYBE_Constraints Constraints 3001e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#endif 3011e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_Constraints) { 3021e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) AddExtensionToCommandLineWhitelist(); 3031e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) ASSERT_TRUE(RunExtensionSubtest("tab_capture/experimental", 3041e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) "constraints.html")) << message_; 3051e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 306