#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/core/css/media_query_evaluator.h"
#include <memory>
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/css/forced_colors.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_sample_test_utils.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_study_settings.h"
#include "third_party/blink/public/common/privacy_budget/identifiable_surface.h"
#include "third_party/blink/public/common/privacy_budget/identifiable_token.h"
#include "third_party/blink/public/common/privacy_budget/scoped_identifiability_test_sample_collector.h"
#include "third_party/blink/renderer/core/css/media_list.h"
#include "third_party/blink/renderer/core/css/media_values.h"
#include "third_party/blink/renderer/core/css/media_values_cached.h"
#include "third_party/blink/renderer/core/css/parser/css_tokenizer.h"
#include "third_party/blink/renderer/core/css/parser/media_query_parser.h"
#include "third_party/blink/renderer/core/css/resolver/media_query_result.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/media_type_names.h"
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "ui/base/ui_base_types.h"
#include "ui/gfx/display_color_spaces.h"
namespace blink {
namespace {
const CSSNumericLiteralValue& WrapDouble(
double value,
CSSPrimitiveValue::UnitType unit_type =
CSSPrimitiveValue::UnitType::kNumber) { … }
MediaQueryExpValue PxValue(double value) { … }
MediaQueryExpValue RatioValue(unsigned numerator, unsigned denominator) { … }
}
struct MediaQueryEvaluatorTestCase { … };
MediaQueryEvaluatorTestCase g_screen_test_cases[] = …;
MediaQueryEvaluatorTestCase g_display_state_test_cases[] = …;
MediaQueryEvaluatorTestCase g_resizable_test_cases[] = …;
MediaQueryEvaluatorTestCase g_monochrome_test_cases[] = …;
MediaQueryEvaluatorTestCase g_viewport_test_cases[] = …;
MediaQueryEvaluatorTestCase g_float_viewport_test_cases[] = …;
MediaQueryEvaluatorTestCase g_float_non_friendly_viewport_test_cases[] = …;
MediaQueryEvaluatorTestCase g_print_test_cases[] = …;
MediaQueryEvaluatorTestCase g_update_with_print_device_test_cases[] = …;
MediaQueryEvaluatorTestCase g_update_with_slow_device_test_cases[] = …;
MediaQueryEvaluatorTestCase g_update_with_fast_device_test_cases[] = …;
MediaQueryEvaluatorTestCase g_forcedcolors_active_cases[] = …;
MediaQueryEvaluatorTestCase g_forcedcolors_none_cases[] = …;
MediaQueryEvaluatorTestCase g_preferscontrast_nopreference_cases[] = …;
MediaQueryEvaluatorTestCase g_preferscontrast_more_cases[] = …;
MediaQueryEvaluatorTestCase g_preferscontrast_less_cases[] = …;
MediaQueryEvaluatorTestCase g_preferscontrast_custom_cases[] = …;
MediaQueryEvaluatorTestCase g_prefersreducedtransparency_nopreference_cases[] = …;
MediaQueryEvaluatorTestCase g_prefersreducedtransparency_reduce_cases[] = …;
MediaQueryEvaluatorTestCase g_navigationcontrols_back_button_cases[] = …;
MediaQueryEvaluatorTestCase g_navigationcontrols_none_cases[] = …;
MediaQueryEvaluatorTestCase g_single_horizontal_viewport_segment_cases[] = …;
MediaQueryEvaluatorTestCase g_double_horizontal_viewport_segment_cases[] = …;
MediaQueryEvaluatorTestCase g_single_vertical_viewport_segment_cases[] = …;
MediaQueryEvaluatorTestCase g_double_vertical_viewport_segment_cases[] = …;
MediaQueryEvaluatorTestCase g_device_posture_none_cases[] = …;
MediaQueryEvaluatorTestCase g_device_posture_folded_cases[] = …;
MediaQueryEvaluatorTestCase g_device_posture_folded_over_cases[] = …;
MediaQueryEvaluatorTestCase g_dynamic_range_standard_cases[] = …;
MediaQueryEvaluatorTestCase g_dynamic_range_high_cases[] = …;
MediaQueryEvaluatorTestCase g_dynamic_range_feature_disabled_cases[] = …;
MediaQueryEvaluatorTestCase g_video_dynamic_range_standard_cases[] = …;
MediaQueryEvaluatorTestCase g_video_dynamic_range_high_cases[] = …;
MediaQueryEvaluatorTestCase g_video_dynamic_range_feature_disabled_cases[] = …;
MediaQueryEvaluatorTestCase g_overflow_with_print_device_test_cases[] = …;
MediaQueryEvaluatorTestCase g_overflow_with_scrollable_device_test_cases[] = …;
MediaQueryEvaluatorTestCase g_invertedcolors_none_cases[] = …;
MediaQueryEvaluatorTestCase g_invertedcolors_inverted_cases[] = …;
MediaQueryEvaluatorTestCase g_scripting_none_cases[] = …;
MediaQueryEvaluatorTestCase g_scripting_initial_only_cases[] = …;
MediaQueryEvaluatorTestCase g_scripting_enabled_cases[] = …;
void TestMQEvaluator(MediaQueryEvaluatorTestCase* test_cases,
const MediaQueryEvaluator* media_query_evaluator,
CSSParserMode mode) { … }
void TestMQEvaluator(MediaQueryEvaluatorTestCase* test_cases,
const MediaQueryEvaluator* media_query_evaluator) { … }
TEST(MediaQueryEvaluatorTest, Cached) { … }
TEST(MediaQueryEvaluatorTest, Dynamic) { … }
TEST(MediaQueryEvaluatorTest, DynamicNoView) { … }
TEST(MediaQueryEvaluatorTest, CachedFloatViewport) { … }
TEST(MediaQueryEvaluatorTest, CachedFloatViewportNonFloatFriendly) { … }
TEST(MediaQueryEvaluatorTest, CachedForcedColors) { … }
TEST(MediaQueryEvaluatorTest, CachedPrefersContrast) { … }
TEST(MediaQueryEvaluatorTest, CachedPrefersReducedTransparency) { … }
TEST(MediaQueryEvaluatorTest, CachedViewportSegments) { … }
TEST(MediaQueryEvaluatorTest, CachedDevicePosture) { … }
TEST(MediaQueryEvaluatorTest, CachedDynamicRange) { … }
TEST(MediaQueryEvaluatorTest, CachedInvertedColors) { … }
TEST(MediaQueryEvaluatorTest, CachedScripting) { … }
TEST(MediaQueryEvaluatorTest, RangedValues) { … }
TEST(MediaQueryEvaluatorTest, ExpNode) { … }
TEST(MediaQueryEvaluatorTest, DependentResults) { … }
TEST(MediaQueryEvaluatorTest, CSSMediaQueries4) { … }
TEST(MediaQueryEvaluatorTest, GeneralEnclosed) { … }
class MediaQueryEvaluatorIdentifiabilityTest : public PageTestBase { … };
TEST_F(MediaQueryEvaluatorIdentifiabilityTest,
MediaFeatureIdentifiableSurfacePrefersReducedMotion) { … }
TEST_F(MediaQueryEvaluatorIdentifiabilityTest,
MediaFeatureIdentifiableSurfacePrefersReducedTransparency) { … }
TEST_F(MediaQueryEvaluatorIdentifiabilityTest,
MediaFeatureIdentifiableSurfaceOrientation) { … }
TEST_F(MediaQueryEvaluatorIdentifiabilityTest,
MediaFeatureIdentifiableSurfaceCollectOnce) { … }
TEST_F(MediaQueryEvaluatorIdentifiabilityTest,
MediaFeatureIdentifiableSurfaceDisplayMode) { … }
TEST_F(MediaQueryEvaluatorIdentifiabilityTest,
MediaFeatureIdentifiableSurfaceDisplayState) { … }
TEST_F(MediaQueryEvaluatorIdentifiabilityTest,
MediaFeatureIdentifiableSurfaceResizable) { … }
TEST_F(MediaQueryEvaluatorIdentifiabilityTest,
MediaFeatureIdentifiableSurfaceForcedColorsHover) { … }
TEST_F(MediaQueryEvaluatorIdentifiabilityTest,
MediaFeatureIdentifiableSurfaceAspectRatioNormalized) { … }
TEST_F(MediaQueryEvaluatorIdentifiabilityTest,
MediaFeatureIdentifiableSurfaceResolution) { … }
TEST_F(MediaQueryEvaluatorIdentifiabilityTest,
MediaFeatureIdentifiableSurfaceInvertedColors) { … }
TEST_F(MediaQueryEvaluatorIdentifiabilityTest,
MediaFeatureIdentifiableSurfaceScripting) { … }
}