Commit a9122713 authored by Mustaq Ahmed's avatar Mustaq Ahmed Committed by Commit Bot

Enable User Activation v2 as RuntimeEnabledFeatures.

The feature was enabled in M72 through content_feature kUserActivationV2, see
crrev.com/c/796938.  This means the RuntimeEnabledFeature gets enabled through
content in general but this is not true for few unit tests.  This CL fixes the
problem with RuntimeEnabledFeature and fixes the affected unit tests.

Bug: 696617
Change-Id: I50c3b22a5dfc6eb145ac00892bb3120b7c02e9ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1689038Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Reviewed-by: default avatarChrome Cunningham <chcunningham@chromium.org>
Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#675791}
parent b52b3433
......@@ -6,10 +6,12 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/feature_list.h"
#include "base/macros.h"
#include "base/optional.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "content/public/common/content_features.h"
#include "extensions/common/api/messaging/message.h"
#include "extensions/common/api/messaging/port_id.h"
#include "extensions/renderer/bindings/api_binding_test.h"
......@@ -225,7 +227,14 @@ TEST_F(GinPortTest, TestPostMessage) {
const char kFunction[] =
"(function(port) { port.postMessage({data: [42]}); })";
blink::WebScopedUserGesture user_gesture(nullptr);
test_post_message(kFunction, port_id, Message(R"({"data":[42]})", true));
// With User Activation v2, the activation state belongs to a (Web)Frame.
// So the missing frame pointer above means we don't expect activation
// below.
bool expect_user_gesture =
!base::FeatureList::IsEnabled(features::kUserActivationV2);
test_post_message(kFunction, port_id,
Message(R"({"data":[42]})", expect_user_gesture));
}
{
......
......@@ -60,6 +60,7 @@
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_local_frame_client.h"
#include "third_party/blink/public/web/web_scoped_user_gesture.h"
#include "third_party/blink/public/web/web_user_gesture_indicator.h"
#include "third_party/blink/public/web/web_view.h"
#include "third_party/blink/public/web/web_widget.h"
#include "url/gurl.h"
......@@ -403,6 +404,8 @@ class WebMediaPlayerImplTest : public testing::Test {
return std::move(surface_layer_bridge_);
}
blink::WebLocalFrame* GetWebLocalFrame() { return web_local_frame_; }
int64_t OnAdjustAllocatedMemory(int64_t delta) {
reported_memory_ += delta;
return 0;
......@@ -1628,22 +1631,19 @@ TEST_F(WebMediaPlayerImplTest, VideoLockedWhenPausedWhenHidden) {
EXPECT_TRUE(IsVideoLockedWhenPausedWhenHidden());
// With a user gesture it does unlock the player.
{
blink::WebScopedUserGesture user_gesture(nullptr);
Play();
EXPECT_FALSE(IsVideoLockedWhenPausedWhenHidden());
}
blink::WebScopedUserGesture user_gesture1(GetWebLocalFrame());
Play();
EXPECT_FALSE(IsVideoLockedWhenPausedWhenHidden());
// Pause without a user gesture doesn't lock the player.
blink::WebUserGestureIndicator::ConsumeUserGesture(GetWebLocalFrame());
Pause();
EXPECT_FALSE(IsVideoLockedWhenPausedWhenHidden());
// With a user gesture, pause does lock the player.
{
blink::WebScopedUserGesture user_gesture(nullptr);
Pause();
EXPECT_TRUE(IsVideoLockedWhenPausedWhenHidden());
}
blink::WebScopedUserGesture user_gesture2(GetWebLocalFrame());
Pause();
EXPECT_TRUE(IsVideoLockedWhenPausedWhenHidden());
// Foregrounding the player unsets the lock.
ForegroundPlayer();
......
......@@ -39,6 +39,9 @@
namespace blink {
TEST(WebUserGestureTokenTest, Basic) {
// UserGestureTokens are meaningless with UAv2.
RuntimeEnabledFeatures::SetUserActivationV2Enabled(false);
WebUserGestureToken token;
{
......
......@@ -611,10 +611,11 @@ TEST_P(AudioContextAutoplayTest,
break;
case AutoplayPolicy::Type::kUserGestureRequired:
GetHistogramTester()->ExpectBucketCount(
kAutoplayMetric, AutoplayStatus::kAutoplayStatusFailed, 1);
kAutoplayMetric, AutoplayStatus::kAutoplayStatusSucceeded, 1);
GetHistogramTester()->ExpectTotalCount(kAutoplayMetric, 1);
GetHistogramTester()->ExpectBucketCount(
kAutoplayCrossOriginMetric, AutoplayStatus::kAutoplayStatusFailed, 1);
kAutoplayCrossOriginMetric, AutoplayStatus::kAutoplayStatusSucceeded,
1);
GetHistogramTester()->ExpectTotalCount(kAutoplayCrossOriginMetric, 1);
break;
case AutoplayPolicy::Type::kDocumentUserActivationRequired:
......
......@@ -1574,6 +1574,7 @@
},
{
name: "UserActivationV2",
status: "stable",
},
{
name: "UserAgentClientHint",
......
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