-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTML: test stylesheet loading text/css requirement
See whatwg/html#3457 for clarifying this in the HTML Standard.
- Loading branch information
Showing
5 changed files
with
71 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
html/semantics/document-metadata/the-link-element/link-style-error-limited-quirks.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//" ""> | ||
<title>link: error events in limited quirks mode</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src=/common/get-host-info.sub.js></script> | ||
<div id="log"></div> | ||
<script src=resources/link-style-error.js></script> |
7 changes: 7 additions & 0 deletions
7
html/semantics/document-metadata/the-link-element/link-style-error-quirks.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!DOCTYPE HTML PUBLIC "-//Sun Microsystems Corp.//DTD HotJava Strict HTML//" ""> | ||
<title>link: error events in quirks mode</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src=/common/get-host-info.sub.js></script> | ||
<div id="log"></div> | ||
<script src=resources/link-style-error.js></script> |
7 changes: 7 additions & 0 deletions
7
html/semantics/document-metadata/the-link-element/resources/css.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
def main(request, response): | ||
response.add_required_headers = False | ||
if "content_type" in request.GET: | ||
response.writer.write_header("Content-Type", request.GET.first("content_type")) | ||
if "nosniff" in request.GET: | ||
response.writer.write_header("x-content-type-options", "nosniff") | ||
response.writer.write_content("body { background:red }") |
47 changes: 47 additions & 0 deletions
47
html/semantics/document-metadata/the-link-element/resources/link-style-error.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
["<link>", "@import"].forEach(linkType => { | ||
[ | ||
["same-origin", "resources/css.py"], | ||
["cross-origin", get_host_info().HTTP_REMOTE_ORIGIN + "/html/semantics/document-metadata/the-link-element/resources/css.py"] | ||
].forEach(originType => { | ||
["no Content-Type", "wrong Content-Type", "broken Content-Type"].forEach(contentType => { | ||
["no nosniff", "nosniff"].forEach(nosniff => { | ||
async_test(t => { | ||
const l = document.createElement("link"); | ||
t.add_cleanup(() => l.remove()); | ||
if (nosniff === "nosniff" || contentType === "wrong Content-Type" && (document.compatMode === "CSS1Compat" || originType[0] === "cross-origin")) { | ||
l.onerror = t.step_func_done(); | ||
l.onload = t.unreached_func("error event should have fired"); | ||
} else { | ||
l.onload = t.step_func_done(); | ||
l.onerror = t.unreached_func("load event should have fired"); | ||
} | ||
l.rel = "stylesheet"; | ||
let query = []; | ||
if (contentType === "broken Content-Type") { | ||
query.push("content_type=oops"); | ||
} else if (contentType === "wrong Content-Type") { | ||
query.push("content_type=text/plain") | ||
} | ||
if (nosniff === "nosniff") { | ||
query.push("nosniff"); | ||
} | ||
let stringQuery = ""; | ||
query.forEach(val => { | ||
if (stringQuery === "") { | ||
stringQuery += "?" + val; | ||
} else { | ||
stringQuery += "&" + val; | ||
} | ||
}); | ||
const link = new URL(originType[1] + stringQuery, location).href; | ||
if (linkType === "<link>") { | ||
l.href = link; | ||
} else { | ||
l.href = "data:text/css,@import url(" + link + ");"; | ||
} | ||
document.head.appendChild(l); | ||
}, "Stylesheet loading using " + linkType + " with " + contentType + ", " + originType[0] + ", and " + nosniff); | ||
}); | ||
}); | ||
}); | ||
}); |