Closed Bug 1461278 Opened 3 years ago Closed 3 years ago

Print a note to the web console when a web site is using shadow DOM (v1), preffed off by default

Categories

(Core :: DOM: Core & HTML, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla62
Tracking Status
firefox62 --- fixed

People

(Reporter: smaug, Assigned: smaug)

Details

Attachments

(1 file)

Just to ease finding whether a web site is actually using Shadow DOM.


(or need to ask devtools if they have some magic for this already)
To help to detect pages using shadow DOM, let's add this console message for now.
Disabled by default but can be enabled using
dom.webcomponents.shadowdom.report_usage = true

Perhaps you emilio could review this.

I explicitly wanted to have dom_webcomponents_shadowdom_report_usage() call in Element to avoid extra OwnerDoc() access when the pref isn't set.

remote: 
remote: Follow the progress of your build on Treeherder:
remote:   https://treeherder.mozilla.org/#/jobs?repo=try&revision=4ab772bded08d62a9535447259709be6e52fc94f
remote: recorded changegroup in replication log in 0.072s
Attachment #8975632 - Flags: review?(emilio)
Comment on attachment 8975632 [details] [diff] [review]
shadow_report_usage.diff

Review of attachment 8975632 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good, thanks. I guess it's not really worth it to add a test for this. r=me as long as you've tested it manually.

::: dom/base/nsDocument.cpp
@@ +13242,5 @@
> +
> +  nsIDocument* topLevel = GetTopLevelContentDocument();
> +  if (topLevel && !topLevel->mHasReportedShadowDOMUsage) {
> +    topLevel->mHasReportedShadowDOMUsage = true;
> +    nsString uri;

nit: Maybe nsAutoString?
Attachment #8975632 - Flags: review?(emilio) → review+
GetDocumentURI explicitly takes nsString, not nsAString, so I used nsString.
Pushed by opettay@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/887c21926833
Print a note to the web console when a web site is using shadow DOM (v1), preffed off by default, r=emilio
Priority: -- → P2
https://hg.mozilla.org/mozilla-central/rev/887c21926833
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla62
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.