tor-browser

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

Image-constructor.html (1932B)


      1 <!DOCTYPE HTML>
      2 <title>DOM Image constructor Test</title>
      3 <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
      4 <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-img-element" />
      5 <meta name="assert" content="Tests the Image constructor for the img-element">
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 
      9 
     10 <div id="log"></div>
     11 <script>
     12  test(function() {
     13    var img = new Image();
     14    assert_true(img != undefined);
     15  }, "Image constructor works");
     16 
     17  test(function() {
     18    assert_equals(Image.prototype, HTMLImageElement.prototype);
     19  }, "Image and HTMLImageElement share a prototype");
     20 
     21  test(function() {
     22    assert_true((new Image()).localName === "img");
     23  }, "Image localName is img");
     24 
     25  test(function() {
     26    assert_true((new Image()).namespaceURI === "http://www.w3.org/1999/xhtml");
     27  }, "Image namespace URI is correct");
     28 
     29  test(function() {
     30      assert_equals(Image.name, "Image", "Image name should be Image (not HTMLImageElement)");
     31      assert_equals(Object.getPrototypeOf(Image), Function.prototype, "Image's prototype is Function.prototype");
     32      assert_equals(Image.prototype, HTMLImageElement.prototype, "Image.prototype is same as HTMLImageElement.prototype");
     33      assert_equals(Object.getPrototypeOf(new Image()), HTMLImageElement.prototype, "new Image()'s prototype is HTMLImageElement.prototype ");
     34      assert_equals(Object.getPrototypeOf(Image.prototype), HTMLElement.prototype, "Image.prototype's prototype is HTMLElement.prototype");
     35 
     36      const desc = Object.getOwnPropertyDescriptor(Image, "prototype");
     37      assert_false(desc.configurable, "Image.prototype is not configurable");
     38      assert_false(desc.enumerable, "Image.prototype is not enumerable");
     39      assert_false(desc.writable, "Image.prototype is not writable");
     40  }, "NamedConstructor creates the correct object structure.");
     41 
     42 </script>