tor-browser

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

image-x-y-zoom.html (3383B)


      1 <!DOCTYPE html>
      2 <title>x and y properties for image elements with css zoom</title>
      3 <link rel="author" title="Yotam Hacohen" href="mailto:yotha@chromium.org">
      4 <link rel="author" title="Google" href="http://www.google.com/">
      5 <link rel="help" href="https://drafts.csswg.org/cssom-view/#dom-element-scroll">
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8  <head>
      9    <style>
     10      img {
     11        display: block;
     12      }
     13      .container {
     14        height: 100px;
     15        width: 100px;
     16      }
     17 
     18      #x4_zoom_container {
     19        zoom: 4;
     20      }
     21 
     22    </style>
     23  </head>
     24  <body>
     25    <div class="container" id="no_zoom_container">
     26      <img src="support/1x1-green.png" id="no_zoom_image_no_zoom_container">
     27      <img src="support/1x1-navy.png" style="zoom: 2;" id="x2_zoom_image_no_zoom_container">
     28    </div>
     29 
     30    <div class="container" id="x4_zoom_container">
     31      <img style="position: relative; top: 10px;" src="support/1x1-maroon.png" id="no_zoom_image_x4_zoom_container">
     32      <img src="support/1x1-navy.png" style="zoom: 2;" id="x2_zoom_image_x4_zoom_container">
     33      <img src="support/1x1-red.png" style="transform: scale(5);" id="transformed_and_zoomed_image">
     34    </div>
     35    <script>
     36        function compareXYCoordinatesToBoundingBox(object, object_name){
     37          assert_equals(object.x, object.getBoundingClientRect().left, object_name + ' x');
     38          assert_equals(object.y, object.getBoundingClientRect().top, object_name + ' y');
     39        }
     40 
     41        window.onload = function() {
     42        test(function() {
     43          // Values should be same as values of getBoundingClientRect
     44          compareXYCoordinatesToBoundingBox(no_zoom_image_no_zoom_container, 'no-zoom image in a no-zoom container');
     45          compareXYCoordinatesToBoundingBox(x2_zoom_image_no_zoom_container, 'image with css zoom in a no zoom container');
     46          compareXYCoordinatesToBoundingBox(no_zoom_image_x4_zoom_container, 'no-zoom image in a container with css zoom');
     47          compareXYCoordinatesToBoundingBox(x2_zoom_image_x4_zoom_container, 'both image and container have css zoom');
     48        });
     49        test(function() {
     50          // Values should be in the root coordinate system, and affected by zoom
     51          assert_equals(no_zoom_image_no_zoom_container.x, 8, 'no zoom image no zoom container x');
     52          assert_equals(no_zoom_image_no_zoom_container.y, 8, 'no zoom image no zoom container y');
     53          assert_equals(x2_zoom_image_no_zoom_container.x, 8, 'x2 zoom image no zoom container x');
     54          assert_equals(x2_zoom_image_no_zoom_container.y, 9, 'x2 zoom image no zoom container y');
     55          assert_equals(no_zoom_image_x4_zoom_container.x, 8, 'no zoom image x4 zoom container x');
     56          // This element also has a position-top, which is affected by zoom
     57          assert_equals(no_zoom_image_x4_zoom_container.y, 148, 'no zoom image x4 zoom container y');
     58          assert_equals(x2_zoom_image_x4_zoom_container.x, 8, 'x2 zoom image x4 zoom container x');
     59          assert_equals(x2_zoom_image_x4_zoom_container.y, 112, 'x2 zoom image x4 zoom container y');
     60          assert_equals(transformed_and_zoomed_image.x, 8, 'image with transform properties x');
     61          assert_equals(transformed_and_zoomed_image.y, 120, 'image with transform properties y');
     62        });
     63      };
     64 
     65      </script>
     66  </body>