chromium/chrome/browser/ui/test/popup_browsertest.cc

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

#include <string>

#include "base/memory/raw_ptr.h"
#include "build/build_config.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/test/popup_test_base.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "third_party/blink/public/common/features.h"
#include "ui/display/display.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h"

namespace {

// Tests of window placement for popup browser windows.
PopupTest;

// A helper class to wait for the bounds of two widgets to become equal.
class WidgetBoundsEqualWaiter final : public views::WidgetObserver {};

// Ensure `left=0,top=0` popup window feature coordinates are respected.
IN_PROC_BROWSER_TEST_F(PopupTest, OpenLeftAndTopZeroCoordinates) {}

// Ensure popups are opened in the available space of the opener's display.
IN_PROC_BROWSER_TEST_F(PopupTest, OpenClampedToCurrentDisplay) {}

// Ensure popups cannot be moved beyond the available display space by script.
IN_PROC_BROWSER_TEST_F(PopupTest, MoveClampedToCurrentDisplay) {}

// Ensure popups cannot be resized beyond the available display space by script.
IN_PROC_BROWSER_TEST_F(PopupTest, ResizeClampedToCurrentDisplay) {}

// Opens two popups with custom position and size, but one has noopener. They
// should both have the same position and size. http://crbug.com/1011688
IN_PROC_BROWSER_TEST_F(PopupTest, NoopenerPositioning) {}

// Tests for Additional Windowing Controls on popup windows.
// https://chromestatus.com/feature/5201832664629248
// For PWA tests see WebAppFrameToolbarBrowserTest_AdditionalWindowingControls
class PopupTest_AdditionalWindowingControls : public PopupTest {};

// Ensure that moving a popup by moveTo/moveBy generates a `move` event.
// Note: window.moveTo/moveBy API is enabled only for popups and web apps.
IN_PROC_BROWSER_TEST_F(PopupTest_AdditionalWindowingControls,
                       MoveCallFiresMoveEvent) {}

}  // namespace