# HG changeset patch # User Andrea Marchesini # Date 1521629847 -3600 # Node ID 59a42f4b6ef6e4134f96428cc667571027785635 # Parent 0f4499ed8d0fd6f613e218262511d2e5ce4d0cc9 Bug 1447422 - Better check on aDocument in nsContentUtils::WarnScriptWasIgnored, r=smaug diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -5857,27 +5857,30 @@ nsContentUtils::GetMostRecentNonPBWindow return pwindow.forget(); } /* static */ void nsContentUtils::WarnScriptWasIgnored(nsIDocument* aDocument) { nsAutoString msg; + bool privateBrowsing = false; + if (aDocument) { nsCOMPtr uri = aDocument->GetDocumentURI(); if (uri) { msg.Append(NS_ConvertUTF8toUTF16(uri->GetSpecOrDefault())); msg.AppendLiteral(" : "); } - } + privateBrowsing = + !!aDocument->NodePrincipal()->OriginAttributesRef().mPrivateBrowsingId; + } + msg.AppendLiteral("Unable to run script because scripts are blocked internally."); - - LogSimpleConsoleError(msg, "DOM", - !!aDocument->NodePrincipal()->OriginAttributesRef().mPrivateBrowsingId); + LogSimpleConsoleError(msg, "DOM", privateBrowsing); } /* static */ void nsContentUtils::AddScriptRunner(already_AddRefed aRunnable) { nsCOMPtr runnable = aRunnable; if (!runnable) {