File: image-x-y-zoom.html

package info (click to toggle)
firefox 149.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,767,760 kB
  • sloc: cpp: 7,416,064; javascript: 6,752,859; ansic: 3,774,850; python: 1,250,473; xml: 641,578; asm: 439,191; java: 186,617; sh: 56,634; makefile: 18,856; objc: 13,092; perl: 12,763; pascal: 5,960; yacc: 4,583; cs: 3,846; lex: 1,720; ruby: 1,002; php: 436; lisp: 258; awk: 105; sql: 66; sed: 53; csh: 10; exp: 6
file content (66 lines) | stat: -rw-r--r-- 3,383 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<title>x and y properties for image elements with css zoom</title>
<link rel="author" title="Yotam Hacohen" href="mailto:yotha@chromium.org">
<link rel="author" title="Google" href="http://www.google.com/">
<link rel="help" href="https://drafts.csswg.org/cssom-view/#dom-element-scroll">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
  <head>
    <style>
      img {
        display: block;
      }
      .container {
        height: 100px;
        width: 100px;
      }

      #x4_zoom_container {
        zoom: 4;
      }

    </style>
  </head>
  <body>
    <div class="container" id="no_zoom_container">
      <img src="support/1x1-green.png" id="no_zoom_image_no_zoom_container">
      <img src="support/1x1-navy.png" style="zoom: 2;" id="x2_zoom_image_no_zoom_container">
    </div>

    <div class="container" id="x4_zoom_container">
      <img style="position: relative; top: 10px;" src="support/1x1-maroon.png" id="no_zoom_image_x4_zoom_container">
      <img src="support/1x1-navy.png" style="zoom: 2;" id="x2_zoom_image_x4_zoom_container">
      <img src="support/1x1-red.png" style="transform: scale(5);" id="transformed_and_zoomed_image">
    </div>
    <script>
        function compareXYCoordinatesToBoundingBox(object, object_name){
          assert_equals(object.x, object.getBoundingClientRect().left, object_name + ' x');
          assert_equals(object.y, object.getBoundingClientRect().top, object_name + ' y');
        }

        window.onload = function() {
        test(function() {
          // Values should be same as values of getBoundingClientRect
          compareXYCoordinatesToBoundingBox(no_zoom_image_no_zoom_container, 'no-zoom image in a no-zoom container');
          compareXYCoordinatesToBoundingBox(x2_zoom_image_no_zoom_container, 'image with css zoom in a no zoom container');
          compareXYCoordinatesToBoundingBox(no_zoom_image_x4_zoom_container, 'no-zoom image in a container with css zoom');
          compareXYCoordinatesToBoundingBox(x2_zoom_image_x4_zoom_container, 'both image and container have css zoom');
        });
        test(function() {
          // Values should be in the root coordinate system, and affected by zoom
          assert_equals(no_zoom_image_no_zoom_container.x, 8, 'no zoom image no zoom container x');
          assert_equals(no_zoom_image_no_zoom_container.y, 8, 'no zoom image no zoom container y');
          assert_equals(x2_zoom_image_no_zoom_container.x, 8, 'x2 zoom image no zoom container x');
          assert_equals(x2_zoom_image_no_zoom_container.y, 9, 'x2 zoom image no zoom container y');
          assert_equals(no_zoom_image_x4_zoom_container.x, 8, 'no zoom image x4 zoom container x');
          // This element also has a position-top, which is affected by zoom
          assert_equals(no_zoom_image_x4_zoom_container.y, 148, 'no zoom image x4 zoom container y');
          assert_equals(x2_zoom_image_x4_zoom_container.x, 8, 'x2 zoom image x4 zoom container x');
          assert_equals(x2_zoom_image_x4_zoom_container.y, 112, 'x2 zoom image x4 zoom container y');
          assert_equals(transformed_and_zoomed_image.x, 8, 'image with transform properties x');
          assert_equals(transformed_and_zoomed_image.y, 120, 'image with transform properties y');
        });
      };

      </script>
  </body>