Bug 1655866: Part 6 - Remove sync before unload prompt code. r=nika,geckoview-reviewers,agi

Differential Revision: https://phabricator.services.mozilla.com/D88319
This commit is contained in:
Kris Maglione 2020-09-21 22:41:06 +00:00
Родитель d3498e1041
Коммит 43d01c93da
3 изменённых файлов: 4 добавлений и 47 удалений

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

@ -71,7 +71,7 @@ class PromptCollection {
return buttonPressed === 0;
}
beforeUnloadCheckInternal(browsingContext, sync) {
asyncBeforeUnloadCheck(browsingContext) {
let title;
let message;
let leaveLabel;
@ -113,23 +113,6 @@ class PromptCollection {
(Ci.nsIPromptService.BUTTON_TITLE_IS_STRING *
Ci.nsIPromptService.BUTTON_POS_1);
if (sync) {
let buttonNumClicked = Services.prompt.confirmExBC(
browsingContext,
modalType,
title,
message,
buttonFlags,
leaveLabel,
stayLabel,
null,
null,
{}
);
return buttonNumClicked === 0;
}
return Services.prompt
.asyncConfirmEx(
browsingContext,
@ -144,10 +127,7 @@ class PromptCollection {
false,
// Tell the prompt service that this is a permit unload prompt
// so that it can set the appropriate flag on the detail object
// of the events it dispatches. This happens automatically for
// the sync version of the prompt, which is always dispatched
// from the content process, where the flag comes from the
// content viewer which triggers the prompt.
// of the events it dispatches.
{ inPermitUnload: true }
)
.then(
@ -155,14 +135,6 @@ class PromptCollection {
result.QueryInterface(Ci.nsIPropertyBag2).get("buttonNumClicked") == 0
);
}
beforeUnloadCheck(browsingContext) {
return this.beforeUnloadCheckInternal(browsingContext, /* sync */ true);
}
asyncBeforeUnloadCheck(browsingContext) {
return this.beforeUnloadCheckInternal(browsingContext, /* sync */ false);
}
}
const BUNDLES = {

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

@ -29,15 +29,6 @@ class PromptCollection {
return !!result?.allow;
}
beforeUnloadCheck(browsingContext) {
const msg = {
type: "beforeUnload",
};
const prompter = new GeckoViewPrompter(browsingContext);
const result = prompter.showPrompt(msg);
return !!result?.allow;
}
asyncBeforeUnloadCheck(browsingContext) {
return new Promise(resolve => {
const msg = {

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

@ -19,14 +19,8 @@ interface nsIPromptCollection : nsISupports
* @param aBrowsingContext
* The browsing context the prompt should be opened for.
*
* @return true if the page should be allowed to navigate away
*/
boolean beforeUnloadCheck(in BrowsingContext aBrowsingContext);
/**
* Like `beforeUnloadCheck`, but does not spin a nested event loop, and
* instead returns a promise which resolves to true if navigation should be
* allowed, and false if not.
* @return Promise which resolves to true if the page should be allowed to
* navigate away
*/
Promise asyncBeforeUnloadCheck(in BrowsingContext aBrowsingContext);