chromium/third_party/blink/web_tests/crypto/subtle/aes-kw/generateKey-failures.html

<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>

<script>
description("Tests generateKey() with bad AES-KW parameters.");
jsTestIsAsync = true;

extractable = true;
keyUsages = ['wrapKey', 'unwrapKey'];

function testNoLength()
{
    return expectFailure(
        "generateKey() without length...",
        crypto.subtle.generateKey({ name: 'aes-kw' }, extractable, keyUsages));
}

function testBigLength()
{
    return expectFailure(
        "generateKey() with a length of 70000...",
        crypto.subtle.generateKey({ name: 'aes-kw', length: 70000 }, extractable, keyUsages));
}

function testNegativeLength()
{
    return expectFailure(
        "generateKey() with a length of -3...",
        crypto.subtle.generateKey({ name: 'aes-kw', length: -3 }, extractable, keyUsages));
}

function testMinusInfinity()
{
    return expectFailure(
        "generateKey() with length that is minus Infinity...",
        crypto.subtle.generateKey({ name: 'aes-kw', length: -Infinity }, extractable, keyUsages));
}

Promise.resolve(null)
    .then(testNoLength)
    .then(testBigLength)
    .then(testNegativeLength)
    .then(testMinusInfinity)
    .then(finishJSTest, failAndFinishJSTest);

</script>

</body>
</html>