Bug 1549688 - Return early if BookmarkPanelHub is not initialized (#5038)

This commit is contained in:
Andrei Oprea 2019-05-17 15:04:18 +00:00 коммит произвёл GitHub
Родитель a955e84edb
Коммит 90a2cb5ae4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 12 добавлений и 5 удалений

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

@ -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(() => {