OLD | NEW |
1 // Verifies that the given "bytes" holds the same value as "expectedHexString". | 1 // Verifies that the given "bytes" holds the same value as "expectedHexString". |
2 // "bytes" can be anything recognized by "bytesToHexString()". | 2 // "bytes" can be anything recognized by "bytesToHexString()". |
3 function bytesShouldMatchHexString(testDescription, expectedHexString, bytes) | 3 function bytesShouldMatchHexString(testDescription, expectedHexString, bytes) |
4 { | 4 { |
5 expectedHexString = "[" + expectedHexString.toLowerCase() + "]"; | 5 expectedHexString = "[" + expectedHexString.toLowerCase() + "]"; |
6 var actualHexString = "[" + bytesToHexString(bytes) + "]"; | 6 var actualHexString = "[" + bytesToHexString(bytes) + "]"; |
7 | 7 |
8 if (actualHexString === expectedHexString) { | 8 if (actualHexString === expectedHexString) { |
9 debug("PASS: " + testDescription + " should be " + expectedHexString + "
and was"); | 9 debug("PASS: " + testDescription + " should be " + expectedHexString + "
and was"); |
10 } else { | 10 } else { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 function asciiToUint8Array(str) | 53 function asciiToUint8Array(str) |
54 { | 54 { |
55 var chars = []; | 55 var chars = []; |
56 for (var i = 0; i < str.length; ++i) | 56 for (var i = 0; i < str.length; ++i) |
57 chars.push(str.charCodeAt(i)); | 57 chars.push(str.charCodeAt(i)); |
58 return new Uint8Array(chars); | 58 return new Uint8Array(chars); |
59 } | 59 } |
60 | 60 |
61 function failAndFinishJSTest(error) | 61 function failAndFinishJSTest(error) |
62 { | 62 { |
63 testFailed(error); | 63 testFailed('' + error); |
64 finishJSTest(); | 64 finishJSTest(); |
65 } | 65 } |
66 | 66 |
67 // Returns a Promise for the cloned key. | 67 // Returns a Promise for the cloned key. |
68 function cloneKey(key) | 68 function cloneKey(key) |
69 { | 69 { |
70 // Sending an object through a MessagePort implicitly clones it. | 70 // Sending an object through a MessagePort implicitly clones it. |
71 // Use a single MessageChannel so requests complete in FIFO order. | 71 // Use a single MessageChannel so requests complete in FIFO order. |
72 var self = cloneKey; | 72 var self = cloneKey; |
73 if (!self.channel) { | 73 if (!self.channel) { |
(...skipping 18 matching lines...) Expand all Loading... |
92 if (internals) | 92 if (internals) |
93 debug("Serialized key bytes: " + bytesToHexString(internals.serializeObj
ect(o))); | 93 debug("Serialized key bytes: " + bytesToHexString(internals.serializeObj
ect(o))); |
94 } | 94 } |
95 | 95 |
96 function shouldEvaluateAs(actual, expectedValue) | 96 function shouldEvaluateAs(actual, expectedValue) |
97 { | 97 { |
98 if (typeof expectedValue == "string") | 98 if (typeof expectedValue == "string") |
99 return shouldBeEqualToString(actual, expectedValue); | 99 return shouldBeEqualToString(actual, expectedValue); |
100 return shouldEvaluateTo(actual, expectedValue); | 100 return shouldEvaluateTo(actual, expectedValue); |
101 } | 101 } |
OLD | NEW |