зеркало из https://github.com/mozilla/gecko-dev.git
Bug 799592 nsDOMWindowUtils::AllowScriptsToClose to bypass dom.allow_scripts_to_close_windows, r=jst
This commit is contained in:
Родитель
831e04c2e3
Коммит
2cdba3cfd5
|
@ -2969,3 +2969,15 @@ nsDOMWindowUtils::GetIsHandlingUserInput(bool* aHandlingUserInput)
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDOMWindowUtils::AllowScriptsToClose()
|
||||||
|
{
|
||||||
|
if (!IsUniversalXPConnectCapable()) {
|
||||||
|
return NS_ERROR_DOM_SECURITY_ERR;
|
||||||
|
}
|
||||||
|
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
|
||||||
|
NS_ENSURE_STATE(window);
|
||||||
|
static_cast<nsGlobalWindow*>(window.get())->AllowScriptsToClose();
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
|
@ -699,6 +699,7 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
|
||||||
mShowFocusRingForContent(false),
|
mShowFocusRingForContent(false),
|
||||||
mFocusByKeyOccurred(false),
|
mFocusByKeyOccurred(false),
|
||||||
mNotifiedIDDestroyed(false),
|
mNotifiedIDDestroyed(false),
|
||||||
|
mAllowScriptsToClose(false),
|
||||||
mTimeoutInsertionPoint(nullptr),
|
mTimeoutInsertionPoint(nullptr),
|
||||||
mTimeoutPublicIdCounter(1),
|
mTimeoutPublicIdCounter(1),
|
||||||
mTimeoutFiringDepth(0),
|
mTimeoutFiringDepth(0),
|
||||||
|
@ -6584,7 +6585,7 @@ nsGlobalWindow::Close()
|
||||||
// opened by script.
|
// opened by script.
|
||||||
if (!mDocShell->GetIsApp() &&
|
if (!mDocShell->GetIsApp() &&
|
||||||
!mHadOriginalOpener && !nsContentUtils::IsCallerTrustedForWrite()) {
|
!mHadOriginalOpener && !nsContentUtils::IsCallerTrustedForWrite()) {
|
||||||
bool allowClose =
|
bool allowClose = mAllowScriptsToClose ||
|
||||||
Preferences::GetBool("dom.allow_scripts_to_close_windows", true);
|
Preferences::GetBool("dom.allow_scripts_to_close_windows", true);
|
||||||
if (!allowClose) {
|
if (!allowClose) {
|
||||||
// We're blocking the close operation
|
// We're blocking the close operation
|
||||||
|
|
|
@ -604,6 +604,10 @@ public:
|
||||||
bool ContainsIdleObserver(nsIIdleObserver* aIdleObserver, uint32_t timeInS);
|
bool ContainsIdleObserver(nsIIdleObserver* aIdleObserver, uint32_t timeInS);
|
||||||
void HandleIdleObserverCallback();
|
void HandleIdleObserverCallback();
|
||||||
|
|
||||||
|
void AllowScriptsToClose()
|
||||||
|
{
|
||||||
|
mAllowScriptsToClose = true;
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
// Array of idle observers that are notified of idle events.
|
// Array of idle observers that are notified of idle events.
|
||||||
nsTObserverArray<IdleObserverHolder> mIdleObservers;
|
nsTObserverArray<IdleObserverHolder> mIdleObservers;
|
||||||
|
@ -996,6 +1000,9 @@ protected:
|
||||||
|
|
||||||
// whether we've sent the destroy notification for our window id
|
// whether we've sent the destroy notification for our window id
|
||||||
bool mNotifiedIDDestroyed : 1;
|
bool mNotifiedIDDestroyed : 1;
|
||||||
|
// whether scripts may close the window,
|
||||||
|
// even if "dom.allow_scripts_to_close_windows" is false.
|
||||||
|
bool mAllowScriptsToClose : 1;
|
||||||
|
|
||||||
nsCOMPtr<nsIScriptContext> mContext;
|
nsCOMPtr<nsIScriptContext> mContext;
|
||||||
nsWeakPtr mOpener;
|
nsWeakPtr mOpener;
|
||||||
|
|
|
@ -40,7 +40,7 @@ interface nsIDOMTouch;
|
||||||
interface nsIDOMClientRect;
|
interface nsIDOMClientRect;
|
||||||
interface nsIURI;
|
interface nsIURI;
|
||||||
|
|
||||||
[scriptable, uuid(a76927b7-4aca-4cd1-9c2b-a6b4789b88c3)]
|
[scriptable, uuid(f5b9883b-2ab9-426c-8fc1-7296cb6bc1d2)]
|
||||||
interface nsIDOMWindowUtils : nsISupports {
|
interface nsIDOMWindowUtils : nsISupports {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1277,4 +1277,10 @@ interface nsIDOMWindowUtils : nsISupports {
|
||||||
* This calls nsEventStateManager::IsHandlingUserInput().
|
* This calls nsEventStateManager::IsHandlingUserInput().
|
||||||
*/
|
*/
|
||||||
readonly attribute boolean isHandlingUserInput;
|
readonly attribute boolean isHandlingUserInput;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* After calling the method, the window for which this DOMWindowUtils
|
||||||
|
* was created can be closed using scripts.
|
||||||
|
*/
|
||||||
|
void allowScriptsToClose();
|
||||||
};
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче