Commit 56000879 authored by Moe Ahmadi's avatar Moe Ahmadi Committed by Commit Bot

Fixes NTP Modules not showing if there is no promo

Modules wait for the promo to be loaded before showing. The promo is
considered loaded when the ntp-middle-slot-promo has been fired by the
promo element. This event is expected to be fired whether or not there
is a promo data available. crrev.com/c/2505739 changed that behavior
causing NTP Modules to remain hidden when there is no promo data.

Fixed: 1147257, 1143366
Change-Id: If0c14ec8ee142fd38cdbc1bf9249f3345db6ca82
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2527854
Commit-Queue: Moe Ahmadi <mahmadi@chromium.org>
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
Auto-Submit: Moe Ahmadi <mahmadi@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825668}
parent a8164106
......@@ -102,6 +102,11 @@ class MiddleSlotPromoElement extends PolymerElement {
this.dispatchEvent(new Event(
'ntp-middle-slot-promo-loaded', {bubbles: true, composed: true}));
});
} else {
// Dispatch this event even if there is no promo as Modules wait for the
// promo to be loaded before showing.
this.dispatchEvent(new Event(
'ntp-middle-slot-promo-loaded', {bubbles: true, composed: true}));
}
});
}
......
......@@ -144,11 +144,14 @@ suite('NewTabPageMiddleSlotPromoTest', () => {
testProxy.handler.setResultFor('getPromo', Promise.resolve({promo: null}));
const middleSlotPromo = document.createElement('ntp-middle-slot-promo');
document.body.appendChild(middleSlotPromo);
const loaded =
eventToPromise('ntp-middle-slot-promo-loaded', document.body);
assertEquals(
0,
promoBrowserCommandTestProxy.handler.getCallCount(
'canShowPromoWithCommand'));
assertEquals(0, testProxy.handler.getCallCount('onPromoRendered'));
assertTrue(middleSlotPromo.hasAttribute('hidden'));
await loaded;
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment