Bug 1419902 - Check if doc exists before quering document URI within CloseOuter. r=smaug

This commit is contained in:
Christoph Kerschbaumer 2017-12-06 14:00:51 +01:00
Родитель 024ae54b75
Коммит 491e62af53
1 изменённых файлов: 18 добавлений и 16 удалений

Просмотреть файл

@ -5966,24 +5966,26 @@ nsGlobalWindowOuter::CloseOuter(bool aTrustedCaller)
// Don't allow scripts from content to close non-neterror windows that
// were not opened by script.
nsAutoString url;
nsresult rv = mDoc->GetURL(url);
NS_ENSURE_SUCCESS_VOID(rv);
if (mDoc) {
nsAutoString url;
nsresult rv = mDoc->GetURL(url);
NS_ENSURE_SUCCESS_VOID(rv);
if (!StringBeginsWith(url, NS_LITERAL_STRING("about:neterror")) &&
!mHadOriginalOpener && !aTrustedCaller) {
bool allowClose = mAllowScriptsToClose ||
Preferences::GetBool("dom.allow_scripts_to_close_windows", true);
if (!allowClose) {
// We're blocking the close operation
// report localized error msg in JS console
nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("DOM Window"), mDoc, // Better name for the category?
nsContentUtils::eDOM_PROPERTIES,
"WindowCloseBlockedWarning");
if (!StringBeginsWith(url, NS_LITERAL_STRING("about:neterror")) &&
!mHadOriginalOpener && !aTrustedCaller) {
bool allowClose = mAllowScriptsToClose ||
Preferences::GetBool("dom.allow_scripts_to_close_windows", true);
if (!allowClose) {
// We're blocking the close operation
// report localized error msg in JS console
nsContentUtils::ReportToConsole(
nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("DOM Window"), mDoc, // Better name for the category?
nsContentUtils::eDOM_PROPERTIES,
"WindowCloseBlockedWarning");
return;
return;
}
}
}