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

Unified Diff: LayoutTests/crypto/resources/common.js

Issue 195543002: [webcrypto] Implement structured clone of keys (blink-side). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update serialized-script-value.html for version bump Created 6 years, 9 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
Index: LayoutTests/crypto/resources/common.js
diff --git a/LayoutTests/crypto/resources/common.js b/LayoutTests/crypto/resources/common.js
index 591044aa641455d00a7d76c0d787ebf9bc79bcc1..35318e8dd7cfb7d64382977cdd18d82700c0624b 100644
--- a/LayoutTests/crypto/resources/common.js
+++ b/LayoutTests/crypto/resources/common.js
@@ -158,3 +158,39 @@ function shouldAcceptPromise(code)
addTask(promise.then(acceptCallback, rejectCallback));
}
+
+// Returns a Promise for the cloned key.
+function cloneKey(key)
+{
+ // Sending an object through a MessagePort implicitly clones it.
+ // Use a single MessageChannel so requests complete in FIFO order.
+ var self = cloneKey;
+ if (!self.channel) {
+ self.channel = new MessageChannel();
+ self.callbacks = [];
+ self.channel.port1.addEventListener('message', function(e) {
+ var callback = self.callbacks.shift();
+ callback(e.data);
+ }, false);
+ self.channel.port1.start();
+ }
+
+ return new Promise(function(resolve, reject) {
+ self.callbacks.push(resolve);
+ self.channel.port2.postMessage(key);
+ });
+}
+
+// Logging the serialized format ensures that if it changes it will break tests.
+function logSerializedKey(o)
+{
+ if (internals)
+ debug("Serialized key bytes: " + bytesToHexString(internals.serializeObject(o)));
+}
+
+function shouldEvaluateAs(actual, expectedValue)
+{
+ if (typeof expectedValue == "string")
+ return shouldBeEqualToString(actual, expectedValue);
+ return shouldEvaluateTo(actual, expectedValue);
+}
« no previous file with comments | « LayoutTests/crypto/clone-rsaKey-public-expected.txt ('k') | LayoutTests/fast/storage/resources/serialized-script-value.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698