chromium/chrome/browser/window_management/window_management_permission_context_browsertest.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/permissions/permission_request_manager.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/default_handlers.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "ui/display/screen_base.h"

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/shell.h"
#include "ui/display/test/display_manager_test_api.h"  // nogncheck
#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

namespace {

constexpr char kGetScreensScript[] =;

constexpr char kCheckPermissionScript[] =;

// Tests of WindowManagementPermissionContext behavior.
class WindowManagementPermissionContextTest : public InProcessBrowserTest {};

class MultiscreenWindowManagementPermissionContextTest
    : public WindowManagementPermissionContextTest {};

// Tests gesture requirements (a gesture is only needed to prompt the user).
IN_PROC_BROWSER_TEST_F(WindowManagementPermissionContextTest, GestureToPrompt) {}

// TODO(crbug.com/40212482): Test failing on linux-chromeos-chrome.
// TODO(crbug.com/40212443): Test failing on linux.
#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX)
#define MAYBE_DismissAndDeny
#else
#define MAYBE_DismissAndDeny
#endif
// Tests user activation after dimissing and denying the permission request.
IN_PROC_BROWSER_TEST_F(WindowManagementPermissionContextTest,
                       MAYBE_DismissAndDeny) {}

// Tests user activation after accepting the permission request.
IN_PROC_BROWSER_TEST_F(WindowManagementPermissionContextTest, Accept) {}

IN_PROC_BROWSER_TEST_F(WindowManagementPermissionContextTest,
                       IFrameSameOriginAllow) {}

IN_PROC_BROWSER_TEST_F(WindowManagementPermissionContextTest,
                       IFrameCrossOriginDeny) {}

IN_PROC_BROWSER_TEST_F(WindowManagementPermissionContextTest,
                       IFrameCrossOriginExplicitAllow) {}

// TODO(enne): Windows assumes that display::GetScreen() is a ScreenWin
// which is not true here.
#if !BUILDFLAG(IS_WIN)

// Verify that window.screen.isExtended returns true in a same-origin
// iframe without the window management permission policy allowed.
IN_PROC_BROWSER_TEST_F(MultiscreenWindowManagementPermissionContextTest,
                       IsExtendedSameOriginAllow) {}

// Verify that window.screen.isExtended returns false in a cross-origin
// iframe without the window management permission policy allowed.
IN_PROC_BROWSER_TEST_F(MultiscreenWindowManagementPermissionContextTest,
                       IsExtendedCrossOriginDeny) {}

// Verify that window.screen.isExtended returns true in a cross-origin
// iframe with the window management permission policy allowed.
IN_PROC_BROWSER_TEST_F(MultiscreenWindowManagementPermissionContextTest,
                       IsExtendedCrossOriginAllow) {}

#endif  // !BUILDFLAG(IS_WIN)

}  // namespace