Index: third_party/WebKit/LayoutTests/http/tests/security/subresourceIntegrity/resources/subresource-integrity-fetch-worker.js |
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/subresourceIntegrity/resources/subresource-integrity-fetch-worker.js b/third_party/WebKit/LayoutTests/http/tests/security/subresourceIntegrity/resources/subresource-integrity-fetch-worker.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..64183f5b94ad77d8866bb6aadea301f594caf410 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/http/tests/security/subresourceIntegrity/resources/subresource-integrity-fetch-worker.js |
@@ -0,0 +1,28 @@ |
+importScripts('/resources/testharness.js'); |
+console.log('hehehe'); |
+const url = '../call-success.js'; |
+const integrity = 'sha256-B0/62fJSJFrdjEFR9ba04m/D+LHQ+zG6PGcaR0Trpxg='; |
+ |
+promise_test(() => { |
+ return fetch(url).then(res => res.text()).then(text => { |
+ assert_equals(text, 'success();\n'); |
+ }); |
+}, 'No integrity'); |
+ |
+promise_test(() => { |
+ return fetch(url, {integrity: integrity}).then(res => { |
+ return res.text(); |
+ }).then(text => { |
+ assert_equals(text, 'success();\n'); |
+ }); |
+}, 'Good integrity'); |
+ |
+promise_test(() => { |
+ return fetch(url, {integrity: 'sha256-deadbeaf'}).then(res => { |
+ assert_unreached('the integrity check should fail'); |
+ }, () => { |
+ // The integrity check should fail. |
+ }); |
+}, 'Bad integrity'); |
+ |
+done(); |