Commit 7669c4b5 authored by Olivier Yiptong's avatar Olivier Yiptong Committed by Chromium LUCI CQ

[Code Health] FontAccess: Consolidate WPT feature detection assertions

This change consolidates feature detection assertions in Local Font
Access WPT tests in the test helper to diminish line noise.

Change-Id: I9a95504c7ddc82c741ee5ca32d456b20f557905b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2643794
Auto-Submit: Olivier Yiptong <oyiptong@chromium.org>
Commit-Queue: Joshua Bell <jsbell@chromium.org>
Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846341}
parent 6db02d09
...@@ -492,6 +492,11 @@ async function simulateUserActivation() { ...@@ -492,6 +492,11 @@ async function simulateUserActivation() {
function font_access_test(test_function, name, properties) { function font_access_test(test_function, name, properties) {
return promise_test(async (t) => { return promise_test(async (t) => {
if (!isPlatformSupported()) {
await promise_rejects_dom(
t, 'NotSupportedError', navigator.fonts.query());
return;
}
await test_driver.set_permission({name: 'font-access'}, 'granted'); await test_driver.set_permission({name: 'font-access'}, 'granted');
await simulateUserActivation(); await simulateUserActivation();
await test_function(t, name, properties); await test_function(t, name, properties);
......
'use strict'; 'use strict';
font_access_test(async t => { font_access_test(async t => {
if (!isPlatformSupported()) {
await promise_rejects_dom(t, 'NotSupportedError', navigator.fonts.query());
return;
}
const fonts = await navigator.fonts.query({persistentAccess: true}); const fonts = await navigator.fonts.query({persistentAccess: true});
const expectedFonts = await filterEnumeration( const expectedFonts = await filterEnumeration(
fonts, getEnumerationTestSet({labelFilter: [TEST_SIZE_CATEGORY.small]})); fonts, getEnumerationTestSet({labelFilter: [TEST_SIZE_CATEGORY.small]}));
......
...@@ -9,12 +9,6 @@ for (const test of standard_fonts_tests) { ...@@ -9,12 +9,6 @@ for (const test of standard_fonts_tests) {
const inputAsString = JSON.stringify(test) ? JSON.stringify(test) : test; const inputAsString = JSON.stringify(test) ? JSON.stringify(test) : test;
font_access_test(async t => { font_access_test(async t => {
if (!isPlatformSupported()) {
await promise_rejects_dom(
t, 'NotSupportedError', navigator.fonts.query());
return;
}
const fonts = const fonts =
await navigator.fonts.query({persistentAccess: true, ...test}); await navigator.fonts.query({persistentAccess: true, ...test});
...@@ -23,11 +17,6 @@ for (const test of standard_fonts_tests) { ...@@ -23,11 +17,6 @@ for (const test of standard_fonts_tests) {
} }
font_access_test(async t => { font_access_test(async t => {
if (!isPlatformSupported()) {
await promise_rejects_dom(t, 'NotSupportedError', navigator.fonts.query());
return;
}
const fonts = await navigator.fonts.query({persistentAccess: true}); const fonts = await navigator.fonts.query({persistentAccess: true});
// The following tests that fonts are sorted. Postscript names are expected to // The following tests that fonts are sorted. Postscript names are expected to
// be encoded in a subset of the ASCII character set. // be encoded in a subset of the ASCII character set.
...@@ -48,11 +37,6 @@ font_access_test(async t => { ...@@ -48,11 +37,6 @@ font_access_test(async t => {
}, 'query(): fonts are sorted'); }, 'query(): fonts are sorted');
font_access_test(async t => { font_access_test(async t => {
if (!isPlatformSupported()) {
await promise_rejects_dom(t, 'NotSupportedError', navigator.fonts.query());
return;
}
const test = { const test = {
persistentAccess: true, persistentAccess: true,
select: [getEnumerationTestSet()[0].postscriptName] select: [getEnumerationTestSet()[0].postscriptName]
...@@ -85,12 +69,6 @@ const non_ascii_input = [ ...@@ -85,12 +69,6 @@ const non_ascii_input = [
for (const test of non_ascii_input) { for (const test of non_ascii_input) {
font_access_test(async t => { font_access_test(async t => {
if (!isPlatformSupported()) {
await promise_rejects_dom(
t, 'NotSupportedError', navigator.fonts.query());
return;
}
const fonts = const fonts =
await navigator.fonts.query({persistentAccess: true, ...test}); await navigator.fonts.query({persistentAccess: true, ...test});
assert_equals( assert_equals(
......
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