tor-browser

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

fledge-container-size-mutation-observer.https.html (1807B)


      1 <!DOCTYPE html>
      2 <title>Test that mutation observer doesn't break noassert container size setter.</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="/common/utils.js"></script>
      6 <script src="/common/dispatcher/dispatcher.js"></script>
      7 <script src="resources/utils.js"></script>
      8 
      9 <body>
     10 <script>
     11 
     12 async function checkMutationObserver() {
     13  // Create a FLEDGE FF with a constant content size and given container size.
     14  const requested_width_1 = '299px';
     15  const requested_height_1 = '72px';
     16  const frame = await attachFencedFrameContext({
     17      generator_api: 'fledge', resolve_to_config: true, ad_with_size: true,
     18      requested_size: [requested_width_1, requested_height_1]});
     19 
     20  // Install a mutation observer.
     21  const config = { attributes: true, childList: true, subtree: true };
     22  const callback = (mutationList, observer) => {
     23    throw new Error("mutation observed");
     24  }
     25  const observer = new MutationObserver(callback);
     26  observer.observe(frame.element, config);
     27 
     28  // Modify the container size manually.
     29  const modified_width = '121px';
     30  const modified_height = '444px';
     31  frame.element.width = modified_width;
     32  frame.element.height = modified_height;
     33 
     34  // Navigate to a new FLEDGE FF config with a different container size.
     35  const requested_width_2 = '321px';
     36  const requested_height_2 = '49px';
     37  const replaced_frame = await replaceFrameContext(frame, {
     38      generator_api: 'fledge', resolve_to_config: true, ad_with_size: true,
     39      requested_size: [requested_width_2, requested_height_2]});
     40 
     41  observer.disconnect();
     42 }
     43 
     44 setup({allow_uncaught_exception: true});
     45 promise_test(async () => { return checkMutationObserver(); }, 'Container size assert no exception ignores mutation observer');
     46 
     47 </script>
     48 </body>