Bug 1730117 - Part 1: Make sync XHR suppress event handling for the nested in-process documents; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D125187
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/Components.h"
|
||||
#include "mozilla/dom/AutoSuppressEventHandlingAndSuspend.h"
|
||||
#include "mozilla/dom/BlobBinding.h"
|
||||
#include "mozilla/dom/BlobURLProtocolHandler.h"
|
||||
#include "mozilla/dom/DocGroup.h"
|
||||
@@ -2797,15 +2798,10 @@ void XMLHttpRequestMainThread::EnsureChannelContentType() {
|
||||
}
|
||||
}
|
||||
|
||||
void XMLHttpRequestMainThread::UnsuppressEventHandlingAndResume() {
|
||||
void XMLHttpRequestMainThread::ResumeTimeout() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mFlagSynchronous);
|
||||
|
||||
if (mSuspendedDoc) {
|
||||
mSuspendedDoc->UnsuppressEventHandlingAndFireEvents(true);
|
||||
mSuspendedDoc = nullptr;
|
||||
}
|
||||
|
||||
if (mResumeTimeoutRunnable) {
|
||||
DispatchToMainThread(mResumeTimeoutRunnable.forget());
|
||||
mResumeTimeoutRunnable = nullptr;
|
||||
@@ -3028,7 +3024,15 @@ void XMLHttpRequestMainThread::SendInternal(const BodyExtractorBase* aBody,
|
||||
mFlagSend = true;
|
||||
|
||||
// If we're synchronous, spin an event loop here and wait
|
||||
RefPtr<Document> suspendedDoc;
|
||||
if (mFlagSynchronous) {
|
||||
auto scopeExit = MakeScopeExit([&] {
|
||||
CancelSyncTimeoutTimer();
|
||||
ResumeTimeout();
|
||||
ResumeEventDispatching();
|
||||
});
|
||||
Maybe<AutoSuppressEventHandling> autoSuppress;
|
||||
|
||||
mFlagSyncLooping = true;
|
||||
|
||||
if (GetOwner()) {
|
||||
@@ -3036,10 +3040,8 @@ void XMLHttpRequestMainThread::SendInternal(const BodyExtractorBase* aBody,
|
||||
GetOwner()->GetOuterWindow()->GetInProcessTop()) {
|
||||
if (nsCOMPtr<nsPIDOMWindowInner> topInner =
|
||||
topWindow->GetCurrentInnerWindow()) {
|
||||
mSuspendedDoc = topWindow->GetExtantDoc();
|
||||
if (mSuspendedDoc) {
|
||||
mSuspendedDoc->SuppressEventHandling();
|
||||
}
|
||||
suspendedDoc = topWindow->GetExtantDoc();
|
||||
autoSuppress.emplace(topWindow->GetBrowsingContext());
|
||||
topInner->Suspend();
|
||||
mResumeTimeoutRunnable = new nsResumeTimeoutsEvent(topInner);
|
||||
}
|
||||
@@ -3048,11 +3050,6 @@ void XMLHttpRequestMainThread::SendInternal(const BodyExtractorBase* aBody,
|
||||
|
||||
SuspendEventDispatching();
|
||||
StopProgressEventTimer();
|
||||
auto scopeExit = MakeScopeExit([&] {
|
||||
CancelSyncTimeoutTimer();
|
||||
UnsuppressEventHandlingAndResume();
|
||||
ResumeEventDispatching();
|
||||
});
|
||||
|
||||
SyncTimeoutType syncTimeoutType = MaybeStartSyncTimeoutTimer();
|
||||
if (syncTimeoutType == eErrorOrExpired) {
|
||||
@@ -3061,7 +3058,7 @@ void XMLHttpRequestMainThread::SendInternal(const BodyExtractorBase* aBody,
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoSyncOperation sync(mSuspendedDoc,
|
||||
nsAutoSyncOperation sync(suspendedDoc,
|
||||
SyncOperationBehavior::eSuspendInput);
|
||||
if (!SpinEventLoopUntil([&]() { return !mFlagSyncLooping; })) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
|
||||
Reference in New Issue
Block a user