Unreviewed, roll out r215229

It caused CachedScripts in MemoryCache to be reused with different encodings
even though CachedScript potentially has already decoded data or cached hash
with a previous encoding.

LayoutTests/imported/w3c:

* web-platform-tests/html/semantics/scripting-1/the-script-element/script-charset-01-expected.txt:

Source/WebCore:

* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::setEncoding):
* loader/TextResourceDecoder.h:
(WebCore::TextResourceDecoder::sawError):
(WebCore::TextResourceDecoder::encodingSet): Deleted.
* loader/cache/CachedCSSStyleSheet.cpp:
(WebCore::CachedCSSStyleSheet::setEncoding):
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::CachedResource):
* loader/cache/CachedResource.h:
(WebCore::CachedResource::hasUnknownEncoding):
(WebCore::CachedResource::setHasUnknownEncoding):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::determineRevalidationPolicy):

LayoutTests:

* TestExpectations:
* fast/loader/cache-encoding-expected.txt:
* fast/loader/cache-encoding.html:
* http/tests/preload/preload-encoding-expected.txt:
* http/tests/preload/preload-encoding.php:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@217289 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index a760479..ce69888 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2017-05-23  Chris Dumez  <cdumez@apple.com>
+
+        Unreviewed, roll out r215229
+
+        It caused CachedScripts in MemoryCache to be reused with different encodings
+        even though CachedScript potentially has already decoded data or cached hash
+        with a previous encoding.
+
+        * TestExpectations:
+        * fast/loader/cache-encoding-expected.txt:
+        * fast/loader/cache-encoding.html:
+        * http/tests/preload/preload-encoding-expected.txt:
+        * http/tests/preload/preload-encoding.php:
+
 2017-05-23  Ryan Haddad  <ryanhaddad@apple.com>
 
         Skip LayoutTest imported/w3c/web-platform-tests/innerText/getter.html.
diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations
index 895098f..f250394 100644
--- a/LayoutTests/TestExpectations
+++ b/LayoutTests/TestExpectations
@@ -1169,6 +1169,8 @@
 ### END OF display: contents failures
 ########################################
 
+webkit.org/b/170122 http/tests/preload/single_download_preload_headers_charset.php [ Pass Failure ]
+
 ########################################
 ### START OF -disabled tests
 
diff --git a/LayoutTests/fast/loader/cache-encoding-expected.txt b/LayoutTests/fast/loader/cache-encoding-expected.txt
index 50962df..785d97d 100644
--- a/LayoutTests/fast/loader/cache-encoding-expected.txt
+++ b/LayoutTests/fast/loader/cache-encoding-expected.txt
@@ -1,11 +1,11 @@
+CONSOLE MESSAGE: line 1: SyntaxError: Invalid character '\u8307'
 First load a script with a wrong charset then again with the right one. Second attempt should work and 'scriptSuccess' should be set to true. 'successfullyParsed' will be undefined.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
 PASS scriptSuccess is true
-PASS scriptSuccess is true
-PASS successfullyParsed is true
+FAIL successfullyParsed should be true (of type boolean). Was undefined (of type undefined).
 
 TEST COMPLETE
 
diff --git a/LayoutTests/fast/loader/cache-encoding.html b/LayoutTests/fast/loader/cache-encoding.html
index c4758cd..0bbb60a 100644
--- a/LayoutTests/fast/loader/cache-encoding.html
+++ b/LayoutTests/fast/loader/cache-encoding.html
@@ -16,9 +16,8 @@
 
 function test()
 {
-    appendScriptWithCharset("utf-8", function () {
-        shouldBeTrue("scriptSuccess");
-        appendScriptWithCharset("utf-16", function () {
+    appendScriptWithCharset("utf-16", function () {
+        appendScriptWithCharset("utf-8", function () {
             shouldBeTrue("scriptSuccess");
             finishJSTest();
         });
diff --git a/LayoutTests/http/tests/preload/preload-encoding-expected.txt b/LayoutTests/http/tests/preload/preload-encoding-expected.txt
index 50962df..785d97d 100644
--- a/LayoutTests/http/tests/preload/preload-encoding-expected.txt
+++ b/LayoutTests/http/tests/preload/preload-encoding-expected.txt
@@ -1,11 +1,11 @@
+CONSOLE MESSAGE: line 1: SyntaxError: Invalid character '\u8307'
 First load a script with a wrong charset then again with the right one. Second attempt should work and 'scriptSuccess' should be set to true. 'successfullyParsed' will be undefined.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
 PASS scriptSuccess is true
-PASS scriptSuccess is true
-PASS successfullyParsed is true
+FAIL successfullyParsed should be true (of type boolean). Was undefined (of type undefined).
 
 TEST COMPLETE
 
diff --git a/LayoutTests/http/tests/preload/preload-encoding.php b/LayoutTests/http/tests/preload/preload-encoding.php
index 4dddf33..38e8398 100644
--- a/LayoutTests/http/tests/preload/preload-encoding.php
+++ b/LayoutTests/http/tests/preload/preload-encoding.php
@@ -19,10 +19,8 @@
 
 function test()
 {
-    appendScriptWithCharset("utf-8", function () {
-        shouldBeTrue("scriptSuccess");
-        scriptSuccess = false;
-        appendScriptWithCharset("utf-16", function () {
+    appendScriptWithCharset("utf-16", function () {
+        appendScriptWithCharset("utf-8", function () {
             shouldBeTrue("scriptSuccess");
             finishJSTest();
         });
diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog
index 287dfb5..671075f 100644
--- a/LayoutTests/imported/w3c/ChangeLog
+++ b/LayoutTests/imported/w3c/ChangeLog
@@ -1,3 +1,13 @@
+2017-05-23  Chris Dumez  <cdumez@apple.com>
+
+        Unreviewed, roll out r215229
+
+        It caused CachedScripts in MemoryCache to be reused with different encodings
+        even though CachedScript potentially has already decoded data or cached hash
+        with a previous encoding.
+
+        * web-platform-tests/html/semantics/scripting-1/the-script-element/script-charset-01-expected.txt:
+
 2017-05-23 Emilio Cobos Álvarez  <ecobos@igalia.com>
 
         Import the css-display-3 css tests.
diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/script-charset-01-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/script-charset-01-expected.txt
index fe3fdb7..cc4a5b0 100644
--- a/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/script-charset-01-expected.txt
+++ b/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/script-charset-01-expected.txt
@@ -2,7 +2,7 @@
 PASS Script @type: unknown parameters 
 PASS Script @type: unknown parameters 1 
 PASS Script @type: unknown parameters 2 
-FAIL Script @type: unknown parameters 3 assert_equals: expected "śćążź" but got "\ufffd湿\ufffd"
+PASS Script @type: unknown parameters 3 
 PASS Script @type: unknown parameters 4 
 PASS Script @type: unknown parameters 5