From 9f99a8ad5f988036bebafc5206f87586a9ae8309 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= <emilio@crisal.io>
Date: Sat, 5 Aug 2017 08:55:50 +0200
Subject: [PATCH] Bug 1382568: Avoid trying to resolve styles in an
 uninitialized presshell in GetInnerText. r=heycam

MozReview-Commit-ID: DFFb5OCQpHG

--HG--
extra : rebase_source : 2338719ce46efc405d845cc41ea633336c4e971c
---
 dom/html/nsGenericHTMLElement.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp
index ccfe785a94441..e1964fe502404 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;
     }
-- 
GitLab