It is not safe to use RuntimeEnabledFeatures::Set*Enabled in tests because these settings are not cleaned up between test runs. We should use scoped setters (see: RuntimeEnabledFeaturesTestHelpers.h), or ideally add DCHECKs to prevent this class of bugs entirely.
Better:
TEST_F(LayoutObjectTest, Test1) {
ScopedSlimmingPaintV2ForTest enabler(true);
...
}
Bad:
TEST_F(LayoutObjectTest, Test1) {
RuntimeEnabledFeatures::SetSlimmingPaintV2Enabled(true);
...
}
Here's proof that this is a bad pattern:
TEST_F(LayoutObjectTest, Test1) {
RuntimeEnabledFeatures::SetSlimmingPaintV2Enabled(true);
}
TEST_F(LayoutObjectTest, Test2) {
LOG(ERROR) << RuntimeEnabledFeatures::SlimmingPaintV2Enabled();
}
When run in webkit_unit_tests --gtest_filter=LayoutObjectTest.Test, Test2 will print "1" while it may not expect SPv2 enabled.
Comment 1 by bugdroid1@chromium.org
, Sep 28 2017