Treat Apple touch icons as maskable
This commit is contained in:
1 parent
c28f2d066d
commit
5928406524
2 files changed
+42
-2
No files matched your search
@@ -86,7 +86,9 @@ function fallbackCandidates(origin) {
|
||||
rel: 'fallback',
|
||||
type: 'image/png',
|
||||
width: 0,
|
||||
maskable: false,
|
||||
// Apple touch icons are authored for iOS's rounded-square mask, so the
|
||||
// well-known path is treated the same as a declared one.
|
||||
maskable: true,
|
||||
},
|
||||
{
|
||||
url: `${origin}/favicon.ico`,
|
||||
@@ -206,7 +208,9 @@ export default class SiteIconsService extends Service {
|
||||
rel: isApple ? 'apple-touch-icon' : 'icon',
|
||||
type: link.getAttribute('type') || null,
|
||||
width: parseWidth(link.getAttribute('sizes')),
|
||||
maskable: false,
|
||||
// iOS renders touch icons inside a rounded-square mask, so they're
|
||||
// already shaped for our tile and can safely render full-bleed.
|
||||
maskable: isApple,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,42 @@ module('Unit | Service | site-icons', function (hooks) {
|
||||
const record = await service.iconFor('https://forum.example.com');
|
||||
|
||||
assert.strictEqual(record.href, 'https://forum.example.com/touch.png');
|
||||
assert.true(record.maskable);
|
||||
});
|
||||
|
||||
test('it prefers a declared apple-touch-icon and marks it maskable', async function (assert) {
|
||||
const service = this.owner.lookup('service:site-icons');
|
||||
|
||||
service.http.requestText = async () =>
|
||||
'<html><head><link rel="icon" href="/favicon.ico"><link rel="apple-touch-icon" href="/touch.png"></head></html>';
|
||||
service.http.requestBlob = async () => blob('icon', 'image/png');
|
||||
|
||||
const record = await service.iconFor('https://forum.example.com');
|
||||
|
||||
assert.strictEqual(record.href, 'https://forum.example.com/touch.png');
|
||||
assert.true(record.maskable);
|
||||
});
|
||||
|
||||
test('it treats the fallback apple-touch-icon as maskable', async function (assert) {
|
||||
const service = this.owner.lookup('service:site-icons');
|
||||
|
||||
service.http.requestText = async () => {
|
||||
throw new Error('blocked by CORS');
|
||||
};
|
||||
service.http.requestBlob = async (url) => {
|
||||
if (url.endsWith('/apple-touch-icon.png')) {
|
||||
return blob('icon', 'image/png');
|
||||
}
|
||||
throw new Error('not found');
|
||||
};
|
||||
|
||||
const record = await service.iconFor('https://forum.example.com');
|
||||
|
||||
assert.strictEqual(
|
||||
record.href,
|
||||
'https://forum.example.com/apple-touch-icon.png'
|
||||
);
|
||||
assert.true(record.maskable);
|
||||
});
|
||||
|
||||
test('it resolves nothing when every candidate fails', async function (assert) {
|
||||
|
||||
Reference in new issue
Block a user