browser_rich_icons.js (2411B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 /* eslint-disable mozilla/no-arbitrary-setTimeout */ 5 6 const ROOT = 7 "http://mochi.test:8888/browser/browser/base/content/test/favicons/"; 8 9 add_task(async function test_richIcons() { 10 const URL = ROOT + "file_rich_icon.html"; 11 const EXPECTED_ICON = ROOT + "moz.png"; 12 const EXPECTED_RICH_ICON = ROOT + "rich_moz_2.png"; 13 14 let tabPromises = Promise.all([ 15 waitForFaviconMessage(true, EXPECTED_ICON), 16 waitForFaviconMessage(false, EXPECTED_RICH_ICON), 17 ]); 18 19 const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL); 20 let [tabIcon, richIcon] = await tabPromises; 21 22 is( 23 richIcon.iconURL, 24 EXPECTED_RICH_ICON, 25 "should choose the largest rich icon" 26 ); 27 is( 28 tabIcon.iconURL, 29 EXPECTED_ICON, 30 "should use the non-rich icon for the tab" 31 ); 32 33 BrowserTestUtils.removeTab(tab); 34 }); 35 36 add_task(async function test_maskIcons() { 37 const URL = ROOT + "file_mask_icon.html"; 38 const EXPECTED_ICON = "http://mochi.test:8888/favicon.ico"; 39 40 let promise = waitForFaviconMessage(true, EXPECTED_ICON); 41 const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL); 42 let tabIcon = await promise; 43 is( 44 tabIcon.iconURL, 45 EXPECTED_ICON, 46 "should ignore the mask icons and load the root favicon" 47 ); 48 49 BrowserTestUtils.removeTab(tab); 50 }); 51 52 add_task(async function test_richIconInfo_rich() { 53 const URL = ROOT + "file_rich_icon.html"; 54 const EXPECTED_RICH_ICON = ROOT + "rich_moz_2.png"; 55 56 let richIconPromise = waitForFaviconMessage(false, EXPECTED_RICH_ICON); 57 58 const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL); 59 let richIcon = await richIconPromise; 60 61 is(richIcon.iconURL, EXPECTED_RICH_ICON, "should load rich icon"); 62 63 ok(richIcon.isRichIcon, "isRichIcon flag should be passed for rich icons"); 64 65 BrowserTestUtils.removeTab(tab); 66 }); 67 68 add_task(async function test_richIconInfo_notRich() { 69 const URL = ROOT + "file_rich_icon.html"; 70 const EXPECTED_ICON = ROOT + "moz.png"; 71 72 let iconPromise = waitForFaviconMessage(true, EXPECTED_ICON); 73 74 const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL); 75 let icon = await iconPromise; 76 77 is(icon.iconURL, EXPECTED_ICON, "should load icon"); 78 79 ok(!icon.isRichIcon, "isRichIcon flag should be passed as false"); 80 81 BrowserTestUtils.removeTab(tab); 82 });