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

Unified Diff: LayoutTests/crypto/resources/common.js

Issue 212173007: [refactor] Delete unused test code. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Improve logging if tests end with rejection of null Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/crypto/resources/common.js
diff --git a/LayoutTests/crypto/resources/common.js b/LayoutTests/crypto/resources/common.js
index 2038b3795a1430a6ef426839d0e5f277ad7c5bca..325281a25898b0cccf5052fd383e353b46fd51d4 100644
--- a/LayoutTests/crypto/resources/common.js
+++ b/LayoutTests/crypto/resources/common.js
@@ -1,32 +1,3 @@
-// FIXME: Delete this (tests should import their own keys).
-function importTestKeys()
-{
- var data = asciiToUint8Array("16 bytes of key!");
- var extractable = true;
- var keyUsages = ['wrapKey', 'unwrapKey', 'encrypt', 'decrypt', 'sign', 'verify'];
-
- var hmacPromise = crypto.subtle.importKey('raw', data, {name: 'hmac', hash: {name: 'sha-1'}}, extractable, keyUsages);
- var aesCbcPromise = crypto.subtle.importKey('raw', data, {name: 'AES-CBC'}, extractable, keyUsages);
- var aesCbcJustDecrypt = crypto.subtle.importKey('raw', data, {name: 'AES-CBC'}, false, ['decrypt']);
- // FIXME: use AES-CTR key type once it's implemented
- var aesCtrPromise = crypto.subtle.importKey('raw', data, {name: 'AES-CBC'}, extractable, keyUsages);
- var aesGcmPromise = crypto.subtle.importKey('raw', data, {name: 'AES-GCM'}, extractable, keyUsages);
- var rsaSsaSha1PublicPromise = crypto.subtle.importKey('spki', hexStringToUint8Array(kKeyData.rsa1.spki), {name: 'RSASSA-PKCS1-v1_5', hash: {name: 'sha-1'}}, extractable, keyUsages);
- var rsaSsaSha1PrivatePromise = crypto.subtle.importKey('pkcs8', hexStringToUint8Array(kKeyData.rsa1.pkcs8), {name: 'RSASSA-PKCS1-v1_5', hash: {name: 'sha-1'}}, extractable, keyUsages);
-
- return Promise.all([hmacPromise, aesCbcPromise, aesCbcJustDecrypt, aesCtrPromise, aesGcmPromise, rsaSsaSha1PublicPromise, rsaSsaSha1PrivatePromise]).then(function(results) {
- return {
- hmacSha1: results[0],
- aesCbc: results[1],
- aesCbcJustDecrypt: results[2],
- aesCtr: results[3],
- aesGcm: results[4],
- rsaSsaSha1Public: results[5],
- rsaSsaSha1Private: results[6],
- };
- });
-}
-
// Verifies that the given "bytes" holds the same value as "expectedHexString".
// "bytes" can be anything recognized by "bytesToHexString()".
function bytesShouldMatchHexString(testDescription, expectedHexString, bytes)
@@ -89,76 +60,10 @@ function asciiToUint8Array(str)
function failAndFinishJSTest(error)
{
- if (error)
- debug(error);
+ testFailed(error);
finishJSTest();
}
-// =====================================================
-// FIXME: Delete the addTask() functions (better to test results directly)
-// =====================================================
-
-numOutstandingTasks = 0;
-
-function addTask(promise)
-{
- numOutstandingTasks++;
-
- function taskFinished()
- {
- numOutstandingTasks--;
- completeTestWhenAllTasksDone();
- }
-
- promise.then(taskFinished, taskFinished);
-}
-
-function completeTestWhenAllTasksDone()
-{
- if (numOutstandingTasks == 0) {
- finishJSTest();
- }
-}
-
-function shouldRejectPromiseWithNull(code)
-{
- var promise = eval(code);
-
- function acceptCallback(result)
- {
- debug("FAIL: '" + code + "' accepted with " + result + " but should have been rejected");
- }
-
- function rejectCallback(result)
- {
- if (result == null)
- debug("PASS: '" + code + "' rejected with null");
- else
- debug("FAIL: '" + code + "' rejected with " + result + " but was expecting null");
- }
-
- addTask(promise.then(acceptCallback, rejectCallback));
-}
-
-function shouldAcceptPromise(code)
-{
- var promise = eval(code);
-
- function acceptCallback(result)
- {
- debug("PASS: '" + code + "' accepted with " + result);
- }
-
- function rejectCallback(result)
- {
- debug("FAIL: '" + code + "' rejected with " + result);
- }
-
- addTask(promise.then(acceptCallback, rejectCallback));
-}
-
-// =====================================================
-
// Returns a Promise for the cloned key.
function cloneKey(key)
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698