tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

font_access_basic.tentative.https.window.js (1524B)


      1 // META: script=/resources/testdriver.js
      2 // META: script=/resources/testdriver-vendor.js
      3 // META: script=resources/font-asserts.js
      4 // META: script=resources/font-data.js
      5 // META: script=resources/font-test-utils.js
      6 // META: timeout=long
      7 
      8 'use strict';
      9 
     10 font_access_test(async t => {
     11  // Fonts we know about. Not all expected fonts are included.
     12  const testData = getTestData();
     13 
     14  // Get the system fonts.
     15  const fonts = await self.queryLocalFonts();
     16  assert_true(Array.isArray(fonts), 'Result of query() should be an Array');
     17  assert_greater_than_equal(fonts.length, 1, 'Need a least one font');
     18 
     19  fonts.forEach(font => {
     20    assert_true(
     21        font instanceof FontData, 'Results should be FontData instances');
     22 
     23    // Verify properties and types.
     24    assert_equals(typeof font.postscriptName, 'string');
     25    assert_true(
     26        font.postscriptName.split('').every(c => (' ' <= c && c < '\x7f')),
     27        `postscriptName should be printable ASCII: "${font.postscriptName}"`);
     28    assert_equals(typeof font.fullName, 'string', 'fullName attribute type');
     29    assert_equals(typeof font.family, 'string', 'family attribute type');
     30    assert_equals(typeof font.style, 'string', 'style attribute type');
     31 
     32    // If the sample test data contains the returned system font,
     33    // then verify the values of FontData.
     34    const expectedFont = testData.get(font.postscriptName);
     35    if (expectedFont) {
     36      assert_font_equals(font, expectedFont);
     37    }
     38  });
     39 }, 'queryLocalFonts(): FontData property types and values');