Commit f2128a15 authored by Matt Falkenhagen's avatar Matt Falkenhagen Committed by Commit Bot

WPT: CSS: Add same-origin tests for loading error stylesheets.

This adds a test that a stylesheet that failed to load is considered
cross-origin. That is, accessing |styleSheet.rules| throws a
SecurityError.  This aligns with the specifications:
- cssRules checks the `origin-clean` flag:
  https://drafts.csswg.org/cssom/#dom-cssstylesheet-cssrules
- This is set to true iff CORS-same-origin:
  https://html.spec.whatwg.org/multipage/links.html#link-type-stylesheet
- CORS-same-origin is false for "error" responses:
  https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-same-origin

Bug: 911974
Change-Id: I558e6d3dfa564b15284c393ffc35b80f54a9bc4e
Reviewed-on: https://chromium-review.googlesource.com/c/1371307
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615479}
parent ad82ea67
......@@ -4,6 +4,9 @@ PASS Origin-clean check in cross-origin CSSOM Stylesheets (redirect from same-or
FAIL Origin-clean check in cross-origin CSSOM Stylesheets (redirect from cross-origin to same-origin) assert_throws: stylesheet.cssRules should throw SecurityError. function "function () {
sheet.cssRules;
}" did not throw
FAIL Origin-clean check in loading error CSSOM Stylesheets assert_throws: stylesheet.cssRules should throw SecurityError. function "function () {
sheet.cssRules;
}" did not throw
PASS Origin-clean check in same-origin CSSOM Stylesheets
PASS Origin-clean check in data:css CSSOM Stylesheets
Harness: the test ran to completion.
......
......@@ -16,11 +16,13 @@
<link id="redirect-crossorigin-to-sameorigin"
href="http://www1.{{host}}:{{ports[http][1]}}/common/redirect.py?location=http://{{host}}:{{ports[http][0]}}/css/cssom/stylesheet-same-origin.css"
rel="stylesheet">
<link id="loaderror" href="support/malformed-http-response.asis" rel="stylesheet">
<script>
var crossorigin = document.getElementById("crossorigin").sheet;
var redirectSameOriginToCrossOrigin = document.getElementById("redirect-sameorigin-to-crossorigin").sheet;
var redirectCrossOriginToSameOrigin = document.getElementById("redirect-crossorigin-to-sameorigin").sheet;
var loadError = document.getElementById("loaderror").sheet;
var sameorigin = document.getElementById("sameorigin").sheet;
var sameorigindata = document.getElementById("sameorigindata").sheet;
......@@ -63,6 +65,10 @@
doOriginDirtyCheck(redirectCrossOriginToSameOrigin);
}, "Origin-clean check in cross-origin CSSOM Stylesheets (redirect from cross-origin to same-origin)");
test(function() {
doOriginDirtyCheck(loadError);
}, "Origin-clean check in loading error CSSOM Stylesheets");
test(function() {
doOriginCleanCheck(sameorigin, "Same-origin");
}, "Origin-clean check in same-origin CSSOM Stylesheets");
......
HAHAHA THIS IS NOT HTTP AND THE BROWSER SHOULD CONSIDER IT A NETWORK ERROR
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