<!DOCTYPE html>
<meta charset=utf-8>
<title>Subresource Integrity</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/sriharness.js"></script>

<div id="log"></div>

<div id="container"></div>
<script>
    var public_key = "qGFmwTxlocg707D1cX4w60iTwtfwbMLf8ITDyfko7s0="
    new SRIScriptTest(
        true,
        "Ed255519 signature, passes.",
        "ed25519-signature.js?1",
        "ed25519-" + public_key
    ).execute();
    new SRIScriptTest(
        false,
        "Ed255519 signature, fails because key is malformed.",
        "ed25519-signature.js?2",
        "ed25519-PotatoPotatoPotato"
    ).execute();
    new SRIScriptTest(
        false,
        "Ed255519 signature, fails because wrong key.",
        "ed25519-signature.js?3",
        "ed25519-PotatoPotatoPotatoPotatoPotatoAvocadoPotato="
    ).execute();
    new SRIScriptTest(
        false,
        "Ed255519 signature, fails because no signature in response header.",
        "ed25519-no-signature.js",
        "ed25519-" + public_key
    ).execute();
    new SRIScriptTest(
        false,
        "Ed255519 signature, fails because incorrect signature in response.",
        "ed25519-broken-signature.js",
        "ed25519-" + public_key
    ).execute();
    new SRIScriptTest(
        true,
        "Ed255519 signature, passes if any (first) of two keys passes.",
        "ed25519-signature.js?4",
        "ed25519-" + public_key +
            " ed25519-PotatoPotatoPotatoPotatoPotatoAvocadoPotato="
    ).execute();
    new SRIScriptTest(
        true,
        "Ed255519 signature, passes if any (second) of two keys passes.",
        "ed25519-signature.js?5",
        "ed25519-PotatoPotatoPotatoPotatoPotatoAvocadoPotato= ed25519-" +
            public_key
    ).execute();
    new SRIScriptTest(
        true,
        "Ed255519 signature, passes because at least one signature matches.",
        "ed25519-multi-signature.js",
        "ed25519-" + public_key
    ).execute();
    new SRIScriptTest(
        true,
        "Ed255519 signature, passes (as above), with commas between values.",
        "ed25519-multi-signature2.js",
        "ed25519-" + public_key
    ).execute();
    new SRIScriptTest(
        true,
        "Ed255519 signature, passes (as above), with multiple headers.",
        "ed25519-multi-signature-headers.js",
        "ed25519-" + public_key
    ).execute();
    new SRIScriptTest(
        true,
        "Ed255519 signature, passes, with multiple signature + multiple keys.",
        "ed25519-multi-signature.js?2",
        "ed25519-PotatoPotatoPotatoPotatoPotatoAvocadoPotato= ed25519-" +
            public_key
    ).execute();
</script>

