OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../resources/js-test.js"></script> | 2 <script src="../../resources/js-test.js"></script> |
3 <script> | 3 <script> |
4 description('IDL dictionary unittest'); | 4 description('IDL dictionary unittest'); |
5 | 5 |
6 var testObject1 = { foo: 'x' }; | 6 var testObject1 = { foo: 'x' }; |
7 var testObject2 = { bar: 'y' }; | 7 var testObject2 = { bar: 'y' }; |
8 | 8 |
9 if (window.internals && internals.dictionaryTest) { | 9 if (window.internals && internals.dictionaryTest) { |
10 var dictionaryTest = window.internals.dictionaryTest(); | 10 var dictionaryTest = window.internals.dictionaryTest(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 debug('Test for setting invalid object value'); | 121 debug('Test for setting invalid object value'); |
122 shouldThrow("dictionaryTest.set({objectMember: 42})"); | 122 shouldThrow("dictionaryTest.set({objectMember: 42})"); |
123 shouldThrow("dictionaryTest.set({objectMember: 'invalid'})"); | 123 shouldThrow("dictionaryTest.set({objectMember: 'invalid'})"); |
124 debug(''); | 124 debug(''); |
125 | 125 |
126 debug('Test for passing invalid dictionary values'); | 126 debug('Test for passing invalid dictionary values'); |
127 shouldThrow("dictionaryTest.set(42)"); | 127 shouldThrow("dictionaryTest.set(42)"); |
128 shouldThrow("dictionaryTest.set('string')"); | 128 shouldThrow("dictionaryTest.set('string')"); |
129 debug(''); | 129 debug(''); |
130 | 130 |
| 131 debug('Test for [Clamp] and [EnforceRange] member'); |
| 132 dictionaryTest.set({ |
| 133 longMember: 2147483648, |
| 134 longMemberWithClamp: 2147483648 |
| 135 }); |
| 136 dict = dictionaryTest.get(); |
| 137 shouldBe('dict.longMember', '-2147483648'); |
| 138 shouldBe('dict.longMemberWithClamp', '2147483647'); |
| 139 shouldThrow('dictionaryTest.set({ longMemberWithEnforceRange: 2147483648 })'
); |
| 140 debug(''); |
| 141 |
131 debug('Test for derived dictionary'); | 142 debug('Test for derived dictionary'); |
132 dictionaryTest.setDerived({}); | 143 dictionaryTest.setDerived({}); |
133 derived = dictionaryTest.getDerived(); | 144 derived = dictionaryTest.getDerived(); |
134 shouldBeUndefined('derived.longMember'); | 145 shouldBeUndefined('derived.longMember'); |
135 shouldBe('derived.longMemberWithDefault', '42'); | 146 shouldBe('derived.longMemberWithDefault', '42'); |
136 shouldBeUndefined('derived.longOrNullMember'); | 147 shouldBeUndefined('derived.longOrNullMember'); |
137 shouldBeNull('derived.longOrNullMemberWithDefault'); | 148 shouldBeNull('derived.longOrNullMemberWithDefault'); |
138 shouldBeUndefined('derived.booleanMember'); | 149 shouldBeUndefined('derived.booleanMember'); |
139 shouldBeUndefined('derived.doubleMember'); | 150 shouldBeUndefined('derived.doubleMember'); |
140 shouldBeUndefined('derived.stringMember'); | 151 shouldBeUndefined('derived.stringMember'); |
(...skipping 22 matching lines...) Expand all Loading... |
163 shouldBe('derived.longMember', '1'); | 174 shouldBe('derived.longMember', '1'); |
164 shouldBeEqualToString('derived.stringMemberWithDefault', 'modifiedString'); | 175 shouldBeEqualToString('derived.stringMemberWithDefault', 'modifiedString'); |
165 shouldBeEqualToString('derived.derivedStringMember', 'modifiedString2'); | 176 shouldBeEqualToString('derived.derivedStringMember', 'modifiedString2'); |
166 shouldBeEqualToString('derived.derivedStringMemberWithDefault', 'modifiedStr
ing3'); | 177 shouldBeEqualToString('derived.derivedStringMemberWithDefault', 'modifiedStr
ing3'); |
167 shouldBeUndefined('derived.invalidMember'); | 178 shouldBeUndefined('derived.invalidMember'); |
168 | 179 |
169 debug(''); | 180 debug(''); |
170 shouldThrow("dictionaryTest.setDerived({objectMember: 42})"); | 181 shouldThrow("dictionaryTest.setDerived({objectMember: 42})"); |
171 } | 182 } |
172 </script> | 183 </script> |
OLD | NEW |