Diff
Modified: trunk/LayoutTests/ChangeLog (105694 => 105695)
--- trunk/LayoutTests/ChangeLog 2012-01-24 06:26:54 UTC (rev 105694)
+++ trunk/LayoutTests/ChangeLog 2012-01-24 06:43:26 UTC (rev 105695)
@@ -1,3 +1,21 @@
+2012-01-23 Alexey Proskuryakov <[email protected]>
+
+ REGRESSION: Downloaded file name fallback encodings are not set correctly
+ https://bugs.webkit.org/show_bug.cgi?id=76862
+
+ Reviewed by Adam Barth.
+
+ * http/tests/download/default-encoding-expected.txt: Added.
+ * http/tests/download/default-encoding.html: Added.
+ * http/tests/download/inherited-encoding-expected.txt: Added.
+ * http/tests/download/inherited-encoding.html: Added.
+ * http/tests/download/literal-utf-8-expected.txt: Added.
+ * http/tests/download/literal-utf-8.html: Added.
+ * http/tests/download/resources/literal-koi8-r.php: Added.
+ * http/tests/download/resources/literal-utf-8.php: Added.
+ * http/tests/download/inherited-encoding-form-submission-result-expected.txt: Added.
+ * http/tests/download/inherited-encoding-form-submission-result.html: Added.
+
2012-01-23 Ojan Vafai <[email protected]>
Implement flex-pack:distribute
Added: trunk/LayoutTests/http/tests/download/default-encoding-expected.txt (0 => 105695)
--- trunk/LayoutTests/http/tests/download/default-encoding-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/download/default-encoding-expected.txt 2012-01-24 06:43:26 UTC (rev 105695)
@@ -0,0 +1,5 @@
+Policy delegate: attempt to load http://127.0.0.1:8000/download/resources/literal-koi8-r.php with navigation type 'link clicked' originating from #text > A > BODY > HTML > #document
+Policy delegate: resource is an attachment, suggested file name 'SUССЕSS.txt'
+Downloaded file name should be "SUССЕSS.txt" (letters "CCE" are Cyrillic).
+
+Click Me
Added: trunk/LayoutTests/http/tests/download/default-encoding.html (0 => 105695)
--- trunk/LayoutTests/http/tests/download/default-encoding.html (rev 0)
+++ trunk/LayoutTests/http/tests/download/default-encoding.html 2012-01-24 06:43:26 UTC (rev 105695)
@@ -0,0 +1,21 @@
+<meta charset="utf-8">
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.overridePreference("WebKitDefaultTextEncodingName", "koi8-r");
+ layoutTestController.setCustomPolicyDelegate(true, true);
+ layoutTestController.waitForPolicyDelegate();
+}
+</script>
+<p>Downloaded file name should be "SUССЕSS.txt" (letters "CCE" are Cyrillic).</p>
+<a href="" id=link>Click Me</a>
+
+<script>
+if (window.eventSender) {
+ var link = document.getElementById("link");
+ eventSender.mouseMoveTo(link.offsetLeft + 2,
+ link.offsetTop + 2);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+}
+</script>
Added: trunk/LayoutTests/http/tests/download/inherited-encoding-expected.txt (0 => 105695)
--- trunk/LayoutTests/http/tests/download/inherited-encoding-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/download/inherited-encoding-expected.txt 2012-01-24 06:43:26 UTC (rev 105695)
@@ -0,0 +1,5 @@
+Policy delegate: attempt to load http://127.0.0.1:8000/download/resources/literal-koi8-r.php with navigation type 'link clicked' originating from #text > A > BODY > HTML > #document
+Policy delegate: resource is an attachment, suggested file name 'SUССЕSS.txt'
+Downloaded file name should be "SUССЕSS.txt" (letters "CCE" are Cyrillic).
+
+Click Me
Added: trunk/LayoutTests/http/tests/download/inherited-encoding-form-submission-result-expected.txt (0 => 105695)
--- trunk/LayoutTests/http/tests/download/inherited-encoding-form-submission-result-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/download/inherited-encoding-form-submission-result-expected.txt 2012-01-24 06:43:26 UTC (rev 105695)
@@ -0,0 +1,5 @@
+Policy delegate: attempt to load http://127.0.0.1:8000/download/resources/literal-koi8-r.php? with navigation type 'form submitted'
+Policy delegate: resource is an attachment, suggested file name 'SUССЕSS.txt'
+Downloaded file name should be "SUССЕSS.txt" (letters "CCE" are Cyrillic).
+
+
Added: trunk/LayoutTests/http/tests/download/inherited-encoding-form-submission-result.html (0 => 105695)
--- trunk/LayoutTests/http/tests/download/inherited-encoding-form-submission-result.html (rev 0)
+++ trunk/LayoutTests/http/tests/download/inherited-encoding-form-submission-result.html 2012-01-24 06:43:26 UTC (rev 105695)
@@ -0,0 +1,15 @@
+<meta charset="koi8-r">
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setCustomPolicyDelegate(true, true);
+ layoutTestController.waitForPolicyDelegate();
+}
+</script>
+<p>Downloaded file name should be "SU\xF3\xF3\xE5SS.txt" (letters "CCE" are Cyrillic).</p>
+<form action=""
+</form>
+
+<script>
+document.forms[0].submit();
+</script>
Added: trunk/LayoutTests/http/tests/download/inherited-encoding.html (0 => 105695)
--- trunk/LayoutTests/http/tests/download/inherited-encoding.html (rev 0)
+++ trunk/LayoutTests/http/tests/download/inherited-encoding.html 2012-01-24 06:43:26 UTC (rev 105695)
@@ -0,0 +1,20 @@
+<meta charset="koi8-r">
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setCustomPolicyDelegate(true, true);
+ layoutTestController.waitForPolicyDelegate();
+}
+</script>
+<p>Downloaded file name should be "SU\xF3\xF3\xE5SS.txt" (letters "CCE" are Cyrillic).</p>
+<a href="" id=link>Click Me</a>
+
+<script>
+if (window.eventSender) {
+ var link = document.getElementById("link");
+ eventSender.mouseMoveTo(link.offsetLeft + 2,
+ link.offsetTop + 2);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+}
+</script>
Added: trunk/LayoutTests/http/tests/download/literal-utf-8-expected.txt (0 => 105695)
--- trunk/LayoutTests/http/tests/download/literal-utf-8-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/download/literal-utf-8-expected.txt 2012-01-24 06:43:26 UTC (rev 105695)
@@ -0,0 +1,5 @@
+Policy delegate: attempt to load http://127.0.0.1:8000/download/resources/literal-utf-8.php with navigation type 'other'
+Policy delegate: resource is an attachment, suggested file name 'SUССЕSS.txt'
+Downloaded file name should be "SUССЕSS.txt" (letters "CCE" are Cyrillic).
+
+
Added: trunk/LayoutTests/http/tests/download/literal-utf-8.html (0 => 105695)
--- trunk/LayoutTests/http/tests/download/literal-utf-8.html (rev 0)
+++ trunk/LayoutTests/http/tests/download/literal-utf-8.html 2012-01-24 06:43:26 UTC (rev 105695)
@@ -0,0 +1,9 @@
+<meta charset="koi8-r"> <!-- Page charset should be ignored -->
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setCustomPolicyDelegate(true, true);
+}
+</script>
+<p>Downloaded file name should be "SU\xF3\xF3\xE5SS.txt" (letters "CCE" are Cyrillic).</p>
+<iframe src=""
Property changes: trunk/LayoutTests/http/tests/download/resources/basic-ascii.php
Deleted: svn:executable
Added: trunk/LayoutTests/http/tests/download/resources/literal-koi8-r.php (0 => 105695)
--- trunk/LayoutTests/http/tests/download/resources/literal-koi8-r.php (rev 0)
+++ trunk/LayoutTests/http/tests/download/resources/literal-koi8-r.php 2012-01-24 06:43:26 UTC (rev 105695)
@@ -0,0 +1,6 @@
+<?php
+header("Content-Disposition: attachment; filename=SU\xf3\xf3\xe5SS.txt");
+header("Content-Type: text/plain; charset=windows-1251"); // Content-Type charset does not affect header charset.
+?>
+
+Test file content.
Added: trunk/LayoutTests/http/tests/download/resources/literal-utf-8.php (0 => 105695)
--- trunk/LayoutTests/http/tests/download/resources/literal-utf-8.php (rev 0)
+++ trunk/LayoutTests/http/tests/download/resources/literal-utf-8.php 2012-01-24 06:43:26 UTC (rev 105695)
@@ -0,0 +1,6 @@
+<?php
+header("Content-Disposition: attachment; filename=SU\xd0\xa1\xd0\xa1\xd0\x95SS.txt");
+header("Content-Type: text/plain; charset=koi8-r"); // Content-Type charset does not affect header charset.
+?>
+
+Test file content.
Modified: trunk/Source/WebCore/ChangeLog (105694 => 105695)
--- trunk/Source/WebCore/ChangeLog 2012-01-24 06:26:54 UTC (rev 105694)
+++ trunk/Source/WebCore/ChangeLog 2012-01-24 06:43:26 UTC (rev 105695)
@@ -1,3 +1,24 @@
+2012-01-23 Alexey Proskuryakov <[email protected]>
+
+ REGRESSION: Downloaded file name fallback encodings are not set correctly
+ https://bugs.webkit.org/show_bug.cgi?id=76862
+
+ Reviewed by Adam Barth.
+
+ Tests: http/tests/download/default-encoding.html
+ http/tests/download/form-submission-result.html
+ http/tests/download/inherited-encoding.html
+ http/tests/download/literal-utf-8.html
+
+ * loader/DocumentWriter.cpp:
+ * loader/DocumentWriter.h:
+ Removed deprecatedFrameEncoding. Due to changes in Document::encoding behavior, it can now
+ be used in its place.
+
+ * loader/FrameLoader.cpp: (WebCore::FrameLoader::addExtraFieldsToRequest): Instead of hunting
+ down a correct loader (and active one is not always correct any more), just use opening document's
+ encoding.
+
2012-01-23 Ojan Vafai <[email protected]>
Implement flex-pack:distribute
Modified: trunk/Source/WebCore/loader/DocumentWriter.cpp (105694 => 105695)
--- trunk/Source/WebCore/loader/DocumentWriter.cpp 2012-01-24 06:26:54 UTC (rev 105694)
+++ trunk/Source/WebCore/loader/DocumentWriter.cpp 2012-01-24 06:43:26 UTC (rev 105695)
@@ -241,21 +241,6 @@
m_encodingWasChosenByUser = userChosen;
}
-String DocumentWriter::deprecatedFrameEncoding() const
-{
- Document* document = m_frame->document();
- if (!document || document->url().isEmpty())
- return m_encoding;
-
- if (m_encodingWasChosenByUser && !m_encoding.isEmpty())
- return m_encoding;
-
- if (m_decoder && m_decoder->encoding().isValid())
- return m_decoder->encoding().name();
-
- return String();
-}
-
void DocumentWriter::setDocumentWasLoadedAsPartOfNavigation()
{
ASSERT(!m_parser->isStopped());
Modified: trunk/Source/WebCore/loader/DocumentWriter.h (105694 => 105695)
--- trunk/Source/WebCore/loader/DocumentWriter.h 2012-01-24 06:26:54 UTC (rev 105694)
+++ trunk/Source/WebCore/loader/DocumentWriter.h 2012-01-24 06:43:26 UTC (rev 105695)
@@ -59,11 +59,6 @@
void setEncoding(const String& encoding, bool userChosen);
- // FIXME: It's really unforunate to need to expose this piece of state.
- // I suspect a better design is to disentangle user-provided encodings,
- // default encodings, and the decoding we're currently using.
- String deprecatedFrameEncoding() const;
-
const String& mimeType() const { return m_mimeType; }
void setMIMEType(const String& type) { m_mimeType = type; }
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (105694 => 105695)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2012-01-24 06:26:54 UTC (rev 105694)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2012-01-24 06:43:26 UTC (rev 105695)
@@ -2585,9 +2585,8 @@
addHTTPOriginIfNeeded(request, String());
// Always try UTF-8. If that fails, try frame encoding (if any) and then the default.
- // For a newly opened frame with an empty URL, encoding() should not be used, because this methods asks decoder, which uses ISO-8859-1.
Settings* settings = m_frame->settings();
- request.setResponseContentDispositionEncodingFallbackArray("UTF-8", activeDocumentLoader()->writer()->deprecatedFrameEncoding(), settings ? settings->defaultTextEncodingName() : String());
+ request.setResponseContentDispositionEncodingFallbackArray("UTF-8", m_frame->document()->encoding(), settings ? settings->defaultTextEncodingName() : String());
}
void FrameLoader::addHTTPOriginIfNeeded(ResourceRequest& request, const String& origin)
Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (105694 => 105695)
--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2012-01-24 06:26:54 UTC (rev 105694)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2012-01-24 06:43:26 UTC (rev 105695)
@@ -609,6 +609,7 @@
[preferences setDefaultFontSize:16];
[preferences setDefaultFixedFontSize:13];
[preferences setMinimumFontSize:0];
+ [preferences setDefaultTextEncodingName:@"ISO-8859-1"];
[preferences setJavaEnabled:NO];
[preferences setJavaScriptEnabled:YES];
[preferences setEditableLinkBehavior:WebKitEditableLinkOnlyLiveWithShiftKey];