Skip to content

Commit

Permalink
wake-lock: Measure screen wake lock requests without activation
Browse files Browse the repository at this point in the history
This will be used to understand the compatibility impact of adding a
transient activation requirement as proposed in
w3c/screen-wake-lock#351.

Bug: 1370132
Change-Id: Iff35979eef46d640aaf8b8f6a336546c03ff0355
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3928945
Auto-Submit: Reilly Grant <[email protected]>
Reviewed-by: Raphael Kubo Da Costa <[email protected]>
Commit-Queue: Reilly Grant <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1053843}
NOKEYCHECK=True
GitOrigin-RevId: 7d6b065bce749cfa333b506fca5db81245036ec7
  • Loading branch information
reillyeon authored and copybara-github committed Oct 1, 2022
1 parent e32690b commit 92af190
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions blink/public/mojom/use_counter/metrics/web_feature.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -3683,6 +3683,7 @@ enum WebFeature {
kPermissionsPolicyUnload = 4362,
kServiceWorkerSkippedForSubresourceLoad = 4363,
kClientHintsPrefersReducedMotion = 4364,
kWakeLockAcquireScreenLockWithoutActivation = 4365,

// Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots.
Expand Down
8 changes: 8 additions & 0 deletions blink/renderer/modules/wake_lock/wake_lock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ ScriptPromise WakeLock::request(ScriptState* script_state,
"The requesting page is not visible");
return ScriptPromise();
}

// Measure calls without transient activation as proposed in
// https://github.com/w3c/screen-wake-lock/pull/351.
if (type == V8WakeLockType::Enum::kScreen &&
!LocalFrame::HasTransientUserActivation(window->GetFrame())) {
UseCounter::Count(
context, WebFeature::kWakeLockAcquireScreenLockWithoutActivation);
}
}

// 7. Let promise be a new promise.
Expand Down

0 comments on commit 92af190

Please sign in to comment.