-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1812620 [wpt PR 38199] - Encoding/HTML: cross-document encoding i…
…nheritance , a=testonly Automatic update from web-platform-tests Encoding/HTML: cross-document encoding inheritance Make Encoding tests no longer rely on an interoperability issue and simultaneously add tests for that issue. The latter tests align with the HTML Standard, but that might not necessarily be the path we want to take. whatwg/html#8789 can be used for further discussion. -- wpt-commits: a58bbf6d8c0db1f1fd5352e846acb0754ee55567 wpt-pr: 38199
- Loading branch information
1 parent
67fa1b3
commit 2c92b27
Showing
7 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
testing/web-platform/tests/encoding/resources/text-html-meta-charset.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,3 @@ | ||
def main(request, response): | ||
response.headers.set(b"Content-Type", b"text/html") | ||
response.content = b"<meta charset=\"" + request.GET.first(b"label") + b"\">hello encoding" |
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
35 changes: 35 additions & 0 deletions
35
testing/web-platform/tests/html/syntax/charset/inheritance-bogus-meta-utf-8.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,35 @@ | ||
<!doctype html> | ||
<meta charset="utf-8" /> | ||
<title>Inheriting from UTF-8 parent</title> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<div id=log></div> | ||
<script> | ||
[ | ||
{ | ||
"title": "Child with bogus <meta charset>", | ||
"url": "resources/bogus-charset.html", | ||
"expected": "\uFFFD\n" // 0x00A2 in windows-1252 is 0xFFFD in UTF-8 | ||
}, | ||
{ | ||
"title": "Child with bogus Content-Type charset", | ||
"url": "resources/bogus-charset-http.py", | ||
"expected": "\uFFFD\n" | ||
}, | ||
{ | ||
"title": "Child with bogus Content-Type charset, but valid <meta charset>", | ||
"url": "resources/bogus-charset-http-valid-meta.py", | ||
"expected": "\u045E\n" | ||
} | ||
].forEach(({ title, url, expected }) => { | ||
async_test(t => { | ||
const frame = document.createElement("iframe"); | ||
t.add_cleanup(() => frame.remove()); | ||
frame.src = url; | ||
frame.onload = t.step_func_done(() => { | ||
assert_equals(frame.contentDocument.body.textContent, expected); | ||
}); | ||
document.body.append(frame); | ||
}, title); | ||
}); | ||
</script> |
46 changes: 46 additions & 0 deletions
46
testing/web-platform/tests/html/syntax/charset/inheritance-bogus-meta.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,46 @@ | ||
<!doctype html> | ||
<meta charset=windows-1253> | ||
<title>Inheriting from windows-1253 parent</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> | ||
[ | ||
{ | ||
"title": "Child with bogus <meta charset>", | ||
"url": "resources/bogus-charset.html", | ||
"expected": "¢\n" // 0x00A2 in windows-1252 is at the same position as 0x0386 in windows-1253 | ||
}, | ||
{ | ||
"title": "Child with bogus Content-Type charset", | ||
"url": "resources/bogus-charset-http.py", | ||
"expected": "¢\n" | ||
}, | ||
{ | ||
"title": "Child with bogus Content-Type charset, but valid <meta charset>", | ||
"url": "resources/bogus-charset-http-valid-meta.py", | ||
"expected": "\u045E\n" | ||
} | ||
].forEach(({ title, url, expected }) => { | ||
async_test(t => { | ||
const frame = document.createElement("iframe"); | ||
t.add_cleanup(() => frame.remove()); | ||
frame.src = url; | ||
frame.onload = t.step_func_done(() => { | ||
assert_equals(frame.contentDocument.body.textContent, expected); | ||
}); | ||
document.body.append(frame); | ||
}, title); | ||
}); | ||
|
||
async_test(t => { | ||
self.onmessage = t.step_func_done(({ data }) => { | ||
assert_equals(data, "\u00A2\n"); | ||
}); | ||
const frame = document.createElement("iframe"); | ||
t.add_cleanup(() => frame.remove()); | ||
frame.src = get_host_info().HTTP_REMOTE_ORIGIN + new URL("resources/bogus-charset.html", location).pathname + "?postMessage"; | ||
document.body.append(frame); | ||
}, "Cross-origin child with bogus <meta charset>"); | ||
</script> |
4 changes: 4 additions & 0 deletions
4
testing/web-platform/tests/html/syntax/charset/resources/bogus-charset-http-valid-meta.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,4 @@ | ||
def main(request, response): | ||
response.headers.set(b"Content-Type", b"text/html;charset=this-is-not-a-charset") | ||
# ¢ | ||
response.content = b"<meta charset=windows-1251>\xA2\n" |
4 changes: 4 additions & 0 deletions
4
testing/web-platform/tests/html/syntax/charset/resources/bogus-charset-http.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,4 @@ | ||
def main(request, response): | ||
response.headers.set(b"Content-Type", b"text/html;charset=this-is-not-a-charset") | ||
# ¢ | ||
response.content = b"\xA2\n" |
7 changes: 7 additions & 0 deletions
7
testing/web-platform/tests/html/syntax/charset/resources/bogus-charset.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><meta charset=this-is-not-a-charset><script> | ||
onload = () => { | ||
if (location.search === "?postMessage") { | ||
parent.postMessage(document.body.textContent, "*"); | ||
} | ||
} | ||
</script>¢ |