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