Commit 0426812f authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Missing RuntimeEnabledFeatures check for media queries.

The shape, forced-colors, and navigation-controls media features were
accepted without a value, even if their runtime flags were disabled.

Bug: 1051617
Change-Id: Ifc3c3976ac5bccc406ff327a120dd364ea674bb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2061253
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarAnders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742151}
parent 2d584bc8
......@@ -207,15 +207,19 @@ static inline bool FeatureWithoutValue(const String& media_feature) {
media_feature == media_feature_names::kResolutionMediaFeature ||
media_feature == media_feature_names::kDisplayModeMediaFeature ||
media_feature == media_feature_names::kScanMediaFeature ||
media_feature == media_feature_names::kShapeMediaFeature ||
(media_feature == media_feature_names::kShapeMediaFeature &&
RuntimeEnabledFeatures::MediaQueryShapeEnabled()) ||
media_feature == media_feature_names::kColorGamutMediaFeature ||
media_feature == media_feature_names::kImmersiveMediaFeature ||
media_feature ==
media_feature_names::kPrefersColorSchemeMediaFeature ||
media_feature ==
media_feature_names::kPrefersReducedMotionMediaFeature ||
media_feature == media_feature_names::kForcedColorsMediaFeature ||
media_feature == media_feature_names::kNavigationControlsMediaFeature;
(media_feature == media_feature_names::kForcedColorsMediaFeature &&
RuntimeEnabledFeatures::ForcedColorsEnabled()) ||
(media_feature ==
media_feature_names::kNavigationControlsMediaFeature &&
RuntimeEnabledFeatures::MediaQueryNavigationControlsEnabled());
}
bool MediaQueryExp::IsViewportDependent() const {
......
......@@ -6,6 +6,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/css/media_list.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
namespace blink {
......@@ -189,4 +190,28 @@ TEST(MediaQuerySetTest, Basic) {
}
}
TEST(MediaQuerySetTest, BehindRuntimeFlag) {
ScopedMediaQueryShapeForTest shape_flag(false);
ScopedForcedColorsForTest forced_colors_flag(false);
ScopedMediaQueryNavigationControlsForTest navigation_controls_flag(false);
// The first string represents the input string, the second string represents
// the output string.
MediaQuerySetTestCase test_cases[] = {
{"(shape)", "not all"},
{"(forced-colors)", "not all"},
{"(navigation-controls)", "not all"},
{"(shape: rect)", "not all"},
{"(forced-colors: none)", "not all"},
{"(navigation-controls: none)", "not all"},
{nullptr, nullptr} // Do not remove the terminator line.
};
for (unsigned i = 0; test_cases[i].input; ++i) {
scoped_refptr<MediaQuerySet> query_set =
MediaQuerySet::Create(test_cases[i].input);
TestMediaQuery(test_cases[i], *query_set);
}
}
} // namespace blink
This is a testharness.js-based test.
PASS Should be parseable in a CSS stylesheet: '(forced-colors)'
FAIL Should be parseable in a CSS stylesheet: '(forced-colors)' assert_true: expected true got false
FAIL Should be parseable in a CSS stylesheet: '(forced-colors: none)' assert_true: expected true got false
FAIL Should be parseable in a CSS stylesheet: '(forced-colors: active)' assert_true: expected true got false
PASS Should not be parseable in a CSS stylesheet: '(forced-colors: 0)'
......@@ -8,7 +8,7 @@ PASS Should not be parseable in a CSS stylesheet: '(forced-colors: 10px)'
PASS Should not be parseable in a CSS stylesheet: '(forced-colors: active 0)'
PASS Should not be parseable in a CSS stylesheet: '(forced-colors: none active)'
PASS Should not be parseable in a CSS stylesheet: '(forced-colors: active/none)'
PASS Should be parseable in JS: '(forced-colors)'
FAIL Should be parseable in JS: '(forced-colors)' assert_true: expected true got false
FAIL Should be parseable in JS: '(forced-colors: none)' assert_true: expected true got false
FAIL Should be parseable in JS: '(forced-colors: active)' assert_true: expected true got false
PASS Should not be parseable in JS: '(forced-colors: 0)'
......
This is a testharness.js-based test.
PASS Should be parseable in a CSS stylesheet: '(navigation-controls)'
FAIL Should be parseable in a CSS stylesheet: '(navigation-controls)' assert_true: expected true got false
FAIL Should be parseable in a CSS stylesheet: '(navigation-controls: none)' assert_true: expected true got false
FAIL Should be parseable in a CSS stylesheet: '(navigation-controls: back-button)' assert_true: expected true got false
PASS Should not be parseable in a CSS stylesheet: '(navigation-controls: none back-button)'
PASS Should not be parseable in a CSS stylesheet: '(navigation-controls: back-button/none)'
PASS Should be parseable in JS: '(navigation-controls)'
FAIL Should be parseable in JS: '(navigation-controls)' assert_true: expected true got false
FAIL Should be parseable in JS: '(navigation-controls: none)' assert_true: expected true got false
FAIL Should be parseable in JS: '(navigation-controls: back-button)' assert_true: expected true got false
PASS Should not be parseable in JS: '(navigation-controls: none back-button)'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment