WebCore:
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 9 Nov 2008 04:11:26 +0000 (04:11 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 9 Nov 2008 04:11:26 +0000 (04:11 +0000)
2008-11-08  Antti Koivisto  <antti@apple.com>

        Reviewed by Sam Weinig.

        Fix https://bugs.webkit.org/show_bug.cgi?id=22141
        REGRESSION: Safari error page is not fully styled when loaded from cache

        Reset text decoder on flush so it does not pass through the BOM when it is reused.

        Test: fast/encoding/css-cached-bom.html

        * loader/TextResourceDecoder.cpp:
        (WebCore::TextResourceDecoder::flush):

LayoutTests:

2008-11-08  Antti Koivisto  <antti@apple.com>

        Reviewed by Sam Weinig.

        Test for https://bugs.webkit.org/show_bug.cgi?id=22141
        REGRESSION: Safari error page is not fully styled when loaded from cache

        * fast/encoding/css-cached-bom.html: Added.
        * fast/encoding/css-cached-bom-expected.txt: Added.
        * fast/encoding/resources/css-cached-bom-frame.html: Added.
        * fast/encoding/resources/utf-16-little-endian.css: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@38240 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/encoding/css-cached-bom-expected.txt [new file with mode: 0644]
LayoutTests/fast/encoding/css-cached-bom.html [new file with mode: 0644]
LayoutTests/fast/encoding/resources/css-cached-bom-frame.html [new file with mode: 0644]
LayoutTests/fast/encoding/resources/utf-16-little-endian.css [new file with mode: 0644]
WebCore/ChangeLog
WebCore/loader/TextResourceDecoder.cpp

index abde779..556c889 100644 (file)
@@ -1,3 +1,15 @@
+2008-11-08  Antti Koivisto  <antti@apple.com>
+
+        Reviewed by Sam Weinig.
+        
+        Test for https://bugs.webkit.org/show_bug.cgi?id=22141
+        REGRESSION: Safari error page is not fully styled when loaded from cache
+
+        * fast/encoding/css-cached-bom.html: Added.
+        * fast/encoding/css-cached-bom-expected.txt: Added.
+        * fast/encoding/resources/css-cached-bom-frame.html: Added.
+        * fast/encoding/resources/utf-16-little-endian.css: Added.
+
 2008-11-08  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Dan Bernstein
diff --git a/LayoutTests/fast/encoding/css-cached-bom-expected.txt b/LayoutTests/fast/encoding/css-cached-bom-expected.txt
new file mode 100644 (file)
index 0000000..329ea59
--- /dev/null
@@ -0,0 +1,3 @@
+Test that stylesheet with BOM is correctly parsed when loaded from cache. You should see word SUCCESS below.
+
+SUCCESS
diff --git a/LayoutTests/fast/encoding/css-cached-bom.html b/LayoutTests/fast/encoding/css-cached-bom.html
new file mode 100644 (file)
index 0000000..a6e75eb
--- /dev/null
@@ -0,0 +1,20 @@
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+function frameLoaded() {
+    if (document.getElementById('f').contentDocument.styleSheets[0].cssRules[0].selectorText == "#success::before")
+        document.getElementById('result').innerHTML = "SUCCESS";
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+</script>
+<link rel=stylesheet href=resources/utf-16-little-endian.css>
+<!-- This halts the parsing until stylesheet has been loaded -->
+<script src=does_not_exists.js></script>
+<div>Test that stylesheet with BOM is correctly parsed when loaded from cache. You should see word SUCCESS below.</div>
+<!-- Load the stylesheet to a different frame. This will use a cached copy of the stylesheet. -->
+<iframe id=f src=resources/css-cached-bom-frame.html></iframe>
+<div id=result>FAIL</div>
+
diff --git a/LayoutTests/fast/encoding/resources/css-cached-bom-frame.html b/LayoutTests/fast/encoding/resources/css-cached-bom-frame.html
new file mode 100644 (file)
index 0000000..0412e3f
--- /dev/null
@@ -0,0 +1,5 @@
+<link rel=stylesheet href=utf-16-little-endian.css>
+<script>
+window.parent.frameLoaded();
+</script>
+
diff --git a/LayoutTests/fast/encoding/resources/utf-16-little-endian.css b/LayoutTests/fast/encoding/resources/utf-16-little-endian.css
new file mode 100644 (file)
index 0000000..2ca0c95
Binary files /dev/null and b/LayoutTests/fast/encoding/resources/utf-16-little-endian.css differ
index 78a3431..cd3a8b3 100644 (file)
@@ -1,3 +1,17 @@
+2008-11-08  Antti Koivisto  <antti@apple.com>
+
+        Reviewed by Sam Weinig.
+        
+        Fix https://bugs.webkit.org/show_bug.cgi?id=22141
+        REGRESSION: Safari error page is not fully styled when loaded from cache
+        
+        Reset text decoder on flush so it does not pass through the BOM when it is reused.
+
+        Test: fast/encoding/css-cached-bom.html
+
+        * loader/TextResourceDecoder.cpp:
+        (WebCore::TextResourceDecoder::flush):
+
 2008-11-08  Kevin Ollivier  <kevino@theolliviers.com>
  
         Reviewed by Mark Rowe.
index 4a0caa0..2064393 100644 (file)
@@ -793,6 +793,7 @@ String TextResourceDecoder::flush()
 {
     String result = m_decoder.decode(m_buffer.data(), m_buffer.size(), true, m_contentType == XML, m_sawError);
     m_buffer.clear();
+    m_decoder.reset(m_decoder.encoding());
     return result;
 }