Index: third_party/WebKit/LayoutTests/http/tests/security/subresourceIntegrity/subresource-integrity-script-cors-bad-integrity.html |
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/subresourceIntegrity/subresource-integrity-script-cors-bad-integrity.html b/third_party/WebKit/LayoutTests/http/tests/security/subresourceIntegrity/subresource-integrity-script-cors-bad-integrity.html |
index 98f79398265850ae646fc5fb6f0766ff05d47bbf..ade24ee29e27c3977489c35eb90317e072422669 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/security/subresourceIntegrity/subresource-integrity-script-cors-bad-integrity.html |
+++ b/third_party/WebKit/LayoutTests/http/tests/security/subresourceIntegrity/subresource-integrity-script-cors-bad-integrity.html |
@@ -7,15 +7,38 @@ |
<script src="/resources/testharnessreport.js"></script> |
<script> |
var result = ''; |
- var scriptLoaded = function() { |
- assert_unreached('Script loaded.'); |
- done(); |
+ // Tests script tag variations corresponding to conditions in |
+ // https://html.spec.whatwg.org/#prepare-a-script, because they |
+ // are implemented by different code paths. |
+ // These tests differ in async/defer attributes |
+ // and whether they are dynamically inserted. |
+ var test1 = async_test('1st Clause, Step 23 of prepare a script'); |
+ var test2 = async_test('2nd Clause, Step 23 of prepare a script'); |
+ var test3 = async_test('3rd Clause, Step 23 of prepare a script'); |
+ var test4 = async_test('4th Clause, Step 23 of prepare a script'); |
+ var scriptLoaded = function(t) { |
+ t.step(function() { |
+ assert_unreached('Script loaded.'); |
+ t.done(); |
+ }); |
}; |
- var scriptError = function() { |
- assert_equals(result, '', 'Script did not run.'); |
- done(); |
+ var scriptError = function(t) { |
+ t.step(function() { |
+ assert_equals(result, '', 'Script did not run.'); |
+ t.done(); |
+ }); |
}; |
+ var script3 = document.createElement('script'); |
+ script3.setAttribute('integrity', 'sha256-deadbeef'); |
+ script3.setAttribute('crossorigin', ''); |
+ script3.onload = scriptLoaded.bind(undefined, test3); |
+ script3.onerror = scriptError.bind(undefined, test3); |
+ script3.src = 'http://localhost:8000/security/resources/cors-script.php?value=ran&test=3'; |
+ script3.async = false; |
+ document.head.appendChild(script3); |
</script> |
- <script crossorigin integrity="sha256-deadbeef" src="http://localhost:8000/security/resources/cors-script.php?value=ran" onload="scriptLoaded();" onerror="scriptError();"></script> |
+ <script crossorigin integrity="sha256-deadbeef" src="http://localhost:8000/security/resources/cors-script.php?value=ran&test=1" onload="scriptLoaded(test1);" onerror="scriptError(test1);" defer></script> |
+ <script crossorigin integrity="sha256-deadbeef" src="http://localhost:8000/security/resources/cors-script.php?value=ran&test=2" onload="scriptLoaded(test2);" onerror="scriptError(test2);"></script> |
+ <script crossorigin integrity="sha256-deadbeef" src="http://localhost:8000/security/resources/cors-script.php?value=ran&test=4" onload="scriptLoaded(test4);" onerror="scriptError(test4);" async></script> |
</body> |
</html> |