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

Side by Side Diff: LayoutTests/crypto/resources/common.js

Issue 268273002: [webcrypto] Make KeyPair structured clonable. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: change up comment once more Created 6 years, 7 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
OLDNEW
1 function logError(error) 1 function logError(error)
2 { 2 {
3 debug("error is: " + error.toString()); 3 debug("error is: " + error.toString());
4 } 4 }
5 5
6 // Verifies that the given "bytes" holds the same value as "expectedHexString". 6 // Verifies that the given "bytes" holds the same value as "expectedHexString".
7 // "bytes" can be anything recognized by "bytesToHexString()". 7 // "bytes" can be anything recognized by "bytesToHexString()".
8 function bytesShouldMatchHexString(testDescription, expectedHexString, bytes) 8 function bytesShouldMatchHexString(testDescription, expectedHexString, bytes)
9 { 9 {
10 expectedHexString = "[" + expectedHexString.toLowerCase() + "]"; 10 expectedHexString = "[" + expectedHexString.toLowerCase() + "]";
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 chars.push(str.charCodeAt(i)); 62 chars.push(str.charCodeAt(i));
63 return new Uint8Array(chars); 63 return new Uint8Array(chars);
64 } 64 }
65 65
66 function failAndFinishJSTest(error) 66 function failAndFinishJSTest(error)
67 { 67 {
68 testFailed('' + error); 68 testFailed('' + error);
69 finishJSTest(); 69 finishJSTest();
70 } 70 }
71 71
72 // Returns a Promise for the cloned key. 72 // FIXME: Delete this and use cloneObject() directly.
73 function cloneKey(key) 73 function cloneKey(key)
74 { 74 {
75 return cloneObject(key);
76 }
77
78 // Returns a Promise for the cloned object.
79 function cloneObject(obj)
80 {
75 // Sending an object through a MessagePort implicitly clones it. 81 // Sending an object through a MessagePort implicitly clones it.
76 // Use a single MessageChannel so requests complete in FIFO order. 82 // Use a single MessageChannel so requests complete in FIFO order.
77 var self = cloneKey; 83 var self = cloneObject;
78 if (!self.channel) { 84 if (!self.channel) {
79 self.channel = new MessageChannel(); 85 self.channel = new MessageChannel();
80 self.callbacks = []; 86 self.callbacks = [];
81 self.channel.port1.addEventListener('message', function(e) { 87 self.channel.port1.addEventListener('message', function(e) {
82 var callback = self.callbacks.shift(); 88 var callback = self.callbacks.shift();
83 callback(e.data); 89 callback(e.data);
84 }, false); 90 }, false);
85 self.channel.port1.start(); 91 self.channel.port1.start();
86 } 92 }
87 93
88 return new Promise(function(resolve, reject) { 94 return new Promise(function(resolve, reject) {
89 self.callbacks.push(resolve); 95 self.callbacks.push(resolve);
90 self.channel.port2.postMessage(key); 96 self.channel.port2.postMessage(obj);
91 }); 97 });
92 } 98 }
93 99
94 // Logging the serialized format ensures that if it changes it will break tests. 100 // Logging the serialized format ensures that if it changes it will break tests.
95 function logSerializedKey(o) 101 function logSerializedKey(o)
96 { 102 {
97 if (internals) { 103 if (internals) {
98 // Removing the version tag from the output so serialization format chan ges don't need to update all the crypto tests. 104 // Removing the version tag from the output so serialization format chan ges don't need to update all the crypto tests.
99 var serialized = internals.serializeObject(o); 105 var serialized = internals.serializeObject(o);
100 var serializedWithoutVersion = new Uint8Array(serialized, 2); 106 var serializedWithoutVersion = new Uint8Array(serialized, 2);
101 debug("Serialized key bytes: " + bytesToHexString(serializedWithoutVersi on)); 107 debug("Serialized key bytes: " + bytesToHexString(serializedWithoutVersi on));
102 } 108 }
103 } 109 }
104 110
105 function shouldEvaluateAs(actual, expectedValue) 111 function shouldEvaluateAs(actual, expectedValue)
106 { 112 {
107 if (typeof expectedValue == "string") 113 if (typeof expectedValue == "string")
108 return shouldBeEqualToString(actual, expectedValue); 114 return shouldBeEqualToString(actual, expectedValue);
109 return shouldEvaluateTo(actual, expectedValue); 115 return shouldEvaluateTo(actual, expectedValue);
110 } 116 }
OLDNEW
« no previous file with comments | « LayoutTests/crypto/clone-rsaKeyPair-expected.txt ('k') | Source/bindings/v8/SerializedScriptValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698