Skip to content

Commit 43d01c9

Browse files
committed
Bug 1655866: Part 6 - Remove sync before unload prompt code. r=nika,geckoview-reviewers,agi
Differential Revision: https://phabricator.services.mozilla.com/D88319
1 parent d3498e1 commit 43d01c9

File tree

3 files changed

+4
-47
lines changed

3 files changed

+4
-47
lines changed

browser/components/prompts/PromptCollection.jsm

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class PromptCollection {
7171
return buttonPressed === 0;
7272
}
7373

74-
beforeUnloadCheckInternal(browsingContext, sync) {
74+
asyncBeforeUnloadCheck(browsingContext) {
7575
let title;
7676
let message;
7777
let leaveLabel;
@@ -113,23 +113,6 @@ class PromptCollection {
113113
(Ci.nsIPromptService.BUTTON_TITLE_IS_STRING *
114114
Ci.nsIPromptService.BUTTON_POS_1);
115115

116-
if (sync) {
117-
let buttonNumClicked = Services.prompt.confirmExBC(
118-
browsingContext,
119-
modalType,
120-
title,
121-
message,
122-
buttonFlags,
123-
leaveLabel,
124-
stayLabel,
125-
null,
126-
null,
127-
{}
128-
);
129-
130-
return buttonNumClicked === 0;
131-
}
132-
133116
return Services.prompt
134117
.asyncConfirmEx(
135118
browsingContext,
@@ -144,25 +127,14 @@ class PromptCollection {
144127
false,
145128
// Tell the prompt service that this is a permit unload prompt
146129
// so that it can set the appropriate flag on the detail object
147-
// of the events it dispatches. This happens automatically for
148-
// the sync version of the prompt, which is always dispatched
149-
// from the content process, where the flag comes from the
150-
// content viewer which triggers the prompt.
130+
// of the events it dispatches.
151131
{ inPermitUnload: true }
152132
)
153133
.then(
154134
result =>
155135
result.QueryInterface(Ci.nsIPropertyBag2).get("buttonNumClicked") == 0
156136
);
157137
}
158-
159-
beforeUnloadCheck(browsingContext) {
160-
return this.beforeUnloadCheckInternal(browsingContext, /* sync */ true);
161-
}
162-
163-
asyncBeforeUnloadCheck(browsingContext) {
164-
return this.beforeUnloadCheckInternal(browsingContext, /* sync */ false);
165-
}
166138
}
167139

168140
const BUNDLES = {

mobile/android/components/geckoview/PromptCollection.jsm

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,6 @@ class PromptCollection {
2929
return !!result?.allow;
3030
}
3131

32-
beforeUnloadCheck(browsingContext) {
33-
const msg = {
34-
type: "beforeUnload",
35-
};
36-
const prompter = new GeckoViewPrompter(browsingContext);
37-
const result = prompter.showPrompt(msg);
38-
return !!result?.allow;
39-
}
40-
4132
asyncBeforeUnloadCheck(browsingContext) {
4233
return new Promise(resolve => {
4334
const msg = {

toolkit/components/windowwatcher/nsIPromptCollection.idl

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,8 @@ interface nsIPromptCollection : nsISupports
1919
* @param aBrowsingContext
2020
* The browsing context the prompt should be opened for.
2121
*
22-
* @return true if the page should be allowed to navigate away
23-
*/
24-
boolean beforeUnloadCheck(in BrowsingContext aBrowsingContext);
25-
26-
/**
27-
* Like `beforeUnloadCheck`, but does not spin a nested event loop, and
28-
* instead returns a promise which resolves to true if navigation should be
29-
* allowed, and false if not.
22+
* @return Promise which resolves to true if the page should be allowed to
23+
* navigate away
3024
*/
3125
Promise asyncBeforeUnloadCheck(in BrowsingContext aBrowsingContext);
3226

0 commit comments

Comments
 (0)