Skip to content

Commit

Permalink
Add use count on event handler modification/updates detected by SWGS.
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
yoshisatoyanagisawa authored and Chromium LUCI CQ committed Feb 21, 2023
1 parent fff9337 commit 1b79ef0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3792,6 +3792,8 @@ enum WebFeature {
kContentDispositionInSvgUse = 4451,
kSameDocumentCrossOriginInitiator = 4452,
kServiceWorkerFetchHandlerModifiedAfterInitialization = 4453,
kServiceWorkerAddHandlerAfterInitialization = 4468,
kServiceWorkerSetAttributeHandlerAfterInitialization = 4469,

// Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,8 @@ bool ServiceWorkerGlobalScope::AddEventListenerInternal(
this,
WebFeature::kServiceWorkerFetchHandlerUpdateAfterInitialization);
}
UseCounter::Count(this,
WebFeature::kServiceWorkerAddHandlerAfterInitialization);
}
return WorkerGlobalScope::AddEventListenerInternal(event_type, listener,
options);
Expand Down Expand Up @@ -2645,10 +2647,14 @@ bool ServiceWorkerGlobalScope::SetAttributeEventListener(
const AtomicString& event_type,
EventListener* listener) {
// Count the modification of fetch handlers after the initial evaluation.
if (did_evaluate_script_ && event_type == event_type_names::kFetch) {
if (did_evaluate_script_) {
if (event_type == event_type_names::kFetch) {
UseCounter::Count(
this,
WebFeature::kServiceWorkerFetchHandlerModifiedAfterInitialization);
}
UseCounter::Count(
this,
WebFeature::kServiceWorkerFetchHandlerModifiedAfterInitialization);
this, WebFeature::kServiceWorkerSetAttributeHandlerAfterInitialization);
}
return WorkerGlobalScope::SetAttributeEventListener(event_type, listener);
}
Expand Down
3 changes: 3 additions & 0 deletions tools/metrics/histograms/enums.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41969,6 +41969,9 @@ Called by update_use_counter_feature_enum.py.-->
<int value="4452" label="SameDocumentCrossOriginInitiator"/>
<int value="4453"
label="ServiceWorkerFetchHandlerModifiedAfterInitialization"/>
<int value="4468" label="ServiceWorkerAddHandlerAfterInitialization"/>
<int value="4469"
label="ServiceWorkerSetAttributeHandlerAfterInitialization"/>
</enum>

<enum name="FeaturePolicyAllowlistType">
Expand Down

0 comments on commit 1b79ef0

Please sign in to comment.