diff --git a/parser/htmlparser/nsExpatDriver.cpp b/parser/htmlparser/nsExpatDriver.cpp
index eefbe3bb3253..a9dd31ae6ec1 100644
--- a/parser/htmlparser/nsExpatDriver.cpp
+++ b/parser/htmlparser/nsExpatDriver.cpp
@@ -9,6 +9,7 @@
#include "CParserContext.h"
#include "nsIExpatSink.h"
#include "nsIContentSink.h"
+#include "nsIDocShell.h"
#include "nsParserMsgUtils.h"
#include "nsIURL.h"
#include "nsIUnicharInputStream.h"
@@ -823,6 +824,14 @@ nsresult nsExpatDriver::HandleError() {
if (doc && nsContentUtils::IsChromeDoc(doc)) {
nsCString path = doc->GetDocumentURI()->GetSpecOrDefault();
+ nsCOMPtr container = doc->GetContainer();
+ nsCOMPtr docShell = do_QueryInterface(container);
+ nsCString docShellDestroyed("unknown"_ns);
+ if (docShell) {
+ bool destroyed = false;
+ docShell->IsBeingDestroyed(&destroyed);
+ docShellDestroyed.Assign(destroyed ? "true"_ns : "false"_ns);
+ }
mozilla::Maybe> extra =
mozilla::Some>({
@@ -834,6 +843,10 @@ nsresult nsExpatDriver::HandleError() {
"last_line"_ns, NS_ConvertUTF16toUTF8(mLastLine)},
mozilla::Telemetry::EventExtraEntry{
"last_line_len"_ns, nsPrintfCString("%u", mLastLine.Length())},
+ mozilla::Telemetry::EventExtraEntry{
+ "hidden"_ns, doc->Hidden() ? "true"_ns : "false"_ns},
+ mozilla::Telemetry::EventExtraEntry{"destroyed"_ns,
+ docShellDestroyed},
});
mozilla::Telemetry::SetEventRecordingEnabled("ysod"_ns, true);
diff --git a/parser/htmlparser/tests/mochitest/browser_ysod_telemetry.js b/parser/htmlparser/tests/mochitest/browser_ysod_telemetry.js
index 5a709351e70a..1a9ca6e0095b 100644
--- a/parser/htmlparser/tests/mochitest/browser_ysod_telemetry.js
+++ b/parser/htmlparser/tests/mochitest/browser_ysod_telemetry.js
@@ -35,6 +35,8 @@ add_task(async function test_popup_opened() {
location: "3:12",
last_line: " &nonExistingEntity;",
last_line_len: "38",
+ hidden: "false",
+ destroyed: "false",
},
},
],
diff --git a/toolkit/components/telemetry/Events.yaml b/toolkit/components/telemetry/Events.yaml
index 2addfc908bb6..d787bbe714f2 100644
--- a/toolkit/components/telemetry/Events.yaml
+++ b/toolkit/components/telemetry/Events.yaml
@@ -2632,6 +2632,8 @@ ysod:
location: Location as Row:Column of where the error happened.
last_line: The content of the last line that led to the error.
last_line_len: The length of the last line that led to the error.
+ hidden: The document is hidden.
+ destroyed: The container of this document is destroyed.
dom.quota.try:
error: