| Index: LayoutTests/http/tests/security/subresourceIntegrity/subresource-integrity-fetch.html
|
| diff --git a/LayoutTests/http/tests/security/subresourceIntegrity/subresource-integrity-fetch.html b/LayoutTests/http/tests/security/subresourceIntegrity/subresource-integrity-fetch.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..89762fb0c0f8d0af9dca66219e4bdbc69fca4673
|
| --- /dev/null
|
| +++ b/LayoutTests/http/tests/security/subresourceIntegrity/subresource-integrity-fetch.html
|
| @@ -0,0 +1,48 @@
|
| +<!DOCTYPE html>
|
| +<html>
|
| +<head>
|
| +<title>Tests integrity enforcement on fetch()</title>
|
| +<script src="/resources/testharness.js"></script>
|
| +<script src="/resources/testharnessreport.js"></script>
|
| +</head>
|
| +<body>
|
| +<script>
|
| +var SRITest = function(pass, name, src, integrity) {
|
| + this.pass = pass;
|
| + this.name = name;
|
| + this.src = src;
|
| + this.integrity = integrity;
|
| +}
|
| +SRITest.prototype.execute = function() {
|
| + var test = async_test(this.name);
|
| + var pass = this.pass;
|
| + var integrity = this.integrity;
|
| + var options = {};
|
| + if (integrity !== '') {
|
| + options.integrity = integrity;
|
| + }
|
| + fetch(this.src, options)
|
| + .then(test.step_func(function(response) {
|
| + if (pass) {
|
| + test.done();
|
| + } else {
|
| + assert_unreached("Response on bad fetch.");
|
| + }
|
| + }))
|
| + .catch(test.step_func(function(error) {
|
| + if (pass) {
|
| + assert_unreached("Network error on good fetch.");
|
| + } else {
|
| + test.done();
|
| + }
|
| + }));
|
| +}
|
| +
|
| +new SRITest(true, 'No integrity', 'call-success.js', '').execute();
|
| +new SRITest(true, 'Good integrity', 'call-success.js', 'sha256-B0/62fJSJFrdjEFR9ba04m/D+LHQ+zG6PGcaR0Trpxg=').execute();
|
| +new SRITest(false, 'Bad integrity', 'call-success.js', 'sha256-deadbeef').execute();
|
| +new SRITest(false, 'Bad integrity and an img', '/resources/square100.png', 'sha256-B0/62fJSJFrdjEFR9ba04m/D+LHQ+zG6PGcaR0Trpxg=').execute();
|
| +new SRITest(true, 'Good integrity and an img', '/resources/square100.png', 'sha256-xZjdcorjj+TiKGteFFcrNbdqrDns2iVURBpGpAwp12k=').execute();
|
| +</script>
|
| +</body>
|
| +</html>
|
|
|