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
3 // found in the LICENSE file.
5 #include "chrome/browser/apps/app_browsertest_util.h"
6 #include "chrome/browser/extensions/extension_test_message_listener.h"
7 #include "chrome/browser/ui/extensions/application_launch.h"
8 #include "chrome/test/base/interactive_test_utils.h"
10 class ExtensionPointerLockTest
: public extensions::PlatformAppBrowserTest
{
12 bool RunExtensionPointerLockTest(const char* app_path
) {
13 ExtensionTestMessageListener
launched_listener("Launched", true);
14 LoadAndLaunchPlatformApp(app_path
);
15 if (!launched_listener
.WaitUntilSatisfied()) {
16 message_
= "Did not get the 'Launched' message.";
20 ResultCatcher catcher
;
22 if (!ui_test_utils::ShowAndFocusNativeWindow(
23 GetFirstShellWindow()->GetNativeWindow())) {
24 message_
= "Can't focus window";
28 launched_listener
.Reply("");
30 if (!catcher
.GetNextResult()) {
31 message_
= catcher
.message();
39 IN_PROC_BROWSER_TEST_F(ExtensionPointerLockTest
,
40 ExtensionPointerLockAccessFail
) {
41 // Test that pointer lock cannot be accessed from an extension without
43 ASSERT_TRUE(RunExtensionPointerLockTest("pointer_lock/no_permission"))
47 IN_PROC_BROWSER_TEST_F(ExtensionPointerLockTest
,
48 ExtensionPointerLockAccessPass
) {
49 // Test that pointer lock can be accessed from an extension with permission.
50 ASSERT_TRUE(RunExtensionPointerLockTest("pointer_lock/has_permission"))