Index: third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-generateCertificate.html |
diff --git a/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-generateCertificate.html b/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-generateCertificate.html |
index 65e2837c9bc1f44aa7da90be469660ebd458565b..bd17fc0e1d71c45817e6813a332613191446df12 100644 |
--- a/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-generateCertificate.html |
+++ b/third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-generateCertificate.html |
@@ -13,12 +13,13 @@ var dayInMs = 24 * 60 * minuteInMs; |
// Signature of the last generateCertificate call. |
var generateCallString = null; |
-// Global certificate variables so that the "should..." methods can evaluate them. |
+// Global variables so that the "should..." methods can evaluate them. |
var certRSA = null; |
var certECDSA = null; |
var certExpiresNegativeOneDay = null; |
var certExpiresZero = null; |
var certExpiresPositiveOneDay = null; |
+var fingerprints = null; |
// 1: RSA-2048 using public exponent = 65537. |
function generate1RSA() |
@@ -101,6 +102,35 @@ function certificateSanityCheck(certVariableName) |
{ |
shouldBeNonNull(certVariableName); |
shouldBeTrue('new Date().getTime() < ' + certVariableName + '.expires'); |
+ shouldBeTrue(certVariableName + '.getFingerprints().length == 1'); |
+ shouldBeTrue(certVariableName + '.getFingerprints()[0].algorithm === "sha-256"'); |
+ shouldBeTrue('isFingerprintValue(' + |
+ certVariableName + '.getFingerprints()[0].value)'); |
+ |
+ // The returned array is frozen and should not be modifiable. |
+ fingerprints = eval(certVariableName + '.getFingerprints()'); |
+ shouldBeTrue('(function(){ fingerprints[0] = null; return fingerprints[0] != null; })()'); |
+ try { |
+ fingerprints.push(null); |
+ fail('Exception not thrown doing ' + fingerprints.push(null)); |
+ } catch (e) { |
+ } |
+ // The elements of the array should be modifiable. |
+ shouldBeTrue('(function(){ fingerprints[0].value = "garbage"; return fingerprints[0].value === "garbage"; })()'); |
+ // The certificate should always return fingerprint copies, not harmed by modifications. |
+ shouldBeTrue(certVariableName + '.getFingerprints()[0] != ' + certVariableName + '.getFingerprints()[0]'); |
+} |
+function isFingerprintValue(fingerprint) { |
+ // / Begin regex |
+ // ^ Start of line |
+ // (?: Non-capturing parenthesis |
+ // [a-z0-9]{2} 2 lowercase alphanumeric characters |
+ // \: The : character |
+ // )+ End of parenthesis, match 1 or more times |
+ // [a-z0-9]{2} 2 lowercase alphanumeric characters |
+ // $ End of line |
+ // / End of regex |
+ return /^(?:[a-z0-9]{2}\:)+[a-z0-9]{2}$/.test(fingerprint); |
} |
// Run each generate test sequentially. The ith generate method will make sure |