tor-browser

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

font_access_detached_iframe.tentative.https.window.js (1545B)


      1 // META: script=/resources/testdriver.js
      2 // META: script=/resources/testdriver-vendor.js
      3 // META: script=resources/font-test-utils.js
      4 // META: timeout=long
      5 
      6 'use strict';
      7 
      8 font_access_test(async t => {
      9  const iframe = document.createElement('iframe');
     10  document.body.appendChild(iframe);
     11 
     12  const frameWindow = iframe.contentWindow;
     13  const frameDOMException = iframe.contentWindow.DOMException;
     14  iframe.remove();
     15 
     16  await promise_rejects_dom(
     17      t, 'InvalidStateError', frameDOMException, frameWindow.queryLocalFonts());
     18 }, 'queryLocalFonts() must return an error when called from a detached frame.');
     19 
     20 font_access_test(async t => {
     21  const iframe = document.createElement('iframe');
     22  document.body.appendChild(iframe);
     23 
     24  iframe.contentWindow.queryLocalFonts;
     25  iframe.remove();
     26 
     27  // Call queryLocalFonts() in the main frame. This should keep the test running
     28  // long enough to catch any crash from the queryLocalFonts() call in the
     29  // removed iframe.
     30  await self.queryLocalFonts();
     31 }, 'Detaching iframe while queryLocalFonts() settles.');
     32 
     33 font_access_test(async t => {
     34  const iframe = document.createElement('iframe');
     35  document.body.appendChild(iframe);
     36 
     37  const iframeFonts = await iframe.contentWindow.queryLocalFonts();
     38  assert_greater_than_equal(iframeFonts.length, 1, 'Need a least one font');
     39  const iframeFontData = iframeFonts[0];
     40  const frameDOMException = iframe.contentWindow.DOMException;
     41  iframe.remove();
     42 
     43  iframeFontData.blob();
     44 }, 'FontData.blob() should not crash when called from a detached iframe.');