Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(611)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/import-enforce-blocked.php

Issue 2408443003: Make ResourceFetcher return Resources with LoadError instead of nullptrs. (Closed)
Patch Set: Add comment. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/import-enforce-blocked.php
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/import-enforce-blocked.php b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/import-enforce-blocked.php
index 2f134fc303d35e955dcfc4a0bea2642233bde055..5b3d138a2fbcd4736edf682b66699259d39703d3 100644
--- a/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/import-enforce-blocked.php
+++ b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/import-enforce-blocked.php
@@ -5,23 +5,33 @@
<script nonce="abc" src="/resources/testharness.js"></script>
<script nonce="abc" src="/resources/testharnessreport.js"></script>
<script nonce="abc">
+ // HTML imports are render-blocking, therefore the test must not complete
+ // before the import finishes (or fails) loading, otherwise, the test output
+ // will be empty (or at least flaky).
+ //
+ // This is because testharness.js appends the results as <pre> elements to the
+ // DOM, and then dumps the document as text. However, in a non-rendering-ready
+ // document, all elements are effectively `display: none`, and as such would
+ // not appear in the dump.
async_test(t => {
window.onload = t.step_func(_ => {
var link = document.createElement('link');
link.setAttribute("rel", "import");
link.setAttribute("nonce", "zyx");
link.setAttribute("href", "/security/resources/blank.html");
-
- var watcher = new EventWatcher(t, document, ['securitypolicyviolation']);
- watcher
- .wait_for('securitypolicyviolation')
- .then(t.step_func_done(e => {
- assert_false(!!link.import, "The import was not loaded.");
- assert_equals(e.blockedURI, "http://127.0.0.1:8000/security/resources/blank.html");
- assert_equals(e.lineNumber, 21);
- }));
-
+ link.onload = t.unreached_func();
+ link.onerror = t.step_func_done();
document.body.appendChild(link);
});
- }, "Incorrectly nonced imports do not load, and trigger reports.");
+ }, "Incorrectly nonced imports do not load.");
+
+ async_test(t => {
+ var watcher = new EventWatcher(t, document, ['securitypolicyviolation']);
+ watcher
+ .wait_for('securitypolicyviolation')
+ .then(t.step_func_done(e => {
+ assert_equals(e.blockedURI, "http://127.0.0.1:8000/security/resources/blank.html");
+ assert_equals(e.lineNumber, 21);
+ }));
+ }, "Incorrectly nonced imports trigger reports.");
</script>

Powered by Google App Engine
This is Rietveld 408576698