Bug 1549688 - Return early if BookmarkPanelHub is not initialized (#5038)
This commit is contained in:
Родитель
a955e84edb
Коммит
90a2cb5ae4
|
@ -19,7 +19,7 @@ class _BookmarkPanelHub {
|
|||
this._handleMessageRequest = null;
|
||||
this._addImpression = null;
|
||||
this._dispatch = null;
|
||||
this._initalized = false;
|
||||
this._initialized = false;
|
||||
this._response = null;
|
||||
this._l10n = null;
|
||||
|
||||
|
@ -42,12 +42,12 @@ class _BookmarkPanelHub {
|
|||
"browser/branding/sync-brand.ftl",
|
||||
"browser/newtab/asrouter.ftl",
|
||||
]);
|
||||
this._initalized = true;
|
||||
this._initialized = true;
|
||||
}
|
||||
|
||||
uninit() {
|
||||
this._l10n = null;
|
||||
this._initalized = false;
|
||||
this._initialized = false;
|
||||
this._handleMessageRequest = null;
|
||||
this._addImpression = null;
|
||||
this._dispatch = null;
|
||||
|
@ -64,6 +64,10 @@ class _BookmarkPanelHub {
|
|||
* @returns {obj|null} response object or null if no messages matched
|
||||
*/
|
||||
async messageRequest(target, win) {
|
||||
if (!this._initialized) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this._response && this._response.win === win && this._response.url === target.url && this._response.content) {
|
||||
this.showMessage(this._response.content, target, win);
|
||||
return true;
|
||||
|
|
|
@ -74,7 +74,7 @@ describe("BookmarkPanelHub", () => {
|
|||
it("should uninit", () => {
|
||||
instance.uninit();
|
||||
|
||||
assert.isFalse(instance._initalized);
|
||||
assert.isFalse(instance._initialized);
|
||||
assert.isNull(instance._addImpression);
|
||||
assert.isNull(instance._handleMessageRequest);
|
||||
});
|
||||
|
@ -85,7 +85,10 @@ describe("BookmarkPanelHub", () => {
|
|||
assert.equal(instance._handleMessageRequest, fakeHandleMessageRequest);
|
||||
assert.equal(instance._dispatch, fakeDispatch);
|
||||
assert.ok(instance._l10n);
|
||||
assert.isTrue(instance._initalized);
|
||||
assert.isTrue(instance._initialized);
|
||||
});
|
||||
it("should return early if not initialized", async () => {
|
||||
assert.isFalse(await instance.messageRequest());
|
||||
});
|
||||
describe("#messageRequest", () => {
|
||||
beforeEach(() => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче