Commit e1fac7c0 authored by adamk@chromium.org's avatar adamk@chromium.org

Force encoding to UTF-8 for HTML Imports

See spec bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=21275

R=abarth@chromium.org, morrita@chromium.org
BUG=336698

Review URL: https://codereview.chromium.org/178883002

git-svn-id: svn://svn.chromium.org/blink/trunk@171381 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 113b8e8d
Test that UTF-8 decoding is applied appropriately to imports
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Default encoding should be UTF-8...
PASS links[0].import.characterSet is "UTF-8"
And a meta tag should not override it...
PASS links[1].import.characterSet is "UTF-8"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<head>
<script src="../../../resources/js-test.js"></script>
<link rel="import" href="resources/no-encoding.html">
<link rel="import" href="resources/meta-encoding.html">
</head>
<body>
<script>
jsTestIsAsync = true;
window.onload = function() {
description("Test that UTF-8 decoding is applied appropriately to imports");
links = document.querySelectorAll('link[rel=import]');
debug("Default encoding should be UTF-8...");
shouldBeEqualToString("links[0].import.characterSet", "UTF-8");
debug("And a meta tag should not override it...");
shouldBeEqualToString("links[1].import.characterSet", "UTF-8");
finishJSTest();
};
</script>
</body>
<!DOCTYPE html>
<head>
<meta charset="EUC-JP">
</head>
<body>Hello, world</body>
Test that UTF-8 decoding is applied appropriately to imports
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Default encoding should be UTF-8...
PASS links[0].import.characterSet is "UTF-8"
And Content-Type headers should be ignored...
PASS links[1].import.characterSet is "UTF-8"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<head>
<script src="/js-test-resources/js-test.js"></script>
<link rel="import" href="resources/no-encoding.cgi">
<link rel="import" href="resources/http-encoding.cgi">
</head>
<body>
<script>
description("Test that UTF-8 decoding is applied appropriately to imports");
jsTestIsAsync = true;
window.onload = function() {
links = document.querySelectorAll('link[rel=import]');
debug("Default encoding should be UTF-8...");
shouldBeEqualToString("links[0].import.characterSet", "UTF-8");
debug("And Content-Type headers should be ignored...");
shouldBeEqualToString("links[1].import.characterSet", "UTF-8");
finishJSTest();
};
</script>
</body>
#!/usr/bin/perl
print "Content-Type: text/html; charset=EUC-JP\n";
print "Access-Control-Allow-Credentials: true\n";
print "Access-Control-Allow-Origin: http://127.0.0.1:8000\n\n";
print "<!DOCTYPE html><body>Hello, world</body>\n\n";
#!/usr/bin/perl
print "Content-Type: text/html\n";
print "Access-Control-Allow-Credentials: true\n";
print "Access-Control-Allow-Origin: http://127.0.0.1:8000\n\n";
print "<!DOCTYPE html><body>Hello, world</body>\n\n";
......@@ -108,7 +108,7 @@ HTMLImportLoader::State HTMLImportLoader::startWritingAndParsing(const ResourceR
DocumentInit init = DocumentInit(response.url(), 0, m_controller->master()->contextDocument(), m_controller)
.withRegistrationContext(m_controller->master()->registrationContext());
m_importedDocument = HTMLDocument::create(init);
m_writer = DocumentWriter::create(m_importedDocument.get(), response.mimeType(), response.textEncodingName());
m_writer = DocumentWriter::create(m_importedDocument.get(), response.mimeType(), "UTF-8");
return StateLoading;
}
......
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