зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1358893 - Stop using document.createEvent("beforeunloadevent") internally; r=smaug
We want to see if we can drop support due to web pages not using it. Edge and Safari already don't support it, and Chrome reports that usage is low enough that they're willing to drop it. But telemetry doesn't tell us about web usage if we're triggering it via our own internal code. MozReview-Commit-ID: 5YBfhQJExHC --HG-- extra : rebase_source : fd359e3264ba96ef10617f4de767080c94b792fb
This commit is contained in:
Родитель
3ba9b0dd11
Коммит
db1d64129d
|
@ -18,7 +18,7 @@
|
|||
#include "nsIContentViewerContainer.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIDocumentViewerPrint.h"
|
||||
#include "nsIDOMBeforeUnloadEvent.h"
|
||||
#include "mozilla/dom/BeforeUnloadEvent.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
|
@ -1185,12 +1185,13 @@ nsDocumentViewer::PermitUnloadInternal(bool *aShouldPrompt,
|
|||
|
||||
// Now, fire an BeforeUnload event to the document and see if it's ok
|
||||
// to unload...
|
||||
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(mDocument);
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
domDoc->CreateEvent(NS_LITERAL_STRING("beforeunloadevent"),
|
||||
getter_AddRefs(event));
|
||||
nsCOMPtr<nsIDOMBeforeUnloadEvent> beforeUnload = do_QueryInterface(event);
|
||||
NS_ENSURE_STATE(beforeUnload);
|
||||
nsIPresShell* shell = mDocument->GetShell();
|
||||
nsPresContext* presContext = nullptr;
|
||||
if (shell) {
|
||||
presContext = shell->GetPresContext();
|
||||
}
|
||||
RefPtr<BeforeUnloadEvent> event =
|
||||
new BeforeUnloadEvent(mDocument, presContext, nullptr);
|
||||
event->InitEvent(NS_LITERAL_STRING("beforeunload"), false, true);
|
||||
|
||||
// Dispatching to |window|, but using |document| as the target.
|
||||
|
@ -1222,7 +1223,7 @@ nsDocumentViewer::PermitUnloadInternal(bool *aShouldPrompt,
|
|||
|
||||
nsCOMPtr<nsIDocShell> docShell(mContainer);
|
||||
nsAutoString text;
|
||||
beforeUnload->GetReturnValue(text);
|
||||
event->GetReturnValue(text);
|
||||
|
||||
// NB: we nullcheck mDocument because it might now be dead as a result of
|
||||
// the event being dispatched.
|
||||
|
|
|
@ -377,9 +377,9 @@
|
|||
"CREATE_EVENT_BEFOREUNLOADEVENT" : {
|
||||
"alert_emails": ["ayg@aryeh.name"],
|
||||
"description": "Was document.createEvent(\"beforeunloadevent\") ever called",
|
||||
"expires_in_version": "56",
|
||||
"expires_in_version": "60",
|
||||
"kind": "count",
|
||||
"bug_numbers": [1295588, 1251198]
|
||||
"bug_numbers": [1295588, 1251198, 1358893]
|
||||
},
|
||||
"CREATE_EVENT_COMPOSITIONEVENT" : {
|
||||
"alert_emails": ["ayg@aryeh.name"],
|
||||
|
|
Загрузка…
Ссылка в новой задаче