Index: chrome/test/data/extensions/api_test/enterprise_platform_keys/basic.js |
diff --git a/chrome/test/data/extensions/api_test/enterprise_platform_keys/basic.js b/chrome/test/data/extensions/api_test/enterprise_platform_keys/basic.js |
index a5915009c4c2880b6360964490c6fb5f4308a9f5..f38cf54e8086b6db2022ebd23c86fa5e29e9c886 100644 |
--- a/chrome/test/data/extensions/api_test/enterprise_platform_keys/basic.js |
+++ b/chrome/test/data/extensions/api_test/enterprise_platform_keys/basic.js |
@@ -260,6 +260,50 @@ function beforeTests(callback) { |
}); |
} |
+function checkAlgorithmIsCopiedOnRead(key) { |
+ var algorithm = key.algorithm; |
+ var originalAlgorithm = { |
+ name: algorithm.name, |
+ modulusLength: algorithm.modulusLength, |
+ publicExponent: algorithm.publicExponent, |
+ hash: {name: algorithm.hash.name} |
+ }; |
+ var originalModulusLength = algorithm.modulusLength; |
+ algorithm.hash.name = null; |
+ algorithm.hash = null; |
+ algorithm.name = null; |
+ algorithm.modulusLength = null; |
+ algorithm.publicExponent = null; |
+ assertEq(originalAlgorithm, key.algorithm); |
+} |
+ |
+function checkPropertyIsReadOnly(object, key) { |
+ var original = object[key]; |
+ try { |
+ object[key] = {}; |
+ fail('Expected that the property is read only and an exception to ' + |
bartfab (slow)
2014/06/18 16:19:06
Nit: Grammar: "Expected the property to be read-on
|
+ 'be thrown'); |
+ } catch (error) { |
+ assertEq(original, object[key]); |
+ } |
+} |
+ |
+function checkKeyPairCommonFormat(keyPair) { |
+ checkPropertyIsReadOnly(keyPair, 'privateKey'); |
+ var privateKey = keyPair.privateKey; |
+ assertEq('private', privateKey.type); |
+ assertEq(false, privateKey.extractable); |
+ checkPropertyIsReadOnly(privateKey, 'algorithm'); |
+ checkAlgorithmIsCopiedOnRead(privateKey); |
+ |
+ checkPropertyIsReadOnly(keyPair, 'publicKey'); |
+ var publicKey = keyPair.publicKey; |
+ assertEq('public', publicKey.type); |
+ assertEq(true, publicKey.extractable); |
+ checkPropertyIsReadOnly(publicKey, 'algorithm'); |
+ checkAlgorithmIsCopiedOnRead(publicKey); |
+} |
+ |
function runTests(userToken) { |
chrome.test.runTests([ |
function hasSubtleCryptoMethods() { |
@@ -308,6 +352,9 @@ function runTests(userToken) { |
function(error) { fail("GenerateKey failed: " + error); }) |
.then(callbackPass(function(publicKeySpki) { |
// Ensure that the returned key pair has the expected format. |
+ // Some parameter independent checks: |
+ checkKeyPairCommonFormat(cachedKeyPair); |
+ |
// Checks depending on the generateKey arguments: |
var privateKey = cachedKeyPair.privateKey; |
assertEq(['sign'], privateKey.usages); |