Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebIDL tests #271

Open
wants to merge 116 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
ba4eff3
Record some notes on features to use as the basis of Web IDL tests.
heycam May 4, 2013
a26923c
Add a few Web IDL tests.
heycam May 4, 2013
7322280
Add a utility function for asserting a property descriptor's attributes.
heycam May 5, 2013
b74950d
A test for named constructor objects.
heycam May 5, 2013
696d45b
Don't use test in assert_properties; more helpers.
heycam May 5, 2013
e189021
Tests for [NamedPropertiesObject].
heycam May 5, 2013
de6410f
Add entries to manifest.
heycam May 5, 2013
38fd370
Test for [NoInterfaceObject].
heycam May 5, 2013
72fc51c
Fix bugs in NamedPropertiesObject-002.
heycam May 5, 2013
344cb88
Use <form>s instead of <iframe>s.
heycam May 5, 2013
8653de8
Another test for [NamedPropertiesObject].
heycam May 5, 2013
786a43f
Tests for [OverrideBuiltins].
heycam May 5, 2013
1eac35a
A test for [LenientThis].
heycam May 6, 2013
1de9a40
Test for [PutForwards].
heycam May 6, 2013
6d7e539
Test fixes.
heycam May 6, 2013
ab78405
Test for [Replaceable].
heycam May 6, 2013
5b23c68
Test for [TreatNullAs].
heycam May 6, 2013
9f96e65
Test for [Unforgeable].
heycam May 6, 2013
649663e
Test for [Clamp].
heycam May 6, 2013
bcf2feb
Typo fix.
heycam May 6, 2013
3554ba2
Test for [TreatNullAs] on an operation argument.
heycam May 6, 2013
afc90dd
Test for [TreatNonCallableAsNull].
heycam May 6, 2013
986a5a2
Test for void return type.
heycam May 6, 2013
635afe2
Tweak comment.
heycam May 6, 2013
7ba167f
Test for any.
heycam May 6, 2013
2988507
Add test for boolean.
heycam May 6, 2013
ff5c57a
Add test for byte.
heycam May 6, 2013
e1ec191
Comment tweak.
heycam May 6, 2013
19140ef
Test for octet.
heycam May 6, 2013
dc4b916
Test for short.
heycam May 6, 2013
9b02611
Tests for unsigned short.
heycam May 7, 2013
3a766fb
Fix spec section number in comments.
heycam May 7, 2013
a08c7c7
Add tests for long.
heycam May 7, 2013
82d9dd2
Add tests for unsigned long.
heycam May 7, 2013
2499540
Tests for float.
heycam May 7, 2013
8066f7a
Test for unrestricted float.
heycam May 8, 2013
84dde23
Tests for double.
heycam May 8, 2013
96605bf
Assertion text typos.
heycam May 8, 2013
0fe989c
Tests for unrestricted double.
heycam May 8, 2013
eda1c49
Add tests for DOMString.
heycam May 8, 2013
642f753
Test for object.
heycam May 8, 2013
b0f3023
Add tests for interface types.
heycam May 8, 2013
6428241
Add test for dictionary types.
heycam May 8, 2013
f72443e
Test for enumeration types.
heycam May 8, 2013
6769487
Test for callback function types.
heycam May 8, 2013
d78c8ac
Tests for nullable types.
heycam May 8, 2013
233eb4c
Test for sequence types.
heycam May 9, 2013
ce5adff
Test for union types.
heycam May 9, 2013
4b1c515
Test for Date.
heycam May 9, 2013
e024e13
Test that interface objects are function objects.
heycam May 9, 2013
6191896
Some tests for interface objects.
heycam May 9, 2013
8a40a50
Add tests for IDL -> JS type conversions.
heycam May 9, 2013
38bb727
Test fixes.
heycam May 9, 2013
2b54eff
Add tests for constructor overload resolution and invocation.
heycam May 10, 2013
5c44e1f
Another subtest.
heycam May 10, 2013
f48ba58
Tests for constants.
heycam May 10, 2013
972a729
Fix title.
heycam May 10, 2013
3d93ad3
Tests for attributes.
heycam May 10, 2013
2a34d4e
Add another overloaded constructor subtest.
heycam May 10, 2013
0f4ca25
Add subtests for static operations.
heycam May 10, 2013
18edb03
Tweak comments.
heycam May 10, 2013
b49422d
Some tests for operations.
heycam May 10, 2013
5090995
Check for TypeError more idiomatically.
heycam May 10, 2013
5957d1b
Add a second static operation.
heycam May 11, 2013
18d8c7b
Some more default argument subtests.
heycam May 11, 2013
9fbe321
Change Document.write test to DOMTokenList.add.
heycam May 11, 2013
27d9dd8
Tests for varaidic and overloaded regular operations.
heycam May 11, 2013
206d746
Add second stringifier.
heycam May 11, 2013
3ee0722
Add tests for stringifiers.
heycam May 11, 2013
b6c4f2f
Add test for implements statement.
heycam May 11, 2013
f6b1769
Add tests for Object.freeze() etc. failing on objects that support in…
heycam May 11, 2013
a15b3ec
Add tests for getting indexed and named properties.
heycam May 11, 2013
00f1b72
Add tests for setting indexed/named properties.
heycam May 12, 2013
c970b79
Add test for deleting named properties.
heycam May 12, 2013
478b74e
Add test for legacycaller.
heycam May 12, 2013
ccf8ee0
Add test for property enumeration order.
heycam May 12, 2013
4664876
Remove unnecessary markup.
heycam May 12, 2013
93d340d
Test callback this values.
heycam May 12, 2013
14dd0ba
Tweak test titles.
heycam May 12, 2013
874a4d9
Tweak comment.
heycam May 12, 2013
c2e1721
Tweak test title.
heycam May 12, 2013
356900c
Add tests for exceptions.
heycam May 12, 2013
d8d5d64
Test for interface prototype objects.
heycam May 12, 2013
47255a8
Add test for exception fields.
heycam May 12, 2013
76568eb
Test for exception objects.
heycam May 12, 2013
3564cdf
Test for platform objects.
heycam May 12, 2013
0bab1a9
Add test for exceptions being associated with the right global enviro…
heycam May 12, 2013
15f4185
Annotate tests with which features they are using.
heycam May 13, 2013
b05c366
Update notes on features to use.
heycam May 13, 2013
93eb4fd
Rename features.txt to notes.txt.
heycam May 13, 2013
cf13916
Record the features used in tests.
heycam May 13, 2013
86d4680
Typo.
heycam May 13, 2013
8cbc70a
Record use of HTMLAnchorElement stringifier as URLUtils stringifier.
heycam May 13, 2013
6b337e7
Add test for [[HasInstance]].
heycam May 13, 2013
1c488e5
Make gather-features.pl executable.
heycam May 13, 2013
8b014c4
Add test for [EnforceRange].
heycam May 13, 2013
ef41733
Update notes on test coverage.
heycam May 13, 2013
b6a7a5d
Record features ordered by type.
heycam May 13, 2013
f61b625
Fix feature annotation.
heycam May 13, 2013
6f14cb7
Fix title.
heycam May 13, 2013
acfeea4
Fix typo in test.
heycam Jun 11, 2013
072a889
Fix a bug.
heycam Jun 11, 2013
d04911e
Add a subtest that different Function objects due to implements state…
heycam Jun 17, 2013
a1d7326
Fix typo in comment.
heycam Jun 18, 2013
f04cfd5
Add subtests for explicit undefined on a dictionary object.
heycam Jun 18, 2013
0a18201
Test updates for spec changes that treat explicit undefined as a miss…
heycam Jun 24, 2013
6b44bed
Note a couple more untested feature specifics.
heycam Jul 22, 2013
5d3d946
Update tests for [NamedPropertiesObject] -> [Global] rename.
heycam Aug 11, 2013
a01b082
Update tests for attribute/operation properties existing on the insta…
heycam Aug 11, 2013
c9bc35b
Update feature lists.
heycam Aug 11, 2013
e354483
Update test for stringifiers not calling [[Get]].
heycam Aug 11, 2013
3af6949
Comment fix.
heycam Aug 11, 2013
072456b
Update [Global] tests for named properties object not supporting expa…
heycam Aug 11, 2013
eb91331
Fix typo, reorder.
heycam Aug 11, 2013
8514dcc
Update section numbering.
heycam Aug 11, 2013
c1c6cd3
Update feature lists.
heycam Aug 11, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions WebIDL/tests/submissions/heycam/ArrayClass-001.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<title>[ArrayClass]</title>
<script src="http://w3c-test.org/resources/testharness.js"></script>
<script src="http://w3c-test.org/resources/testharnessreport.js"></script>
<script src="utils.js"></script>
<div id="log"></div>

<script>
// 4.5.3 Interface prototype object
//
// [ArrayClass] on an interface means that its [[Prototype]] is Array.prototype.

// feature: NodeList (interface) (with [ArrayClass])

test(function() {
assert_true(NodeList.prototype == Array.prototype, "NodeList.prototype == Array.prototype");
}, "NodeList being [ArrayClass] implies NodeList.prototype == Array.prototype");

test(function() {
var a = document.childNodes.concat();
assert_true(Object.getPrototypeOf(a) == Array.prototype, "nodeList.concat() returns an Array");
assert_array_equals(document.childNodes, a);
}, "nodeList.concat() works");
</script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is good. Not sure if any browsers implement this correctly yet though :)

55 changes: 55 additions & 0 deletions WebIDL/tests/submissions/heycam/Clamp-001.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<title>[Clamp] on operation arguments</title>
<script src="http://w3c-test.org/resources/testharness.js"></script>
<script src="http://w3c-test.org/resources/testharnessreport.js"></script>
<script src="utils.js"></script>
<div id="log"></div>

<script>
// 4.2.5 octet
//
// When [Clamp] is on an operation argument whose type is an integer type, then
// values outside the range of the integer will be clamped to be valid.

// feature: Uint8ClampedArray (indexed property setter) (with [Clamp])

test(function() {
var a = new Uint8ClampedArray(1);
a[0] = 128;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to follow this line with the assert_equals(a[0], 127);

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a line has to be added, it should be assert_equals(a[0], 128); then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a[0] = -1;
assert_equals(a[0], 0);
a[0] = 256;
assert_equals(a[0], 255);
a[0] = -0.1;
assert_equals(a[0], 0);
a[0] = 255.1;
assert_equals(a[0], 255);
a[0] = -Infinity;
assert_equals(a[0], 0);
a[0] = Infinity;
assert_equals(a[0], 255);
a[0] = -0;
assert_true(a[0] == 0 && 1 / a[0] > 0);
a[0] = 2.5;
assert_equals(a[0], 2);
a[0] = 5.5;
assert_equals(a[0], 6);
a[0] = NaN;
assert_equals(a[0], 0);
}, "correct conversion of Number values to a [Clamp]ed octet");

// feature: WebSocket.close (operation) (with [Clamp] on an argument)

test(function() {
var ws = new WebSocket("wss://test.invalid");

// valid code, should not throw
ws.close(1000);

// invalid code, should throw
assert_throws({ name: "InvalidAccessError" }, function() { ws.close(500); });

// invalid code, as it should clamp to 65535, rather than wrap to 1000
assert_throws({ name: "InvalidAccessError" }, function() { ws.close(66536); });
}, "correct conversion of Number values to a [Clamp]ed unsigned short");
</script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the missing assert, noted above, this file (Clamp-001) looks great.

55 changes: 55 additions & 0 deletions WebIDL/tests/submissions/heycam/Constructor-001.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<title>[Constructor]</title>
<script src="http://w3c-test.org/resources/testharness.js"></script>
<script src="http://w3c-test.org/resources/testharnessreport.js"></script>
<script src="utils.js"></script>
<div id="log"></div>

<script>
// 4.5.1.1 Interface object [[Call]] method
//
// Interfaces with [Constructor] have a [[Call]] method that invokes the
// constructor behavior. If it didn't have [Constructor], a TypeError is
// thrown. The returned object must implement the interface. There must
// also be a "length" property on the interface object.

// feature: Element (interface) (without [Constructor])

test(function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate this test, but instead of "new Element();" simply invoke Element as a method call: "Element();". Both cases should throw.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert_throws(new TypeError(), function() { new Element(); }, "new Element()");
}, "Calling new on an interface object whose interface does not have [Constructor]")

// feature: Event (interface) (with [Constructor])

test(function() {
assert_true(new Event("test") instanceof Event, "new Event(...) instanceof Event");
}, "Event constructor returns an object that is instanceof Event");

test(function() {
assert_true(Event("test") instanceof Event, "Event(...) instanceof Event");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this test is OK, given we don't yet have consensus on what to do about Bug 22808 (https://www.w3.org/Bugs/Public/show_bug.cgi?id=22808). Currently IE/Firefox would pass this test, Chrome would not (but IE won't pass it because it does not support Event constructors in general yet).

}, "Event constructor called as a function returns an object that is instanceof Event");

// feature: XMLHttpRequest (interface) (with [Constructor])

test(function() {
assert_true(new XMLHttpRequest() instanceof XMLHttpRequest, "new XMLHttpRequest() instanceof XMLHttpRequest");
}, "XMLHttpRequest constructor returns an object that is instanceof XMLHttpRequest");

test(function() {
assert_true(XMLHttpRequest() instanceof XMLHttpRequest, "XMLHttpRequest() instanceof XMLHttpRequest");
}, "XMLHttpRequest constructor called as a function returns an object that is instanceof XMLHttpRequest");

var lengthProperties = [
"Event", 1,
"XMLHttpRequest", 0
];

for (var i = 0; i < lengthProperties.length; i += 2) {
var intf = lengthProperties[i];
var val = lengthProperties[i + 1];

test(function() {
assert_property(window[intf], "length", { writable: false, enumerable: false, configurable: false, value: val }, intf + ".length");
}, intf + " has correct length property");
}
</script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One test addition requested; otherwise the rest looks good.

39 changes: 39 additions & 0 deletions WebIDL/tests/submissions/heycam/Constructor-002.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<title>Invoking constructors without overloading or optional arguments</title>
<script src="http://w3c-test.org/resources/testharness.js"></script>
<script src="http://w3c-test.org/resources/testharnessreport.js"></script>
<script src="utils.js"></script>
<div id="log"></div>

<script>
// 4.5.1.1 Interface object [[Call]] method
//
// In this test we're invoking simple constructors -- ones that do not use
// overloading or optional arguments. When too few arguments are passed,
// a TypeError is thrown. When too many arguments are passed, the extra
// ones are ignored. Argument types are not used to eliminate the single
// entry in the effective overload set.

// feature: ArrayBuffer (interface) (with [Constructor], and no overloading or optional arguments)

test(function() {
assert_throws(new TypeError(), function() { new ArrayBuffer(); });
}, "passing too few arguments to ArrayBuffer constructor throws");

test(function() {
var buffer = new ArrayBuffer(undefined);
assert_equals(buffer.byteLength, 0);
}, "passing undefined to ArrayBuffer constructor succeeds");

test(function() {
var buffer = new ArrayBuffer(10, 20);
assert_equals(buffer.byteLength, 10);
}, "additional arguments passed to ArrayBuffer constructor are ignored");

// feature: Range (interface) (with [Constructor], and no overloading or optional arguments)

test(function() {
var range = new Range("test");
assert_true(!!range);
}, "additional arguments passed to Range constructor are ignored");
</script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests in Constructor-002 are all good. (The ArrayBuffer(undefined) threw me at first, as I read through overload resolution, which seemed to say throw TypeError, since there wasn't an optional overload, but then ArrayBuffer has no overloads, so this is really just "undefined" -> "unsigned long" conversion, which is +0.

56 changes: 56 additions & 0 deletions WebIDL/tests/submissions/heycam/Constructor-003.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<title>Invoking constructors without overloading but with optional arguments</title>
<script src="http://w3c-test.org/resources/testharness.js"></script>
<script src="http://w3c-test.org/resources/testharnessreport.js"></script>
<script src="utils.js"></script>
<div id="log"></div>

<script>
// 4.5.1.1 Interface object [[Call]] method
//
// In this test we're invoking constructors with no overloading but which
// do have optional arguments. When too few arguments are passed, a TypeError
// is thrown. When too many arguments are passed, the extra ones are ignored.
// Argument types are not used to eliminate the single entry in the effective
// overload set that remains after discarding others due to incorrect argument
// list length. Optional argument default values are also filled in for
// trailing missing arguments.

// feature: Event (interface) (with [Constructor] and optional arguments)

test(function() {
assert_throws(new TypeError(), function() { new Event(); });
}, "passing too few arguments to Event constructor throws");

test(function() {
var e1 = new Event("click");
var e2 = new Event("click", { });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It helped me when going through 4.2.19's conversion algorithm, to note a third test case here:
var e3 = new Event("click", null);
and assert it is the same as e1 and e2.

assert_equals(e1.bubbles, e2.bubbles);
assert_equals(e1.cancelable, e2.cancelable);
}, "passing one argument to Event constructor will use the default argument value");

test(function() {
assert_throws(new TypeError(), function() { new Event("click", false); });
}, "passing a bad type as the Event constructor optional argument value throws an exception");

test(function() {
var e = new Event("click", { }, "ignored");
assert_true(!!e);
}, "extra arguments passed to Event constructor are ignored");

// feature: WebSocket (interface) (with [Constructor] and optional arguments)

test(function() {
assert_throws(new TypeError(), function() { new WebSocket(); });
}, "passing too few arguments to WebSocket constructor throws");

test(function() {
var ws = new WebSocket("wss://test.invalid");
assert_true(!!ws);
}, "omitting an optional argument in the WebSocket constructor works");

test(function() {
var ws = new WebSocket("wss://test.invalid", "protocol", "ignored");
assert_true(!!ws);
}, "additional arguments passed to the WebSocket constructor are ignored");
</script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test looks good (Constructor-003). It would be nice to add the extra test case mentioned above as well.

124 changes: 124 additions & 0 deletions WebIDL/tests/submissions/heycam/Constructor-004.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<!DOCTYPE html>
<title>Invoking constructors with overloading</title>
<script src="http://w3c-test.org/resources/testharness.js"></script>
<script src="http://w3c-test.org/resources/testharnessreport.js"></script>
<script src="utils.js"></script>
<div id="log"></div>

<script>
// 4.5.1.1 Interface object [[Call]] method
//
// In this test we're invoking constructors with overloading. When too few
// arguments are passed, a TypeError is thrown. When too many arguments are
// passed, the extra ones are ignored. Candidate overloads are first chosen
// based on how many arguments were passed. Then, a specific argument is used
// as the one that distinguishes between the different candidate overloads.
// Values before this distinguishing argument are converted to IDL values before
// the distinguishing argument is inspected. Looking at the distinguishing
// argument might then cause the call to fail (and a TypeError to be thrown) if
// there is not an appropriate value passed in that position.
//
// With both Uint8Array and Blob, the two interfaces we are using in this test,
// it's not possible to test the "arguments before the distinguishing argument
// are converted before possibly throwing due to an invalid value in that
// argument position" since the distinguishing argument index is < 1.

// feature Uint8Array (interface) (with [Constructor] and overloading)

test(function() {
assert_throws(new TypeError(), function() { new Uint8Array(); });
}, "passing too few arguments to Uint8Array constructor throws");

test(function() {
var a = new Uint8Array(3);
assert_equals(a.length, 3);
}, "passing a Number as the only argument to the Uint8Array constructor selects the (unsigned long) overload");

test(function() {
var a1 = new Uint8Array(4);
var a2 = new Uint8Array(a1);
assert_equals(a2.length, 4);
}, "passing a Uint8Array as the only argument to the Uint8Array constructor selects the (Uint8Array) overload");

test(function() {
var a = new Uint8Array([9, 9, 9]);
assert_equals(a.length, 3);
assert_equals(a[0], 9);
}, "passing an Array as the only argument to the Uint8Array constructor selects the (octet[]) overload");

test(function() {
var a = new Uint8Array({ length: 3, "0": 9 });
assert_equals(a.length, 3);
assert_equals(a[0], 9);
}, "passing { length: 3, \"0\": 9 } as the only argument to the Uint8Array constructor selects the (octet[]) overload");

test(function() {
var buffer = new ArrayBuffer(5);
var a = new Uint8Array(buffer);
assert_equals(a.length, 5);
}, "passing an ArrayBuffer as the only argument to the Uint8Array constructor selects the (ArrayBuffer, optional unsigned long, optional unsigned long) overload");

test(function() {
assert_throws(new TypeError(), function() { new Uint8Array(3, "extra"); });
}, "passing (Number, String) to the Uint8Array constructor selects the (ArrayBuffer, optional unsigned long, optional unsigned long) overload, and then throws due to the conversion of the Number to an ArrayBuffer");

test(function() {
var a1 = new Uint8Array(4);
assert_throws(new TypeError(), function() { new Uint8Array(a1, "extra"); });
}, "passing (Uint8Array, String) to the Uint8Array constructor selects the (ArrayBuffer, optional unsigned long, optional unsigned long) overload, and then throws due to the conversion of the Uint8Array to an ArrayBuffer");

test(function() {
assert_throws(new TypeError(), function() { new Uint8Array([9, 9, 9], "extra"); });
}, "passing (Array, String) to the Uint8Array constructor selects the (ArrayBuffer, optional unsigned long, optional unsigned long) overload, and then throws due to the conversion of the Array to an ArrayBuffer");

test(function() {
var buffer = new ArrayBuffer(5);
var a1 = new Uint8Array(buffer);
a1[0] = 123;
var a2 = new Uint8Array(buffer, "hello"); // the "hello" converts to 0
assert_equals(a2[0], 123);
}, "passing (ArrayBuffer, String) to the Uint8Array constructor selects the (ArrayBuffer, optional unsigned long, optional unsigned long) overload");

test(function() {
var buffer = new ArrayBuffer(5);
var a = new Uint8Array(buffer, 0, { valueOf: function() { return 2; } });
assert_equals(a.length, 2);
}, "passing (ArrayBuffer, Number, { valueOf }) to the Uint8Array constructor selects the (ArrayBuffer, optional unsigned long, optional unsigned long) overload");

test(function() {
var buffer = new ArrayBuffer(5);
var a = new Uint8Array(buffer, 0, 2, "extra");
assert_equals(a.length, 2);
}, "passing (ArrayBuffer, Number, Number, String) to the Uint8Array constructor selects the (ArrayBuffer, optional unsigned long, optional unsigned long) overload");

test(function() {
var buffer = new ArrayBuffer(5);
var a = new Uint8Array(buffer, undefined, undefined);
assert_equals(a.length, 5);
}, "passing (ArrayBuffer, undefined, undefined) to the Uint8Array constructor selects the (ArrayBuffer, optional unsigned long, optional unsigned long) overload with three arguments and treats the undefineds as missing arguments");


// feature Blob (interface) (with [Constructor] and overloading)

test(function() {
var b = new Blob();
assert_equals(b.size, 0);
}, "passing no arguments to the Blob constructor selects the () overload");

test(function() {
var b1 = new Blob([]);
var b2 = new Blob([], { });
assert_equals(b1.size, 0);
assert_equals(b1.type, b2.type);
}, "passing an Array object as the only argument to the Blob constructor selects the (sequence<...>, optional BlobPropertyBag) overload");

test(function() {
var b = new Blob({ length: 3, "0": "a" });
assert_equals(b.size, "aundefinedundefined".length);
}, "passing { length: 3, \"0\": \"a\" } as the only argument to the Blob constructor selects the (sequence<...>, optional BlobPropertyBag) overload");

test(function() {
var b = new Blob(["abc"], { }, "extra");
assert_equals(b.size, 3);
}, "passing ([\"abc\"], { }, \"extra\") to the Blob constructor selects the (sequence<...>, optional BlobPropertyBag) overload");
</script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are good (Constructor-004)

Loading