diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index ccfe785a94441dd4483bbb92e1492d89019a786a..e1964fe502404aad4a377ce86045931c64e058c1 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -3060,7 +3060,10 @@ nsGenericHTMLElement::GetInnerText(mozilla::dom::DOMString& aValue, { if (!GetPrimaryFrame(FlushType::Layout)) { nsIPresShell* presShell = nsComputedDOMStyle::GetPresShellForContent(this); - if (!presShell || IsOrHasAncestorWithDisplayNone(this, presShell)) { + // NOTE(emilio): We need to check the presshell is styled in order to ensure + // the document is styled. + if (!presShell || !presShell->DidInitialize() || + IsOrHasAncestorWithDisplayNone(this, presShell)) { GetTextContentInternal(aValue, aError); return; }