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

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

Issue 752763002: Bindings: test for object identity and cycles in structured cloning (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE HTML>
2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script>
4 <script>
5 function promise_test(func, name, properties) {
6 properties = properties || {};
7 var test = async_test(name, properties);
8 Promise.resolve(test.step(func, test, test))
9 .then(function() { test.done(); })
10 .catch(test.step_func(function(value) { throw value; }));
11 }
12
13 function structuredClone(o)
14 {
15 return new Promise(function(resolve, reject) {
16 var mc = new MessageChannel();
17 mc.port2.onmessage = function(e) { resolve(e.data); };
18 mc.port1.postMessage(o);
19 });
20 }
21
22 promise_test(function() {
23 var inner = {};
24 var orig = { inner: inner };
25 inner.outer = orig;
26 return structuredClone(orig).then(function(clone) {
27 assert_equals(clone.inner.outer, clone, 'Cycles should be preserved');
28 });
29 }, 'Verify: "This algorithm preserves cycles..."');
30
31 promise_test(function() {
32 var gen = {name: 'AES-CBC', length: 128};
33 return crypto.subtle.generateKey(gen, false, ['encrypt']).then(function(key) {
34 var simple = {};
35 var blob = new Blob(['content']);
36 var orig = {
37 s1: simple, s2: simple,
38 b1: blob, b2: blob,
39 k1: key, k2: key
40 };
41 return structuredClone(orig).then(function(clone) {
42 assert_equals(clone.s1, clone.s2, 'JS object identity should be pres erved');
43 assert_equals(clone.b1, clone.b2, 'Core object identity should be pr eserved');
44 assert_equals(clone.k1, clone.k2, 'Module object identity should be preserved');
45 });
46 });
47 }, 'Verify: "This algorithm preserves... the identity of duplicate objects in gr aphs."');
48
49 </script>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698