Skip to content

Commit

Permalink
Reduce flakes on local font access WPT tests by marking them slow.
Browse files Browse the repository at this point in the history
Window.queryLocalFonts() or FontData.blob() JS API for enumerating
local fonts could take longer than the default 6-second test timeout
on some platforms (e.g. Mac Release) when called the first time.
Marking the tests as slow WPT test to prevent this flakiness. For this:

- Removed the relevant flaky TestExpectation entries added
automatically by wpt importer.
- Marked the relevant js and html files for font access WPT files as
slow:
  - https://web-platform-tests.org/writing-tests/testharness.html
#specifying-a-timeout-of-long
  - https://web-platform-tests.org/writing-tests/testharness-api.html
#harness-timeout

Bug: 1502008
Change-Id: I2075408aa1c563b0495ad6d0abecbcf078dd5e96
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5034577
Auto-Submit: Hakan Isbiliroglu <[email protected]>
Reviewed-by: Brad Triebwasser <[email protected]>
Reviewed-by: Ayu Ishii <[email protected]>
Commit-Queue: Ayu Ishii <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1227107}
  • Loading branch information
blackseawave authored and chromium-wpt-export-bot committed Nov 21, 2023
1 parent 0fafa63 commit c8ecca5
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 47 deletions.
14 changes: 7 additions & 7 deletions font-access/font_access_basic.tentative.https.window.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//META: script=/resources/testdriver.js
//META: script=/resources/testdriver-vendor.js
//META: script=resources/font-asserts.js
//META: script=resources/font-data.js
//META: script=resources/font-test-utils.js
// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: script=resources/font-asserts.js
// META: script=resources/font-data.js
// META: script=resources/font-test-utils.js
// META: timeout=long

'use strict';

Expand All @@ -23,8 +24,7 @@ font_access_test(async t => {
assert_equals(typeof font.postscriptName, 'string');
assert_true(
font.postscriptName.split('').every(c => (' ' <= c && c < '\x7f')),
`postscriptName should be printable ASCII: "${font.postscriptName}"`
);
`postscriptName should be printable ASCII: "${font.postscriptName}"`);
assert_equals(typeof font.fullName, 'string', 'fullName attribute type');
assert_equals(typeof font.family, 'string', 'family attribute type');
assert_equals(typeof font.style, 'string', 'style attribute type');
Expand Down
13 changes: 7 additions & 6 deletions font-access/font_access_blob.tentative.https.window.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//META: script=/resources/testdriver.js
//META: script=/resources/testdriver-vendor.js
//META: script=resources/font-asserts.js
//META: script=resources/font-data.js
//META: script=resources/font-test-utils.js
// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: script=resources/font-asserts.js
// META: script=resources/font-data.js
// META: script=resources/font-test-utils.js
// META: timeout=long

'use strict';

Expand All @@ -26,7 +27,7 @@ font_access_test(async t => {
const parsedData = await parseFontData(data);
assert_version_info(parsedData.versionTag);
assert_not_equals(
parsedData.tables.size, 0, "Should not have tables of size zero.");
parsedData.tables.size, 0, 'Should not have tables of size zero.');
assert_font_has_tables(font.postscriptName, parsedData.tables, BASE_TABLES);
}
}, 'FontData.blob(): blob has expected format and parsable table data.');
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//META: script=/resources/testdriver.js
//META: script=/resources/testdriver-vendor.js
//META: script=resources/font-test-utils.js
// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: script=resources/font-test-utils.js
// META: timeout=long

'use strict';

Expand Down
5 changes: 3 additions & 2 deletions font-access/font_access_permission.tentative.https.window.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//META: script=/resources/testdriver.js
//META: script=/resources/testdriver-vendor.js
// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: timeout=long

'use strict';

Expand Down
35 changes: 14 additions & 21 deletions font-access/font_access_query_select.tentative.https.window.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
//META: script=/resources/testdriver.js
//META: script=/resources/testdriver-vendor.js
//META: script=resources/font-asserts.js
//META: script=resources/font-data.js
//META: script=resources/font-test-utils.js
// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: script=resources/font-asserts.js
// META: script=resources/font-data.js
// META: script=resources/font-test-utils.js
// META: timeout=long

font_access_test(async t => {
const testData = getTestData();
assert_greater_than_equal(
testData.size, 1, 'Need a least one test font data.');
const testFont = testData.values().next().value;

const queryInput = {
postscriptNames: [testFont.postscriptName]
};
const queryInput = {postscriptNames: [testFont.postscriptName]};
const fonts = await self.queryLocalFonts(queryInput);

assert_equals(
Expand All @@ -21,9 +20,7 @@ font_access_test(async t => {
}, 'queryLocalFonts(): valid postscript name in QueryOptions');

font_access_test(async t => {
const queryInput = {
postscriptNames: ['invalid_postscript_name']
};
const queryInput = {postscriptNames: ['invalid_postscript_name']};
const fonts = await self.queryLocalFonts(queryInput);

assert_equals(
Expand All @@ -40,27 +37,23 @@ font_access_test(async t => {
}, 'queryLocalFonts(): empty object for QueryOptions.postscriptNames');

font_access_test(async t => {
const queryInput = {
invalidFieldName: []
};
const queryInput = {invalidFieldName: []};
const fonts = await self.queryLocalFonts(queryInput);

assert_greater_than_equal(
fonts.length, 1,
'All available fonts should be returned when an invalid field name for ' +
'QueryOptions is passed.');
'QueryOptions is passed.');
}, 'queryLocalFonts(): invalid QueryOptions field');

font_access_test(async t => {
const queryInput = {
postscriptNames: []
};
const queryInput = {postscriptNames: []};
const fonts = await self.queryLocalFonts(queryInput);

assert_equals(
fonts.length, 0,
'Fonts should not be selected when an empty list for ' +
'QueryOptions.postscriptNames is passed.');
'QueryOptions.postscriptNames is passed.');
}, 'queryLocalFonts(): empty QueryOptions.postscriptNames list');

font_access_test(async t => {
Expand All @@ -69,7 +62,7 @@ font_access_test(async t => {
assert_greater_than_equal(
fonts.length, 1,
'All available fonts should be returned when undefined is passed for ' +
'input.');
'input.');
}, 'queryLocalFonts(): undefined QueryOptions');

const non_ascii_input = [
Expand All @@ -96,6 +89,6 @@ for (const test of non_ascii_input) {
assert_equals(
fonts.length, 0,
'Fonts should not be selected for non-ASCII character input: ' +
JSON.stringify(fonts));
JSON.stringify(fonts));
}, `queryLocalFonts(): non-ASCII character input: ${JSON.stringify(test)}`);
}
9 changes: 5 additions & 4 deletions font-access/font_access_sorted.tentative.https.window.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//META: script=/resources/testdriver.js
//META: script=/resources/testdriver-vendor.js
//META: script=resources/font-asserts.js
//META: script=resources/font-test-utils.js
// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: script=resources/font-asserts.js
// META: script=resources/font-test-utils.js
// META: timeout=long

'use strict';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!DOCTYPE html>
<meta name="timeout" content="long"> <!-- this is a long-running test at least on some platforms ! -->
<body>
<script src=/font-access/resources/font-test-utils.js></script>
<script src=/resources/testharness.js></script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!DOCTYPE html>
<meta name="timeout" content="long"> <!-- this is a long-running test at least on some platforms ! -->
<body>
<script src=/font-access/resources/font-test-utils.js></script>
<script src=/resources/testharness.js></script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!DOCTYPE html>
<meta name="timeout" content="long"> <!-- this is a long-running test at least on some platforms ! -->
<body>
<script src=/font-access/resources/font-test-utils.js></script>
<script src=/resources/testharness.js></script>
Expand Down
7 changes: 3 additions & 4 deletions font-access/resources/font-test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ async function getTableData(fontBlob, numTables) {
}

async function getTag(blob, offset) {
return (new TextDecoder).decode(
await blob.slice(offset, offset + 4).arrayBuffer());
return (new TextDecoder)
.decode(await blob.slice(offset, offset + 4).arrayBuffer());
}

async function getUint16(blob, offset) {
Expand Down Expand Up @@ -91,8 +91,7 @@ function isPlatformSupported() {
function font_access_test(test_function, name, properties) {
return promise_test(async (t) => {
if (!isPlatformSupported()) {
await promise_rejects_dom(
t, 'NotSupportedError', self.queryLocalFonts());
await promise_rejects_dom(t, 'NotSupportedError', self.queryLocalFonts());
return;
}
await test_driver.set_permission({name: 'local-fonts'}, 'granted');
Expand Down

0 comments on commit c8ecca5

Please sign in to comment.