chromium/third_party/blink/renderer/core/html/html_permission_element_test.cc

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

#include "third_party/blink/renderer/core/html/html_permission_element.h"

#include "base/run_loop.h"
#include "base/test/run_until.h"
#include "base/test/scoped_feature_list.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/strings/grit/blink_strings.h"
#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/core/css/properties/css_property.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/document_init.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/geometry/dom_rect.h"
#include "third_party/blink/renderer/core/html/html_iframe_element.h"
#include "third_party/blink/renderer/core/html/html_span_element.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/script/classic_script.h"
#include "third_party/blink/renderer/core/testing/null_execution_context.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/core/testing/sim/sim_request.h"
#include "third_party/blink/renderer/core/testing/sim/sim_test.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/testing_platform_support.h"

namespace blink {

EmbeddedPermissionControlResult;
EmbeddedPermissionRequestDescriptor;
EmbeddedPermissionRequestDescriptorPtr;
PermissionDescriptor;
PermissionDescriptorPtr;
PermissionName;
PermissionObserver;
PermissionService;
MojoPermissionStatus;

namespace {

constexpr char kCameraString[] =;
constexpr char kCameraAllowedString[] =;
constexpr char kMicrophoneString[] =;
constexpr char kMicrophoneAllowedString[] =;
constexpr char kGeolocationString[] =;
constexpr char kGeolocationAllowedString[] =;
constexpr char kCameraMicrophoneString[] =;
constexpr char kCameraMicrophoneAllowedString[] =;

constexpr base::TimeDelta kDefaultTimeout =;
constexpr base::TimeDelta kSmallTimeout =;

class LocalePlatformSupport : public TestingPlatformSupport {};

void NotReachedForPEPCRegistered() {}

}  // namespace

class HTMLPemissionElementTestBase : public PageTestBase {};

TEST_F(HTMLPemissionElementTestBase, SetTypeAttribute) {}

TEST_F(HTMLPemissionElementTestBase, ParsePermissionDescriptorsFromType) {}

// Helper class used to wait until receiving a permission status change event.
class PermissionStatusChangeWaiter : public PermissionObserver {};

class TestPermissionService : public PermissionService {};

class RegistrationWaiter {};

class HTMLPemissionElementTest : public HTMLPemissionElementTestBase {};

// TODO(crbug.com/1315595): remove this class and use
// `SimTest(base::test::TaskEnvironment::TimeSource::MOCK_TIME)` once migration
// to blink_unittests_v2 completes. We then can simply use
// `time_environment()->FastForwardBy()`
class DeferredChecker {};

TEST_F(HTMLPemissionElementTest, InitializeInnerText) {}

// Regression test for crbug.com/341875650, check that a detached layout tree
// permission element doesn't crash the renderer process.
TEST_F(HTMLPemissionElementTest, AfterDetachLayoutTreeCrashTest) {}

TEST_F(HTMLPemissionElementTest, SetInnerTextAfterRegistrationSingleElement) {}

TEST_F(HTMLPemissionElementTest,
       SetInnerTextAfterRegistrationCameraMicrophonePermissions) {}

TEST_F(HTMLPemissionElementTest, StatusChangeSinglePermissionElement) {}

TEST_F(HTMLPemissionElementTest,
       StatusesChangeCameraMicrophonePermissionsElement) {}

class HTMLPemissionElementClickingEnabledTest
    : public HTMLPemissionElementTest {};

TEST_F(HTMLPemissionElementClickingEnabledTest, UnclickableBeforeRegistered) {}

class HTMLPemissionElementSimTest : public SimTest {};

TEST_F(HTMLPemissionElementSimTest, BlockedByPermissionsPolicy) {}

TEST_F(HTMLPemissionElementSimTest, EnableClickingAfterDelay) {}

TEST_F(HTMLPemissionElementSimTest, BadContrastDisablesElement) {}

TEST_F(HTMLPemissionElementSimTest, FontSizeCanDisableElement) {}

class HTMLPemissionElementDispatchValidationEventTest
    : public HTMLPemissionElementSimTest {};

// Test receiving event after registration
TEST_F(HTMLPemissionElementDispatchValidationEventTest, Registration) {}

// Test receiving event after several times disabling (temporarily or
// indefinitely) + enabling a single reason and verify the `isValid` and
// `invalidReason` attrs.
TEST_F(HTMLPemissionElementDispatchValidationEventTest, DisableEnableClicking) {}

// Test restart the timer caused by `DisableClickingTemporarily` or
// `EnableClickingAfterDelay`. And verify that `invalidReason` changing could
// result in an event.
TEST_F(HTMLPemissionElementDispatchValidationEventTest,
       ChangeReasonRestartTimer) {}

// Test receiving event after disabling (temporarily or indefinitely) + enabling
// multiple reasons and verify the `isValid` and `invalidReason` attrs.
TEST_F(HTMLPemissionElementDispatchValidationEventTest,
       DisableEnableClickingDifferentReasons) {}

class HTMLPemissionElementFencedFrameTest : public HTMLPemissionElementSimTest {};

TEST_F(HTMLPemissionElementFencedFrameTest, NotAllowedInFencedFrame) {}

TEST_F(HTMLPemissionElementSimTest, BlockedByMissingFrameAncestorsCSP) {}

class HTMLPemissionElementIntersectionTest
    : public HTMLPemissionElementSimTest {};

TEST_F(HTMLPemissionElementIntersectionTest, IntersectionChanged) {}

TEST_F(HTMLPemissionElementIntersectionTest,
       IntersectionVisibleOverlapsRecentAttachedInterval) {}

TEST_F(HTMLPemissionElementIntersectionTest,
       IntersectionChangedDisableEnableDisable) {}

TEST_F(HTMLPemissionElementIntersectionTest, ContainerDivRotates) {}

TEST_F(HTMLPemissionElementIntersectionTest, ContainerDivOpacity) {}

TEST_F(HTMLPemissionElementIntersectionTest, ContainerDivClipPath) {}

class HTMLPemissionElementLayoutChangeTest
    : public HTMLPemissionElementSimTest {};

TEST_F(HTMLPemissionElementLayoutChangeTest, InvalidatePEPCAfterMove) {}

TEST_F(HTMLPemissionElementLayoutChangeTest, InvalidatePEPCAfterResize) {}

TEST_F(HTMLPemissionElementLayoutChangeTest, InvalidatePEPCAfterMoveContainer) {}

TEST_F(HTMLPemissionElementLayoutChangeTest,
       InvalidatePEPCAfterTransformContainer) {}

TEST_F(HTMLPemissionElementLayoutChangeTest,
       InvalidatePEPCLayoutInAnimationFrameCallback) {}

}  // namespace blink