Commit 79dcde71 authored by Yutaka Hirano's avatar Yutaka Hirano Committed by Commit Bot

Unflake http/tests/security/link-crossorigin-stylesheet-no-cors.html

The test is flaky because speculative preloads start, and in some cases
finish loading before disabling console message. Let's use testharness.js
in order to ignore console messages.

Bug: 882292
Change-Id: Ic6627f0bb941e7299ac611c2fd10e6469e1ed5e9
Reviewed-on: https://chromium-review.googlesource.com/1214978Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589832}
parent 0e8dc0e5
......@@ -5139,7 +5139,3 @@ crbug.com/878315 [ Mac ] virtual/threaded/fast/scroll-behavior/overscroll-behavi
# Sheriff 2018-08-23
crbug.com/877183 [ Linux Win ] external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/flexbox/flexbox-intrinsic-ratio-003v.html [ Pass Failure ]
crbug.com/882292 http/tests/security/link-crossorigin-stylesheet-no-cors.html [ Pass Failure ]
crbug.com/882292 virtual/outofblink-cors/http/tests/security/link-crossorigin-stylesheet-no-cors.html [ Pass Failure ]
crbug.com/882292 virtual/outofblink-cors-ns/http/tests/security/link-crossorigin-stylesheet-no-cors.html [ Pass Failure ]
PASS
PASS
PASS
PASS
PASS
PASS
PASS
PASS
PASS successfullyParsed is true
TEST COMPLETE
Test that a linked stylesheet with a crossorigin attribute does not load a cross-origin resource that isn't CORS enabled.
<!DOCTYPE HTML>
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
window.testCount = 8;
let counter = 0;
// Don't log console messages as the order of CORS error messages is not
// stable. It's ok to ignore them since we're checking whether the elements
// got loaded or errored.
if (window.testRunner) {
testRunner.setDumpConsoleMessages(false);
async_test((t) => {
self.test = t;
}, "A stylesheet with a crossorigin attribute should not load a cross-origin " +
"resource that isn't CORS enabled");
const fail = test.step_func((target) => {
const href = target.href;
assert_unreached('"' + href + '"');
});
function pass() {
++counter;
if (counter !== 8) {
return;
}
self.test.done();
}
</script>
<script src="resources/link-crossorigin-common.js"></script>
</head>
<body>
<p>Test that a linked stylesheet with a crossorigin attribute does not load a cross-origin resource that isn't CORS enabled.</p>
<link crossorigin="anonymous" rel="stylesheet" href="http://localhost:8080/security/resources/green-background.css?1" onload="fail()" onerror="pass()">
<link crossorigin="use-credentials" rel="stylesheet" href="http://localhost:8080/security/resources/green-background.css?2" onload="fail()" onerror="pass()">
<link crossorigin="anonymous" rel="stylesheet" href="http://localhost:8080/security/resources/green-background.css?1" onload="fail(this)" onerror="pass()">
<link crossorigin="use-credentials" rel="stylesheet" href="http://localhost:8080/security/resources/green-background.css?2" onload="fail(this)" onerror="pass()">
<!-- Check that from-cache loads are also failing (and does not generate separate loads.) -->
<link crossorigin="anonymous" rel="stylesheet" href="http://localhost:8080/security/resources/green-background.css?1" onload="fail()" onerror="pass()">
<link crossorigin="use-credentials" rel="stylesheet" href="http://localhost:8080/security/resources/green-background.css?2" onload="fail()" onerror="pass()">
<link crossorigin="anonymous" rel="stylesheet" href="http://localhost:8080/security/resources/green-background.css?1" onload="fail(this)" onerror="pass()">
<link crossorigin="use-credentials" rel="stylesheet" href="http://localhost:8080/security/resources/green-background.css?2" onload="fail(this)" onerror="pass()">
<!-- These are same-origin and should load as the fetch wasn't out of origin -->
<link crossorigin="anonymous" rel="stylesheet" href="resources/green-background.css?3" onload="pass()" onerror="fail()">
<link crossorigin="use-credentials" rel="stylesheet" href="resources/green-background.css?4" onload="pass()" onerror="fail()">
<link crossorigin="anonymous" rel="stylesheet" href="resources/green-background.css?3" onload="pass()" onerror="fail(this)">
<link crossorigin="use-credentials" rel="stylesheet" href="resources/green-background.css?4" onload="pass()" onerror="fail(this)">
<script>
function runTest()
{
......@@ -31,7 +43,7 @@ function runTest()
var link = document.createElement("link");
link.rel = "stylesheet";
link.crossOrigin = "anonymous";
link.onload = fail;
link.onload = fail.bind(link, link);
link.onerror = pass;
link.href = "http://localhost:8080/security/resources/green-background.css?8";
document.body.appendChild(link);
......@@ -39,7 +51,7 @@ function runTest()
link = document.createElement("link");
link.rel = "stylesheet";
link.crossOrigin = "use-credentials";
link.onload = fail;
link.onload = fail.bind(link, link);
link.onerror = pass;
link.href = "http://localhost:8080/security/resources/green-background.css?9";
document.body.appendChild(link);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment