Bug 801304 Part 1 - Keep track of suspended event queues in nsIDocument, r=smaug.

--HG--
extra : rebase_source : 312b0e15d40c7e11ba2c4a6bdadcfefb1300999f
This commit is contained in:
Brian Hackett 2018-12-14 06:47:40 -10:00
Родитель 1b714ffa18
Коммит d0f7b1b700
2 изменённых файлов: 35 добавлений и 0 удалений

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

@ -286,6 +286,7 @@
#include "nsHTMLTags.h"
#include "NodeUbiReporting.h"
#include "nsICookieService.h"
#include "mozilla/net/ChannelEventQueue.h"
#include "mozilla/net/RequestContextService.h"
#include "StorageAccessPermissionRequest.h"
@ -8580,6 +8581,22 @@ void nsIDocument::UnsuppressEventHandlingAndFireEvents(bool aFireEvents) {
} else {
FireOrClearDelayedEvents(documents, false);
}
if (!EventHandlingSuppressed()) {
MOZ_ASSERT(NS_IsMainThread());
nsTArray<RefPtr<net::ChannelEventQueue>> queues;
mSuspendedQueues.SwapElements(queues);
for (net::ChannelEventQueue* queue : queues) {
queue->Resume();
}
}
}
void nsIDocument::AddSuspendedChannelEventQueue(
net::ChannelEventQueue* aQueue) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(EventHandlingSuppressed());
mSuspendedQueues.AppendElement(aQueue);
}
nsISupports* nsIDocument::GetCurrentContentSink() {

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

@ -210,6 +210,12 @@ enum class CallerType : uint32_t;
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace net {
class ChannelEventQueue;
} // namespace net
} // namespace mozilla
// Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs
#define NS_IDOCUMENT_IID \
{ \
@ -2442,6 +2448,14 @@ class nsIDocument : public nsINode,
UpdateFrameRequestCallbackSchedulingState();
}
/**
* Note a ChannelEventQueue which has been suspended on the document's behalf
* to prevent XHRs from running content scripts while event handling is
* suppressed. The document is responsible for resuming the queue after
* event handling is unsuppressed.
*/
void AddSuspendedChannelEventQueue(mozilla::net::ChannelEventQueue* aQueue);
/**
* Increment https://html.spec.whatwg.org/#ignore-destructive-writes-counter
*/
@ -4025,6 +4039,10 @@ class nsIDocument : public nsINode,
uint32_t mEventsSuppressed;
// Any XHR ChannelEventQueues that were suspended on this document while
// events were suppressed.
nsTArray<RefPtr<mozilla::net::ChannelEventQueue>> mSuspendedQueues;
/**
* https://html.spec.whatwg.org/#ignore-destructive-writes-counter
*/