File: naturalWidth-naturalHeight.html

package info (click to toggle)
firefox 144.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,637,504 kB
  • sloc: cpp: 7,576,692; javascript: 6,430,831; ansic: 3,748,119; python: 1,398,978; xml: 628,810; asm: 438,679; java: 186,194; sh: 63,212; makefile: 19,159; objc: 13,086; perl: 12,986; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (42 lines) | stat: -rw-r--r-- 2,728 bytes parent folder | download | duplicates (10)
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
<!doctype html>
<title>HTMLImageElement.prototype.naturalWidth/naturalHeight</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<img src="resources/cat.jpg"
     title="raster image" data-width="320" data-height="240">
<img src="resources/cat.jpg" width="10" height="10"
     title="raster image with width/height attributes" data-width="320" data-height="240">
<img src="non-existent.jpg"
     title="non existent image, no natural dimensions" data-width="0" data-height="0">
<img src="non-existent.jpg" width="10" height="10"
     title="non existent image with width/height attributes, no natural dimensions" data-width="0" data-height="0">
<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>"
     title="SVG image, no natural dimensions" data-width="0" data-height="0">
<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='500' height='400'></svg>"
     title="SVG image, width/height in pixels" data-width="500" data-height="400">
<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='500'></svg>"
     title="SVG image, width in pixels; height unspecified" data-width="500" data-height="0">
<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='500' height='100%'></svg>"
     title="SVG image, width in pixels; percentage height" data-width="500" data-height="0">
<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='500' height='400' viewBox='0 0 800 600'></svg>"
     title="SVG image, width/height in pixels; viewBox" data-width="500" data-height="400">
<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 600'></svg>"
     title="SVG image, width/height unspecified; viewBox" data-width="0" data-height="0">
<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='400' viewBox='0 0 800 600'></svg>"
     title="SVG image, width in pixels; height unspecified; viewBox" data-width="400" data-height="300">
<img src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' height='300' viewBox='0 0 800 600'></svg>"
     title="SVG image, width unspecified; height in pixels; viewBox" data-width="400" data-height="300">
<script>
setup({explicit_done:true});
onload = function() {
  Array.from(document.images).forEach(img => {
    test(function() {
      const expectedWidth = parseFloat(img.dataset.width);
      const expectedHeight = parseFloat(img.dataset.height);
      assert_equals(img.naturalWidth, expectedWidth, 'naturalWidth');
      assert_equals(img.naturalHeight, expectedHeight, 'naturalHeight');
    }, `${document.title}, ${img.title}`);
  });
  done();
};
</script>