test_img_attributes_reflection.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Test for HTMLImageElement attributes reflection</title>
  5. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  6. <script type="application/javascript" src="reflect.js"></script>
  7. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  8. </head>
  9. <body>
  10. <p id="display"></p>
  11. <div id="content" style="display: none">
  12. </div>
  13. <pre id="test">
  14. <script type="application/javascript">
  15. /** Test for HTMLImageElement attributes reflection **/
  16. reflectString({
  17. element: document.createElement("img"),
  18. attribute: "alt",
  19. })
  20. reflectURL({
  21. element: document.createElement("img"),
  22. attribute: "src",
  23. })
  24. reflectString({
  25. element: document.createElement("img"),
  26. attribute: "srcset",
  27. })
  28. reflectLimitedEnumerated({
  29. element: document.createElement("img"),
  30. attribute: "crossOrigin",
  31. // "" is a valid value per spec, but gets mapped to the "anonymous" state,
  32. // just like invalid values, so just list it under invalidValues
  33. validValues: [ "anonymous", "use-credentials" ],
  34. invalidValues: [
  35. "", " aNOnYmous ", " UsE-CreDEntIALS ", "foobar", "FOOBAR", " fOoBaR "
  36. ],
  37. defaultValue: { invalid: "anonymous", missing: null },
  38. nullable: true,
  39. })
  40. reflectString({
  41. element: document.createElement("img"),
  42. attribute: "useMap",
  43. })
  44. reflectBoolean({
  45. element: document.createElement("img"),
  46. attribute: "isMap",
  47. })
  48. ok("width" in document.createElement("img"), "img.width is present")
  49. ok("height" in document.createElement("img"), "img.height is present")
  50. ok("naturalWidth" in document.createElement("img"), "img.naturalWidth is present")
  51. ok("naturalHeight" in document.createElement("img"), "img.naturalHeight is present")
  52. ok("complete" in document.createElement("img"), "img.complete is present")
  53. reflectString({
  54. element: document.createElement("img"),
  55. attribute: "name",
  56. })
  57. reflectString({
  58. element: document.createElement("img"),
  59. attribute: "align",
  60. })
  61. reflectUnsignedInt({
  62. element: document.createElement("img"),
  63. attribute: "hspace",
  64. })
  65. reflectUnsignedInt({
  66. element: document.createElement("img"),
  67. attribute: "vspace",
  68. })
  69. reflectURL({
  70. element: document.createElement("img"),
  71. attribute: "longDesc",
  72. })
  73. reflectString({
  74. element: document.createElement("img"),
  75. attribute: "border",
  76. extendedAttributes: { TreatNullAs: "EmptyString" },
  77. })
  78. reflectURL({
  79. element: document.createElement("img"),
  80. attribute: "lowsrc",
  81. })
  82. ok("x" in document.createElement("img"), "img.x is present")
  83. ok("y" in document.createElement("img"), "img.y is present")
  84. </script>
  85. </pre>
  86. </body>
  87. </html>