Index: LayoutTests/crypto/resources/common.js |
diff --git a/LayoutTests/crypto/resources/common.js b/LayoutTests/crypto/resources/common.js |
index 8169e9be66654a7a8200edeb3168499318d6b15b..0f195f6958264662a93101ed7f959334b7e03d67 100644 |
--- a/LayoutTests/crypto/resources/common.js |
+++ b/LayoutTests/crypto/resources/common.js |
@@ -39,6 +39,11 @@ function bytesToHexString(bytes) |
return hexBytes.join(""); |
} |
+function bytesToASCIIString(bytes) |
+{ |
+ return String.fromCharCode.apply(null, new Uint8Array(bytes)); |
+} |
+ |
function hexStringToUint8Array(hexString) |
{ |
if (hexString.length % 2 != 0) |
@@ -63,6 +68,17 @@ function asciiToUint8Array(str) |
return new Uint8Array(chars); |
} |
+var Base64URL = { |
+ stringify: function (a) { |
+ var base64string = btoa(String.fromCharCode.apply(0, a)); |
+ return base64string.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_"); |
+ }, |
+ parse: function (s) { |
+ s = s.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, ''); |
+ return new Uint8Array(Array.prototype.map.call(atob(s), function (c) { return c.charCodeAt(0) })); |
+ } |
+}; |
+ |
function failAndFinishJSTest(error) |
{ |
testFailed('' + error); |