tor-browser

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

selecturl-flexible-size.https.html (2333B)


      1 <!DOCTYPE html>
      2 <title>Test frame size behavior in selectURL fenced frames.</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 async function runTest(original_width, original_height, new_width, new_height) {
     12  // Attach a selectURL fenced frame whose outer container has dimensions
     13  // `original_width` by `original_height`.
     14  const frame = await attachFencedFrameContext({
     15      generator_api: "sharedstorage", resolve_to_config: true,
     16      attributes: [["width", original_width], ["height", original_height]]});
     17 
     18  const assert_dimensions =
     19      (label, original_width, original_height,
     20       expected_width, expected_height) => {
     21    assert_equals(getComputedStyle(document.documentElement).width,
     22        expected_width+"px",
     23        label + " the computed width (originally " + original_width
     24        + ") should be " + expected_width);
     25    assert_equals(window.innerWidth, expected_width,
     26        label + " the innerWidth (originally " + original_width
     27        + ") should be " + expected_width);
     28    assert_equals(window.innerHeight, expected_height,
     29        label + " the innerHeight (originally " + original_height
     30        + ") should be " + expected_height);
     31  }
     32 
     33  // Assert that the fenced frame sees the original dimensions.
     34  await frame.execute(assert_dimensions, ["After navigation",
     35      original_width, original_height, original_width, original_height]);
     36 
     37  // Assert that the embedder sees the fenced frame's original dimensions.
     38  assert_equals(frame.width, original_width.toString(),
     39      "The outer container width is the requested width.");
     40  assert_equals(frame.height, original_height.toString(),
     41      "The outer container height is the requested height.");
     42 
     43  // Resize the fenced frame's outer container.
     44  frame.width = new_width;
     45  frame.height = new_height;
     46 
     47  // Observe that the selectURL fenced frame sees the new size.
     48  await frame.execute(assert_dimensions, ["After resizing",
     49      original_width, original_height, new_width, new_height]);
     50 }
     51 
     52 // Exact size cases.
     53 promise_test(async () => { return runTest(299, 72, 100, 101); }, '299x72->100x101');
     54 
     55 </script>
     56 </body>