Closed Bug 840476 Opened 12 years ago Closed 12 years ago

Gather telemetry about character encoding (charset) menu use on labeled vs. unlabeled pages

Categories

(Core :: DOM: Navigation, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla22

People

(Reporter: hsivonen, Assigned: hsivonen)

References

Details

Attachments

(1 file, 2 obsolete files)

In order to be able to make informed decisions about gradually retiring the character encoding menu, we should gather telemetry about its use. To mitigate the risk of users being tricked into corrupting properly authored pages, it would be good to make the menu have no effect on pages that explicitly set their encoding. To determine if it's OK to make that change, we should categorize uses of the character encoding menu into two categories: 1) Override was chosen when the top-level page was labeled. 2) Override was chosen when the top-level page was unlabeled.
Hmm. Actually, it would be possible to gather this info even for non-top-level pages in nsHtml5StreamParser and even for other same-origin pages loaded with the override in effect. To measure only the user actions, the telemetry code should probably live in the docshell.
Blocks: 842338
Assignee: nobody → hsivonen
Attached patch Add the probe (obsolete) (deleted) — Splinter Review
(In reply to Henri Sivonen (:hsivonen) from comment #1) > Hmm. Actually, it would be possible to gather this info even for > non-top-level pages in nsHtml5StreamParser and even for other same-origin > pages loaded with the override in effect. Not sure what I was thinking when I wrote that. This patch does what I suggested in comment 0.
Attachment #716474 - Flags: review?(bugs)
Comment on attachment 716474 [details] [diff] [review] Add the probe > NS_IMETHODIMP > nsDocShell::SetCharset(const char* aCharset) > { > // set the default charset > nsCOMPtr<nsIContentViewer> viewer; > GetContentViewer(getter_AddRefs(viewer)); > if (viewer) { >+ >+ nsIDocument* doc = viewer->GetDocument(); >+ MOZ_ASSERT(!doc->WillIgnoreCharsetOverride(), "How come we got here?"); >+ if (doc && !doc->WillIgnoreCharsetOverride()) { Here you have null check for doc, but you don't have that in MOZ_ASSERT. >+ int32_t charsetSource = doc->GetDocumentCharacterSetSource(); >+ switch (charsetSource) { >+ case kCharsetFromWeakDocTypeDefault: >+ case kCharsetFromUserDefault: >+ case kCharsetFromDocTypeDefault: >+ case kCharsetFromCache: >+ case kCharsetFromParentFrame: >+ case kCharsetFromAutoDetection: >+ case kCharsetFromHintPrevDoc: >+ // Changing charset on an unlabeled doc >+ Telemetry::Accumulate(Telemetry::CHARSET_OVERRIDE_SITUATION, 0); >+ break; >+ case kCharsetFromMetaPrescan: >+ case kCharsetFromMetaTag: >+ case kCharsetFromChannel: >+ // Changing charset on a doc that had a charset label >+ Telemetry::Accumulate(Telemetry::CHARSET_OVERRIDE_SITUATION, 1); >+ break; >+ case kCharsetFromParentForced: >+ case kCharsetFromUserForced: >+ // Changing charset on a document that already had an override >+ Telemetry::Accumulate(Telemetry::CHARSET_OVERRIDE_SITUATION, 2); >+ break; >+ case kCharsetFromIrreversibleAutoDetection: >+ case kCharsetFromOtherComponent: >+ case kCharsetFromByteOrderMark: >+ case kCharsetUninitialized: >+ default: >+ MOZ_NOT_REACHED("Should not have come here."); And this is really never ever possible? Since we crash here even on opt builds if this happens, I believe. Perhaps you could use Telemetry::Accumulate(Telemetry::CHARSET_OVERRIDE_SITUATION, 3) for this. (and increase n for telemetry)
Attachment #716474 - Flags: review?(bugs) → review+
In other words, I'd prefer to *not* use MOZ_NOT_REACHED in this kind of code which isn't critical or anything.
Attached patch Add the probe, r=smaug (obsolete) (deleted) — Splinter Review
Not landing yet, since my understanding is that all telemetry probes need privacy review.
Attachment #716474 - Attachment is obsolete: true
Attachment #716517 - Flags: review+
Flags: needinfo?(sstamm)
Status: NEW → ASSIGNED
Component: HTML: Parser → Document Navigation
Much like bug 843586, this is about measuring feature usage, so it should be in scope for telemetry privacy. CC'ing curtisk since he's the one managing this review now.
Flags: needinfo?(sstamm)
Attached patch Better patch (deleted) — Splinter Review
Let's try this again. This patch works around the problem we discussed on IRC about extensions setting the charset property on the docshell. Also, this patch folds in the flag from the other bug. Additionally, this breaks the unlabeled cases into file URLs and non-file URLs in order to see if people are actually using the menu to work around problems with local files as opposed to working around problems with Web sites. Furthermore, this handles the cases where the heuristic detector has fired separately in order to see if our detectors are actually misfiring a lot.
Attachment #716517 - Attachment is obsolete: true
Attachment #718955 - Flags: review?(bugs)
Comment on attachment 718955 [details] [diff] [review] Better patch Update uuid is of nsIDocShell
Attachment #718955 - Flags: review?(bugs) → review+
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla22
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: