Skip to content

Commit 1b79ef0

Browse files
yoshisatoyanagisawaChromium LUCI CQ
authored and
Chromium LUCI CQ
committed
Add use count on event handler modification/updates detected by SWGS.
To understand the effect of whatwg/dom#1161, let me add use counters to count updates of handlers prohibited by this proposal. (cherry picked from commit c49519f) Bug: 1347319 Change-Id: Ic6a19a512222dabca8e52416fdab9629ce9a70ad Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4259225 Commit-Queue: Yoshisato Yanagisawa <[email protected]> Reviewed-by: Kouhei Ueno <[email protected]> Reviewed-by: Minoru Chikamune <[email protected]> Reviewed-by: Shunya Shishido <[email protected]> Cr-Original-Commit-Position: refs/heads/main@{#1106099} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4273346 Auto-Submit: Yoshisato Yanagisawa <[email protected]> Cr-Commit-Position: refs/branch-heads/5563@{#663} Cr-Branched-From: 3ac59a6-refs/heads/main@{#1097615}
1 parent fff9337 commit 1b79ef0

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom

+2
Original file line numberDiff line numberDiff line change
@@ -3792,6 +3792,8 @@ enum WebFeature {
37923792
kContentDispositionInSvgUse = 4451,
37933793
kSameDocumentCrossOriginInitiator = 4452,
37943794
kServiceWorkerFetchHandlerModifiedAfterInitialization = 4453,
3795+
kServiceWorkerAddHandlerAfterInitialization = 4468,
3796+
kServiceWorkerSetAttributeHandlerAfterInitialization = 4469,
37953797

37963798
// Add new features immediately above this line. Don't change assigned
37973799
// numbers of any item, and don't reuse removed slots.

third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc

+9-3
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ bool ServiceWorkerGlobalScope::AddEventListenerInternal(
695695
this,
696696
WebFeature::kServiceWorkerFetchHandlerUpdateAfterInitialization);
697697
}
698+
UseCounter::Count(this,
699+
WebFeature::kServiceWorkerAddHandlerAfterInitialization);
698700
}
699701
return WorkerGlobalScope::AddEventListenerInternal(event_type, listener,
700702
options);
@@ -2645,10 +2647,14 @@ bool ServiceWorkerGlobalScope::SetAttributeEventListener(
26452647
const AtomicString& event_type,
26462648
EventListener* listener) {
26472649
// Count the modification of fetch handlers after the initial evaluation.
2648-
if (did_evaluate_script_ && event_type == event_type_names::kFetch) {
2650+
if (did_evaluate_script_) {
2651+
if (event_type == event_type_names::kFetch) {
2652+
UseCounter::Count(
2653+
this,
2654+
WebFeature::kServiceWorkerFetchHandlerModifiedAfterInitialization);
2655+
}
26492656
UseCounter::Count(
2650-
this,
2651-
WebFeature::kServiceWorkerFetchHandlerModifiedAfterInitialization);
2657+
this, WebFeature::kServiceWorkerSetAttributeHandlerAfterInitialization);
26522658
}
26532659
return WorkerGlobalScope::SetAttributeEventListener(event_type, listener);
26542660
}

tools/metrics/histograms/enums.xml

+3
Original file line numberDiff line numberDiff line change
@@ -41969,6 +41969,9 @@ Called by update_use_counter_feature_enum.py.-->
4196941969
<int value="4452" label="SameDocumentCrossOriginInitiator"/>
4197041970
<int value="4453"
4197141971
label="ServiceWorkerFetchHandlerModifiedAfterInitialization"/>
41972+
<int value="4468" label="ServiceWorkerAddHandlerAfterInitialization"/>
41973+
<int value="4469"
41974+
label="ServiceWorkerSetAttributeHandlerAfterInitialization"/>
4197241975
</enum>
4197341976

4197441977
<enum name="FeaturePolicyAllowlistType">

0 commit comments

Comments
 (0)