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

Unified Diff: LayoutTests/fast/js/structured-clone.html

Issue 1205973002: Support structured cloning of ES'15 Map and Set (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added some comments to SerializationTag.h Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/core/v8/ScriptValueSerializer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/js/structured-clone.html
diff --git a/LayoutTests/fast/js/structured-clone.html b/LayoutTests/fast/js/structured-clone.html
index 6cd9c365878d5340ae30ced8ce4297c7a39f3dde..dfa7740ac8e9e1f885df5ff5008a65e56927c499 100644
--- a/LayoutTests/fast/js/structured-clone.html
+++ b/LayoutTests/fast/js/structured-clone.html
@@ -119,4 +119,38 @@ promise_test(function() {
});
}, 'Verify: "Add a new property..." (dense arrays)');
+promise_test(function() {
+ var orig = {
+ emptySet: new Set,
+ set: new Set([1, 2, 3]),
+ emptyMap: new Map,
+ map: new Map([[1, 2], [3, 4]]),
+ };
+ return structuredClone(orig).then(function(clone) {
+ assert_true(clone.emptySet instanceof Set, 'Clone should be a Set');
+ assert_true(clone.emptyMap instanceof Map, 'Clone should be a Map');
+ assert_true(clone.set instanceof Set, 'Clone should be a Set');
+ assert_true(clone.map instanceof Map, 'Clone should be a Map');
+ assert_equals(clone.set.size, orig.set.size, 'Clone should be the same size');
jsbell 2015/06/24 20:30:43 Should probably have asserts about emptySet/emptyM
adamk 2015/06/24 21:13:32 Done.
+ assert_equals(clone.map.size, orig.map.size, 'Clone should be the same size');
+ assert_true(clone.set.has(1) && clone.set.has(2) && clone.set.has(3), 'Cloned set should have the same keys');
+ assert_true(clone.map.get(1) == 2 && clone.map.get(3) == 4, 'Cloned map should have the same keys and values');
+ });
+}, '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.
+
+promise_test(function() {
+ var set = new Set;
+ set.add(set);
+ var map = new Map;
+ map.set(map, map);
+ var orig = { map: map, set: set };
+ return structuredClone(orig).then(function(clone) {
+ assert_true(clone.set instanceof Set, 'Clone should be a Set');
+ assert_true(clone.map instanceof Map, 'Clone should be a Map');
+ assert_true(clone.set === Array.from(clone.set)[0], 'Recursive sets should 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.
+ assert_true(clone.map === Array.from(clone.map)[0][0], 'Recursive maps should maintain identity');
+ assert_true(clone.map === Array.from(clone.map)[0][1], 'Recursive maps should maintain identity');
+ });
+}, 'Verify: "Maps and Sets can contain themselves..."');
jsbell 2015/06/24 20:30:43 Ditto.
adamk 2015/06/24 21:13:32 Done.
+
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?
</script>
« no previous file with comments | « no previous file | Source/bindings/core/v8/ScriptValueSerializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698