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

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

Issue 718383003: bindings: fixed incorrect dependency of SerializedScriptValue. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added fast/js/structured-clone.html 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/core/DEPS » ('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
new file mode 100644
index 0000000000000000000000000000000000000000..372601ea1010a02096a405a881eb182343ebf264
--- /dev/null
+++ b/LayoutTests/fast/js/structured-clone.html
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+function promise_test(func, name, properties) {
+ properties = properties || {};
+ var test = async_test(name, properties);
+ Promise.resolve(test.step(func, test, test))
+ .then(function() { test.done(); })
+ .catch(test.step_func(function(value) { throw value; }));
+}
+
+function structuredClone(o)
+{
+ return new Promise(function(resolve, reject) {
+ var mc = new MessageChannel();
+ mc.port2.onmessage = function(e) { resolve(e.data); };
+ mc.port1.postMessage(o);
+ });
+}
+
+promise_test(function() {
+ var inner = {};
+ var orig = { inner: inner };
+ inner.outer = orig;
+ return structuredClone(orig).then(function(clone) {
+ assert_equals(clone.inner.outer, clone, 'Cycles should be preserved');
+ });
+}, 'Verify: "This algorithm preserves cycles..."');
+
+promise_test(function() {
+ var gen = {name: 'AES-CBC', length: 128};
+ return crypto.subtle.generateKey(gen, false, ['encrypt']).then(function(key) {
+ var simple = {};
+ var blob = new Blob(['content']);
+ var orig = {
+ s1: simple, s2: simple,
+ b1: blob, b2: blob,
+ k1: key, k2: key
+ };
+ return structuredClone(orig).then(function(clone) {
+ assert_equals(clone.s1, clone.s2, 'JS object identity should be preserved');
+ assert_equals(clone.b1, clone.b2, 'Core object identity should be preserved');
+ assert_equals(clone.k1, clone.k2, 'Module object identity should be preserved');
+ });
+ });
+}, 'Verify: "This algorithm preserves... the identity of duplicate objects in graphs."');
+
+</script>
« no previous file with comments | « no previous file | Source/bindings/core/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698