62b33e8b918ad985f93ebd03d93768ab32c1c5ff
[WebKit-https.git] / LayoutTests / inspector / unit-tests / collection.html
1 <!doctype html>
2 <html>
3 <head>
4 <script src="../../http/tests/inspector/resources/inspector-test.js"></script>
5 <script>
6 function test()
7 {
8     let suite = InspectorTest.createAsyncSuite("Collection");
9
10     suite.addTestCase({
11         name: "WI.Collection.prototype.add",
12         test(resolve, reject) {
13             let collection = new WI.Collection;
14             collection.add("one");
15             collection.add("two");
16
17             InspectorTest.log(collection);
18
19             collection.add(3);
20
21             InspectorTest.log(collection);
22
23             resolve();
24         }
25     });
26
27     suite.addTestCase({
28         name: "WI.Collection.prototype.remove",
29         test(resolve, reject) {
30             let item = "one";
31
32             let collection = new WI.Collection;
33             collection.add(item);
34             collection.add("two");
35
36             InspectorTest.log(collection);
37
38             collection.remove(item);
39
40             InspectorTest.log(collection);
41
42             resolve();
43         }
44     });
45
46     suite.addTestCase({
47         name: "WI.Collection.prototype.clear",
48         test(resolve, reject) {
49             let collection = new WI.Collection;
50             collection.add("one");
51             collection.add("two");
52             collection.add(3);
53
54             InspectorTest.log(collection);
55
56             collection.clear();
57
58             InspectorTest.log(collection);
59
60             resolve();
61         }
62     });
63
64     suite.addTestCase({
65         name: "WI.Collection.prototype.get typeVerifier",
66         test(resolve, reject) {
67             function stringVerifier(object) {
68                 return typeof object === "string";
69             }
70
71             let collection = new WI.Collection(stringVerifier);
72             collection.add("one");
73             collection.add("two");
74
75             InspectorTest.log(collection);
76
77             collection.add(3);
78
79             InspectorTest.log(collection);
80             InspectorTest.expectEqual(collection.typeVerifier, stringVerifier, "typeVerifier is the given function.");
81
82             resolve();
83         }
84     });
85
86     suite.runTestCasesAndFinish();
87 }
88 </script>
89 </head>
90 <body onload="runTest()">
91     <p>Testing all methods of Collection.</p>
92 </body>
93 </html>