diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 5467fe967a6..5530ca05725 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -2085,12 +2085,15 @@ PresShell::SetPrefNoScriptRule() // also handle the case where print is done from print preview // see bug #342439 for more details - PRBool scriptEnabled = mDocument->IsScriptEnabled() || - ((mPresContext->Type() == nsPresContext::eContext_PrintPreview || - mPresContext->Type() == nsPresContext::eContext_Print) && - NS_PTR_TO_INT32(mDocument->GetProperty( - nsGkAtoms::scriptEnabledBeforePrintOrPreview))); + nsIDocument* doc = mDocument; + if (mPresContext->Type() == nsPresContext::eContext_PrintPreview || + mPresContext->Type() == nsPresContext::eContext_Print) { + while (doc->GetOriginalDocument()) { + doc = doc->GetOriginalDocument(); + } + } + PRBool scriptEnabled = doc->IsScriptEnabled(); if (scriptEnabled) { if (!mPrefStyleSheet) { rv = CreatePreferenceStyleSheet();