OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../resources/js-test.js"></script> |
| 3 <script> |
| 4 description('IDL dictionary unittest'); |
| 5 |
| 6 if (window.internals && internals.dictionaryTest) { |
| 7 var dictionaryTest = window.internals.dictionaryTest(); |
| 8 |
| 9 debug('Test for setting an empty dictionary'); |
| 10 dictionaryTest.set({}); |
| 11 dict = dictionaryTest.get(); |
| 12 shouldBeUndefined('dict.longMember'); |
| 13 shouldBeEqualToString('dict.stringMember', 'defaultStringValue'); |
| 14 shouldBeNull('dict.booleanOrNullMember'); |
| 15 shouldBeUndefined('dict.doubleOrNullMember'); |
| 16 shouldBeUndefined('dict.stringSequenceMember'); |
| 17 debug(''); |
| 18 |
| 19 debug('Test for setting undefined'); |
| 20 dictionaryTest.set(undefined); |
| 21 dict = dictionaryTest.get(); |
| 22 shouldBeUndefined('dict.longMember'); |
| 23 shouldBeEqualToString('dict.stringMember', 'defaultStringValue'); |
| 24 shouldBeNull('dict.booleanOrNullMember'); |
| 25 shouldBeUndefined('dict.doubleOrNullMember'); |
| 26 shouldBeUndefined('dict.stringSequenceMember'); |
| 27 debug(''); |
| 28 |
| 29 debug('Test for setting valid values'); |
| 30 dictionaryTest.set({longMember: 3, stringMember: 'modifiedString', |
| 31 booleanOrNullMember: true, doubleOrNullMember: 2.0, |
| 32 stringSequenceMember: ['foo', 'bar', 'baz']}); |
| 33 dict = dictionaryTest.get(); |
| 34 shouldBe('dict.longMember', '3'); |
| 35 shouldBeEqualToString('dict.stringMember', 'modifiedString'); |
| 36 shouldBeTrue('dict.booleanOrNullMember'); |
| 37 shouldBe('dict.doubleOrNullMember', '2.0'); |
| 38 shouldBe('dict.stringSequenceMember', '["foo", "bar", "baz"]'); |
| 39 debug(''); |
| 40 |
| 41 // FIXME: Following test doesn't pass. Make it pass. |
| 42 /* |
| 43 debug('Test for explicit undefined or null, and missing members'); |
| 44 dictionaryTest.reset(); |
| 45 dictionaryTest.set({longMember: undefined, stringMember: undefined, |
| 46 booleanOrNullMember: null}); |
| 47 dict = dictionaryTest.get(); |
| 48 shouldBeUndefined('dict.longMember'); |
| 49 shouldBeEqualToString('dict.stringMember', 'defaultStringValue'); |
| 50 shouldBeNull('dict.booleanOrNullMember'); |
| 51 shouldBeUndefined('dict.doubleOrNullMember'); |
| 52 shouldBeUndefined('dict.stringSequenceMember'); |
| 53 debug(''); |
| 54 */ |
| 55 |
| 56 debug('Test for setting invalid member'); |
| 57 dictionaryTest.set({invalidMember: 'shouldNotBeSet'}); |
| 58 dict = dictionaryTest.get(); |
| 59 shouldBeUndefined('dict.invalidMember'); |
| 60 debug(''); |
| 61 } |
| 62 </script> |
OLD | NEW |