tor-browser

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

audio_constructor.html (1966B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>Audio constructor</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <div id=log></div>
      7 <script>
      8 test(function() {
      9  var throwingObject = {
     10    toString: function() { throw Error() },
     11    valueOf: function() { throw Error() }
     12  };
     13  var tests = [
     14    [function() { return new Audio() }, null, "No arguments"],
     15    [function() { return new Audio("") }, "", "Empty string argument"],
     16    [function() { return new Audio("src") }, "src", "Non-empty string argument"],
     17    [function() { return new Audio(null) }, "null", "Null argument"],
     18    [function() { return new Audio(undefined) }, null, "Undefined argument"],
     19    [function() { return new Audio("", throwingObject) }, "", "Extra argument"],
     20  ];
     21  tests.forEach(function(t) {
     22    var fn = t[0], expectedSrc = t[1], description = t[2];
     23    test(function() {
     24      var element = fn();
     25      assert_equals(element.localName, "audio");
     26      assert_equals(element.tagName, "AUDIO");
     27      assert_equals(element.namespaceURI, "http://www.w3.org/1999/xhtml");
     28      assert_equals(element.nodeType, Node.ELEMENT_NODE);
     29      assert_equals(element.getAttribute("preload"), "auto");
     30      assert_equals(element.getAttribute("src"), expectedSrc);
     31      assert_equals(element.ownerDocument, document);
     32    }, description);
     33  });
     34 });
     35 
     36 test(function() {
     37  var audio = new Audio();
     38  assert_equals(Object.getPrototypeOf(audio), HTMLAudioElement.prototype);
     39 }, "Prototype of object created with named constructor");
     40 
     41 test(function() {
     42  assert_throws_js(TypeError, function() {
     43    Audio();
     44  });
     45 }, "Calling Audio should throw");
     46 test(function() {
     47  assert_throws_js(TypeError, function() {
     48    HTMLAudioElement();
     49  });
     50 }, "Calling HTMLAudioElement should throw");
     51 test(function() {
     52  assert_throws_js(TypeError, function() {
     53    new HTMLAudioElement();
     54  });
     55 }, "Constructing HTMLAudioElement should throw");
     56 </script>