Bug 1432529 - Exit spinEventLoopUntil when canceling migrator r?Gijs
Fairly trivial - discussed in
bug 862127. Opt to cancel the spin wait
rather than disable canceling in the UI.
MozReview-Commit-ID: B55Fsw34uX7
--- a/browser/components/migration/MigrationUtils.jsm
+++ b/browser/components/migration/MigrationUtils.jsm
@@ -37,16 +37,17 @@ ChromeUtils.defineModuleGetter(this, "Wi
ChromeUtils.defineModuleGetter(this, "setTimeout",
"resource://gre/modules/Timer.jsm");
var gMigrators = null;
var gProfileStartup = null;
var gMigrationBundle = null;
var gPreviousDefaultBrowserKey = "";
+let gForceExitSpinResolve = false;
let gKeepUndoData = false;
let gUndoData = null;
XPCOMUtils.defineLazyGetter(this, "gAvailableMigratorKeys", function() {
if (AppConstants.platform == "win") {
return [
"firefox", "edge", "ie", "chrome", "chromium", "360se",
"canary",
@@ -647,32 +648,39 @@ this.MigrationUtils = Object.freeze({
get _migrators() {
if (!gMigrators) {
gMigrators = new Map();
}
return gMigrators;
},
+ forceExitSpinResolve: function MU_forceExitSpinResolve() {
+ gForceExitSpinResolve = true;
+ },
+
spinResolve: function MU_spinResolve(promise) {
if (!(promise instanceof Promise)) {
return promise;
}
let done = false;
let result = null;
let error = null;
+ gForceExitSpinResolve = false;
promise.catch(e => {
error = e;
}).then(r => {
result = r;
done = true;
});
- Services.tm.spinEventLoopUntil(() => done);
- if (error) {
+ Services.tm.spinEventLoopUntil(() => done || gForceExitSpinResolve);
+ if (!done) {
+ throw new Error("Forcefully exited event loop.");
+ } else if (error) {
throw error;
} else {
return result;
}
},
/*
* Returns the migrator for the given source, if any data is available
--- a/browser/components/migration/content/migration.js
+++ b/browser/components/migration/content/migration.js
@@ -61,29 +61,27 @@ var MigrationWizard = { /* exported Migr
os.removeObserver(this, "Migration:ItemError");
os.removeObserver(this, "Migration:Ended");
MigrationUtils.finishMigration();
},
spinResolve(promise) {
let canAdvance = this._wiz.canAdvance;
let canRewind = this._wiz.canRewind;
- let canCancel = this._canCancel;
this._wiz.canAdvance = false;
this._wiz.canRewind = false;
- this._canCancel = false;
let result = MigrationUtils.spinResolve(promise);
this._wiz.canAdvance = canAdvance;
this._wiz.canRewind = canRewind;
- this._canCancel = canCancel;
return result;
},
onWizardCancel() {
- return this._canCancel;
+ MigrationUtils.forceExitSpinResolve();
+ return true;
},
// 1 - Import Source
onImportSourcePageShow() {
// Show warning message to close the selected browser when needed
let toggleCloseBrowserWarning = () => {
let visibility = "hidden";
if (group.selectedItem.id != "nothing") {
--- a/browser/components/migration/content/migration.xul
+++ b/browser/components/migration/content/migration.xul
@@ -10,17 +10,18 @@
<wizard id="migrationWizard"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
windowtype="Browser:MigrationWizard"
title="&migrationWizard.title;"
onload="MigrationWizard.init()"
onunload="MigrationWizard.uninit()"
style="width: 40em;"
buttons="accept,cancel"
- branded="true">
+ branded="true"
+ onwizardcancel="return MigrationWizard.onWizardCancel();">
<script type="application/javascript" src="chrome://browser/content/migration/migration.js"/>
<wizardpage id="importSource" pageid="importSource" next="selectProfile"
label="&importSource.title;"
onpageadvanced="return MigrationWizard.onImportSourcePageAdvanced();">
#ifdef XP_WIN
<description id="importAll" control="importSourceGroup">&importFrom.label;</description>