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: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615479}
diff --git a/css/cssom/stylesheet-same-origin.sub.html b/css/cssom/stylesheet-same-origin.sub.html
index e317745..ef71467 100644
--- a/css/cssom/stylesheet-same-origin.sub.html
+++ b/css/cssom/stylesheet-same-origin.sub.html
@@ -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");
diff --git a/css/cssom/support/malformed-http-response.asis b/css/cssom/support/malformed-http-response.asis
new file mode 100644
index 0000000..bc3c68d
--- /dev/null
+++ b/css/cssom/support/malformed-http-response.asis
@@ -0,0 +1 @@
+HAHAHA THIS IS NOT HTTP AND THE BROWSER SHOULD CONSIDER IT A NETWORK ERROR