Bug 1731756: Pull site name from the array of site data. r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D126212
This commit is contained in:
Dave Townsend 2021-09-22 09:56:47 +00:00
Родитель ac34e350cd
Коммит 3eab4c935f
2 изменённых файлов: 13 добавлений и 8 удалений

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

@ -310,8 +310,9 @@ class CommonNames {
* @returns {string} The snapshot's common name.
*/
static getName(snapshot) {
let commonName = snapshot.pageData.get(PageDataCollector.DATA_TYPE.GENERAL)
?.site_name;
let commonName = snapshot.pageData.get(
PageDataCollector.DATA_TYPE.GENERAL
)?.[0]?.site_name;
if (commonName) {
return commonName;
}

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

@ -40,9 +40,11 @@ add_task(async function fromMetadata() {
PageDataService.pageDataDiscovered(TEST_URL1, [
{
type: PageDataCollector.DATA_TYPE.GENERAL,
data: {
site_name: "Test Example",
},
data: [
{
site_name: "Test Example",
},
],
},
]);
await assertUrlNotification(TOPIC_ADDED, [TEST_URL1], () =>
@ -88,9 +90,11 @@ add_task(async function customName_withMetadata() {
PageDataService.pageDataDiscovered(TEST_URL3, [
{
type: PageDataCollector.DATA_TYPE.GENERAL,
data: {
site_name: "Test Example 2",
},
data: [
{
site_name: "Test Example 2",
},
],
},
]);
await assertUrlNotification(TOPIC_ADDED, [TEST_URL3], () =>