Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
| 2 <script src="../../resources/testharness.js"></script> | 2 <script src="../../resources/testharness.js"></script> |
| 3 <script src="../../resources/testharnessreport.js"></script> | 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <script> | 4 <script> |
| 5 function promise_test(func, name, properties) { | 5 function promise_test(func, name, properties) { |
| 6 properties = properties || {}; | 6 properties = properties || {}; |
| 7 var test = async_test(name, properties); | 7 var test = async_test(name, properties); |
| 8 Promise.resolve(test.step(func, test, test)) | 8 Promise.resolve(test.step(func, test, test)) |
| 9 .then(function() { test.done(); }) | 9 .then(function() { test.done(); }) |
| 10 .catch(test.step_func(function(value) { throw value; })); | 10 .catch(test.step_func(function(value) { throw value; })); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 assert_true(orig.hasOwnProperty(name)); | 112 assert_true(orig.hasOwnProperty(name)); |
| 113 | 113 |
| 114 return structuredClone(orig).then(function(clone) { | 114 return structuredClone(orig).then(function(clone) { |
| 115 assert_true(Array.isArray(clone), 'Clone should be an Array'); | 115 assert_true(Array.isArray(clone), 'Clone should be an Array'); |
| 116 assert_false(setter_called, 'Setter should not be called by cloning algo rithm.'); | 116 assert_false(setter_called, 'Setter should not be called by cloning algo rithm.'); |
| 117 assert_true(clone.hasOwnProperty(name), 'Cloning algorithm should add an own property.') | 117 assert_true(clone.hasOwnProperty(name), 'Cloning algorithm should add an own property.') |
| 118 assert_equals(clone[name], orig[name], 'Property value should match'); | 118 assert_equals(clone[name], orig[name], 'Property value should match'); |
| 119 }); | 119 }); |
| 120 }, 'Verify: "Add a new property..." (dense arrays)'); | 120 }, 'Verify: "Add a new property..." (dense arrays)'); |
| 121 | 121 |
| 122 promise_test(function() { | |
| 123 var orig = { | |
| 124 emptySet: new Set, | |
| 125 set: new Set([1, 2, 3]), | |
| 126 emptyMap: new Map, | |
| 127 map: new Map([[1, 2], [3, 4]]), | |
| 128 }; | |
| 129 return structuredClone(orig).then(function(clone) { | |
| 130 assert_true(clone.emptySet instanceof Set, 'Clone should be a Set'); | |
| 131 assert_true(clone.emptyMap instanceof Map, 'Clone should be a Map'); | |
| 132 assert_true(clone.set instanceof Set, 'Clone should be a Set'); | |
| 133 assert_true(clone.map instanceof Map, 'Clone should be a Map'); | |
| 134 assert_equals(clone.set.size, orig.set.size, 'Clone should be the same s ize'); | |
|
jsbell
2015/06/24 20:30:43
Should probably have asserts about emptySet/emptyM
adamk
2015/06/24 21:13:32
Done.
| |
| 135 assert_equals(clone.map.size, orig.map.size, 'Clone should be the same s ize'); | |
| 136 assert_true(clone.set.has(1) && clone.set.has(2) && clone.set.has(3), 'C loned set should have the same keys'); | |
| 137 assert_true(clone.map.get(1) == 2 && clone.map.get(3) == 4, 'Cloned map should have the same keys and values'); | |
| 138 }); | |
| 139 }, 'Verify: "Maps and Sets are cloned..."'); | |
|
jsbell
2015/06/24 20:30:42
The 'Verify: "xxxx..."' phrasing in tests above is
adamk
2015/06/24 21:13:31
I've removed the quotes and the ellipses. Should I
jsbell
2015/06/24 21:37:10
I think this file is fine.
| |
| 140 | |
| 141 promise_test(function() { | |
| 142 var set = new Set; | |
| 143 set.add(set); | |
| 144 var map = new Map; | |
| 145 map.set(map, map); | |
| 146 var orig = { map: map, set: set }; | |
| 147 return structuredClone(orig).then(function(clone) { | |
| 148 assert_true(clone.set instanceof Set, 'Clone should be a Set'); | |
| 149 assert_true(clone.map instanceof Map, 'Clone should be a Map'); | |
| 150 assert_true(clone.set === Array.from(clone.set)[0], 'Recursive sets shou ld maintain identity'); | |
|
jsbell
2015/06/24 20:30:43
Use assert_equals() for these (it does 'same value
adamk
2015/06/24 21:13:31
Done.
| |
| 151 assert_true(clone.map === Array.from(clone.map)[0][0], 'Recursive maps s hould maintain identity'); | |
| 152 assert_true(clone.map === Array.from(clone.map)[0][1], 'Recursive maps s hould maintain identity'); | |
| 153 }); | |
| 154 }, 'Verify: "Maps and Sets can contain themselves..."'); | |
|
jsbell
2015/06/24 20:30:43
Ditto.
adamk
2015/06/24 21:13:32
Done.
| |
| 155 | |
|
jsbell
2015/06/24 20:30:42
Can you add a test where a member of the map/set h
adamk
2015/06/24 21:13:32
Done. Should we file a bug for this?
jsbell
2015/06/24 21:37:10
Against HTML? Probably.
One more edge case we sho
adamk
2015/06/24 22:50:31
Non-cloneability tests added.
adamk
2015/06/24 23:48:53
Filed https://www.w3.org/Bugs/Public/show_bug.cgi?
| |
| 122 </script> | 156 </script> |
| OLD | NEW |