Commit 3c413c91 authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

Add UseCounter for unknown namespace usage in selectors.

R=chrishtr@chromium.org

Bug: 901938
Change-Id: I9e20fe19f2c97b98f8250c6c9914512b5a73d8c7
Reviewed-on: https://chromium-review.googlesource.com/c/1318891
Commit-Queue: Anders Ruud <andruud@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606845}
parent 5395d94f
......@@ -2075,6 +2075,7 @@ enum WebFeature {
kUpdateWithoutShippingOptionOnShippingOptionChange = 2623,
kCSSSelectorEmptyWhitespaceOnlyFail = 2624,
kActivatedImplicitRootScroller = 2625,
kCSSUnknownNamespacePrefixInSelector = 2626,
// Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots.
// Also, run update_use_counter_feature_enum.py in
......
......@@ -324,6 +324,7 @@ std::unique_ptr<CSSParserSelector> CSSSelectorParser::ConsumeCompoundSelector(
if (!compound_selector) {
AtomicString namespace_uri = DetermineNamespace(namespace_prefix);
if (namespace_uri.IsNull()) {
context_->Count(WebFeature::kCSSUnknownNamespacePrefixInSelector);
failed_parsing_ = true;
return nullptr;
}
......
......@@ -415,4 +415,27 @@ TEST_F(DeprecationTest, InspectorDisablesDeprecation) {
EXPECT_TRUE(use_counter_.HasRecordedMeasurement(feature));
}
TEST_F(UseCounterTest, CSSUnknownNamespacePrefixInSelector) {
std::unique_ptr<DummyPageHolder> dummy_page_holder =
DummyPageHolder::Create(IntSize(800, 600));
Page::InsertOrdinaryPageForTesting(&dummy_page_holder->GetPage());
Document& document = dummy_page_holder->GetDocument();
WebFeature feature = WebFeature::kCSSUnknownNamespacePrefixInSelector;
EXPECT_FALSE(UseCounter::IsCounted(document, feature));
document.documentElement()->SetInnerHTMLFromString(R"HTML(
<style>
@namespace svg url(http://www.w3.org/2000/svg);
svg|a {}
a {}
</style>
)HTML");
document.View()->UpdateAllLifecyclePhases();
EXPECT_FALSE(UseCounter::IsCounted(document, feature));
document.documentElement()->SetInnerHTMLFromString("<style>foo|a {}</style>");
document.View()->UpdateAllLifecyclePhases();
EXPECT_TRUE(UseCounter::IsCounted(document, feature));
}
} // namespace blink
......@@ -20696,6 +20696,7 @@ Called by update_net_error_codes.py.-->
<int value="2623" label="UpdateWithoutShippingOptionOnShippingOptionChange"/>
<int value="2624" label="CSSSelectorEmptyWhitespaceOnlyFail"/>
<int value="2625" label="ActivatedImplicitRootScroller"/>
<int value="2626" label="CSSUnknownNamespacePrefixInSelector"/>
</enum>
<enum name="FeaturePolicyFeature">
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