Web Inspector: replace TypeVerifier with subclasses of WI.Collection
[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     class TestCollection extends WI.Collection {
9         objectIsRequiredType(object)
10         {
11             return true;
12         }
13     }
14
15     class StringCollection extends WI.Collection {
16         objectIsRequiredType(object)
17         {
18             return typeof object === "string";
19         }
20     }
21
22     let suite = InspectorTest.createSyncSuite("Collection");
23
24     suite.addTestCase({
25         name: "WI.Collection.prototype.add",
26         test() {
27             let collection = new TestCollection;
28             collection.add("one");
29             collection.add("two");
30
31             InspectorTest.log(collection);
32
33             collection.add(3);
34
35             InspectorTest.log(collection);
36
37             return true;
38         }
39     });
40
41     suite.addTestCase({
42         name: "WI.Collection.prototype.remove",
43         test() {
44             let item = "one";
45
46             let collection = new TestCollection;
47             collection.add(item);
48             collection.add("two");
49
50             InspectorTest.log(collection);
51
52             collection.remove(item);
53
54             InspectorTest.log(collection);
55
56             return true;
57         }
58     });
59
60     suite.addTestCase({
61         name: "WI.Collection.prototype.clear",
62         test() {
63             let collection = new TestCollection;
64             collection.add("one");
65             collection.add("two");
66             collection.add(3);
67
68             InspectorTest.log(collection);
69
70             collection.clear();
71
72             InspectorTest.log(collection);
73
74             return true;
75         }
76     });
77
78     suite.addTestCase({
79         name: "WI.Collection.SpecifiedType",
80         test() {
81             let collection = new StringCollection;
82             collection.add("one");
83             collection.add("two");
84
85             InspectorTest.log(collection);
86
87             collection.add(3);
88
89             InspectorTest.log(collection);
90
91             return true;
92         }
93     });
94
95     suite.runTestCasesAndFinish();
96 }
97 </script>
98 </head>
99 <body onload="runTest()">
100     <p>Testing all methods of Collection.</p>
101 </body>
102 </html>