Bug 1475662 - Ensure GeckoSession.saveState() always completes r=droeh

MozReview-Commit-ID: CLcdjOkGI9b
This commit is contained in:
James Willcox 2018-07-13 14:02:08 -05:00
parent d1c649f6bd
commit 4f14025c2f
2 changed files with 19 additions and 3 deletions

View File

@ -158,8 +158,18 @@ class GeckoViewContent extends GeckoViewContentModule {
// Short circuit and return the pending state if we're in the process of restoring
sendAsyncMessage("GeckoView:SaveStateFinish", {state: JSON.stringify(this._savedState), id: aMsg.data.id});
} else {
let state = this.collectSessionState();
sendAsyncMessage("GeckoView:SaveStateFinish", {state: JSON.stringify(state), id: aMsg.data.id});
try {
let state = this.collectSessionState();
sendAsyncMessage("GeckoView:SaveStateFinish", {
state: state ? JSON.stringify(state) : null,
id: aMsg.data.id
});
} catch (e) {
sendAsyncMessage("GeckoView:SaveStateFinish", {
error: e.message,
id: aMsg.data.id
});
}
}
break;

View File

@ -139,7 +139,13 @@ class GeckoViewContent extends GeckoViewModule {
warn `Failed to save state due to missing callback`;
return;
}
this._saveStateCallbacks.get(aMsg.data.id).onSuccess(aMsg.data.state);
const callback = this._saveStateCallbacks.get(aMsg.data.id)
if (aMsg.data.error) {
callback.onError(aMsg.data.error);
} else {
callback.onSuccess(aMsg.data.state);
}
this._saveStateCallbacks.delete(aMsg.data.id);
break;
}