Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: LayoutTests/fast/js/structured-clone.html

Issue 1297223004: ScriptValueSerializer should throw, not crash, when handling unknown types (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use nullptr Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/bindings/core/v8/ScriptValueSerializer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 assert_equals(clone.map.size, 1, 'Cloned map should not reflect mutation '); 182 assert_equals(clone.map.size, 1, 'Cloned map should not reflect mutation ');
183 assert_equals(Array.from(clone.set)[0].val, 'setMutator', 'Cloned set sh ould contain getter return value'); 183 assert_equals(Array.from(clone.set)[0].val, 'setMutator', 'Cloned set sh ould contain getter return value');
184 assert_equals(clone.map.get('mapMutator').val, 'mapMutator', 'Cloned map should contain getter return value'); 184 assert_equals(clone.map.get('mapMutator').val, 'mapMutator', 'Cloned map should contain getter return value');
185 }); 185 });
186 }, 'Cloned Maps and Sets do not reflect mutations that occur during cloning'); 186 }, 'Cloned Maps and Sets do not reflect mutations that occur during cloning');
187 187
188 promise_test(function() { 188 promise_test(function() {
189 var map = new Map([['key', function(){}]]); 189 var map = new Map([['key', function(){}]]);
190 return structuredClone(map).then(function(clone) { 190 return structuredClone(map).then(function(clone) {
191 assert_unreached('Should have thrown an exception'); 191 assert_unreached('Should have thrown an exception');
192 }).catch(function(ex) { 192 }, function(ex) {
193 assert_true(ex instanceof DOMException, 'Should throw a DOMException'); 193 assert_true(ex instanceof DOMException, 'Should throw a DOMException');
194 assert_equals(ex.code, DOMException.DATA_CLONE_ERR, 'Should be a DataClo neError'); 194 assert_equals(ex.code, DOMException.DATA_CLONE_ERR, 'Should be a DataClo neError');
195 }); 195 });
196 }, 'Cloning Maps should fail if they contain non-cloneable things'); 196 }, 'Cloning Maps should fail if they contain non-cloneable things');
197 197
198 promise_test(function() { 198 promise_test(function() {
199 var set = new Set([function(){}]); 199 var set = new Set([function(){}]);
200 return structuredClone(set).then(function(clone) { 200 return structuredClone(set).then(function(clone) {
201 assert_unreached('Should have thrown an exception'); 201 assert_unreached('Should have thrown an exception');
202 }).catch(function(ex) { 202 }, function(ex) {
203 assert_true(ex instanceof DOMException, 'Should throw a DOMException'); 203 assert_true(ex instanceof DOMException, 'Should throw a DOMException');
204 assert_equals(ex.code, DOMException.DATA_CLONE_ERR, 'Should be a DataClo neError'); 204 assert_equals(ex.code, DOMException.DATA_CLONE_ERR, 'Should be a DataClo neError');
205 }); 205 });
206 }, 'Cloning Sets should fail if they contain non-cloneable things'); 206 }, 'Cloning Sets should fail if they contain non-cloneable things');
207 207
208 promise_test(function() {
209 return structuredClone(Symbol('foo')).then(function(clone) {
210 assert_unreached('Should have thrown an exception');
211 }, function(ex) {
212 assert_true(ex instanceof DOMException, 'Should throw a DOMException');
213 assert_equals(ex.code, DOMException.DATA_CLONE_ERR, 'Should be a DataClo neError');
214 });
215 }, 'Cloning Symbols should fail');
216
208 </script> 217 </script>
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/core/v8/ScriptValueSerializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698