Drop [TreatReturnedNullStringAs=Undefined] WebKit-specific IDL attribute
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Feb 2016 23:24:14 +0000 (23:24 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Feb 2016 23:24:14 +0000 (23:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=154662

Reviewed by Darin Adler.

Source/WebCore:

Drop [TreatReturnedNullStringAs=Undefined] WebKit-specific IDL attribute.
This has no standard equivalent and all uses in WebKit are either useless
or wrong.

Test: fast/frames/detached-frame-document-defaultCharset.html

* bindings/scripts/CodeGeneratorJS.pm:
(NativeToJSValue): Deleted.
* bindings/scripts/IDLAttributes.txt:
Drop support for [TreatReturnedNullStringAs=X] entirely.

* dom/Document.cpp:
(WebCore::Document::defaultCharset):
Fall back to return "UTF-8" instead of the null string, similarly to
what is done in for Document.characterSet. Note that this attribute
is non-standard and is an IE extension. Firefox never supported it
and Chrome dropped it last year.

* dom/Document.idl:
- Drop extended attribute for Document.defaultCharset as the
  implementation has been updated to never return a null String.
- Drop extended attribute for Document.readyState. It was useless
  because the implementation could never return a null String.

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::getAllResponseHeaders):
Update implementation to return emptyString() instead of "" in case
of error.

* xml/XMLHttpRequest.idl:
Drop extended attribute from XMLHttpRequest.getAllResponseHeaders().
It was useless because the implementation could never return a
null String.

* xml/XSLTProcessor.idl:
Drop extended attribute from XSLTProcessor.getParameter(). The
operation is already marked as [Custom] so the extended attribute
had no effect.

LayoutTests:

Add layout test to cover the return value of document.defaultCharset before
and after its frame is detached.

* fast/frames/detached-frame-document-defaultCharset-expected.txt: Added.
* fast/frames/detached-frame-document-defaultCharset.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/frames/detached-frame-document-defaultCharset-expected.txt [new file with mode: 0644]
LayoutTests/fast/frames/detached-frame-document-defaultCharset.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLAttributes.txt
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.idl
Source/WebCore/xml/XMLHttpRequest.cpp
Source/WebCore/xml/XMLHttpRequest.idl
Source/WebCore/xml/XSLTProcessor.idl

index 100bb85..5d2476b 100644 (file)
@@ -1,3 +1,16 @@
+2016-02-25  Chris Dumez  <cdumez@apple.com>
+
+        Drop [TreatReturnedNullStringAs=Undefined] WebKit-specific IDL attribute
+        https://bugs.webkit.org/show_bug.cgi?id=154662
+
+        Reviewed by Darin Adler.
+
+        Add layout test to cover the return value of document.defaultCharset before
+        and after its frame is detached.
+
+        * fast/frames/detached-frame-document-defaultCharset-expected.txt: Added.
+        * fast/frames/detached-frame-document-defaultCharset.html: Added.
+
 2016-02-25  Ryan Haddad  <ryanhaddad@apple.com>
 
         Removing failure expectation for 26 editing tests that now pass on ios-simulator
diff --git a/LayoutTests/fast/frames/detached-frame-document-defaultCharset-expected.txt b/LayoutTests/fast/frames/detached-frame-document-defaultCharset-expected.txt
new file mode 100644 (file)
index 0000000..9a925c9
--- /dev/null
@@ -0,0 +1,13 @@
+Tests the value returned by document.defaultCharset before and after its frame is detached.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS childDocument.defaultCharset is "ISO-8859-1"
+Detaching frame.
+PASS childDocument.defaultCharset is "UTF-8"
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/frames/detached-frame-document-defaultCharset.html b/LayoutTests/fast/frames/detached-frame-document-defaultCharset.html
new file mode 100644 (file)
index 0000000..ca03ff0
--- /dev/null
@@ -0,0 +1,18 @@
+<script src="../../resources/js-test-pre.js"></script>
+<script>
+description("Tests the value returned by document.defaultCharset before and after its frame is detached.");
+jsTestIsAsync = true;
+
+onload = function()
+{
+    childDocument = frames[0].document;
+    shouldBeEqualToString("childDocument.defaultCharset", "ISO-8859-1");
+    debug("Detaching frame.");
+    document.body.removeChild(document.getElementsByTagName("iframe")[0]);
+    shouldBeEqualToString("childDocument.defaultCharset", "UTF-8");
+    debug("");
+    finishJSTest();
+}
+</script>
+<iframe src="about:blank"></iframe>
+<script src="../../resources/js-test-post.js"></script>
index b240624..3516a36 100644 (file)
@@ -1,3 +1,49 @@
+2016-02-25  Chris Dumez  <cdumez@apple.com>
+
+        Drop [TreatReturnedNullStringAs=Undefined] WebKit-specific IDL attribute
+        https://bugs.webkit.org/show_bug.cgi?id=154662
+
+        Reviewed by Darin Adler.
+
+        Drop [TreatReturnedNullStringAs=Undefined] WebKit-specific IDL attribute.
+        This has no standard equivalent and all uses in WebKit are either useless
+        or wrong.
+
+        Test: fast/frames/detached-frame-document-defaultCharset.html
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (NativeToJSValue): Deleted.
+        * bindings/scripts/IDLAttributes.txt:
+        Drop support for [TreatReturnedNullStringAs=X] entirely.
+
+        * dom/Document.cpp:
+        (WebCore::Document::defaultCharset):
+        Fall back to return "UTF-8" instead of the null string, similarly to
+        what is done in for Document.characterSet. Note that this attribute
+        is non-standard and is an IE extension. Firefox never supported it
+        and Chrome dropped it last year.
+
+        * dom/Document.idl:
+        - Drop extended attribute for Document.defaultCharset as the
+          implementation has been updated to never return a null String.
+        - Drop extended attribute for Document.readyState. It was useless
+          because the implementation could never return a null String.
+
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::getAllResponseHeaders):
+        Update implementation to return emptyString() instead of "" in case
+        of error.
+
+        * xml/XMLHttpRequest.idl:
+        Drop extended attribute from XMLHttpRequest.getAllResponseHeaders().
+        It was useless because the implementation could never return a
+        null String.
+
+        * xml/XSLTProcessor.idl:
+        Drop extended attribute from XSLTProcessor.getParameter(). The
+        operation is already marked as [Custom] so the extended attribute
+        had no effect.
+
 2016-02-25  Gavin Barraclough  <barraclough@apple.com>
 
         Should template RefCounter instead of RefCounter::Token
index 1fe7a68..acde3ab 100644 (file)
@@ -4260,12 +4260,6 @@ sub NativeToJSValue
 
     if ($codeGenerator->IsStringType($type)) {
         AddToImplIncludes("URL.h", $conditional);
-        my $conv = $signature->extendedAttributes->{"TreatReturnedNullStringAs"};
-        if (defined $conv) {
-            return "jsStringOrUndefined(state, $value)" if $conv eq "Undefined";
-
-            die "Unknown value for TreatReturnedNullStringAs extended attribute";
-        }
         return "jsStringOrNull(state, $value)" if $signature->isNullable;
         AddToImplIncludes("<runtime/JSString.h>", $conditional);
         return "jsStringWithCache(state, $value)";
index 225f8c7..91d9682 100644 (file)
@@ -121,7 +121,6 @@ StrictTypeChecking
 SuppressToJSObject
 TreatNullAs=NullString
 TreatReturnedNaNDateAs=Null|NaN
-TreatReturnedNullStringAs=Undefined
 TreatUndefinedAs=NullString
 TypedArray=*
 URL
index 387bb3d..d02eb2c 100644 (file)
@@ -1294,7 +1294,7 @@ String Document::defaultCharset() const
 {
     if (Settings* settings = this->settings())
         return settings->defaultTextEncodingName();
-    return String();
+    return UTF8Encoding().domName();
 }
 
 void Document::setCharset(const String& charset)
index a9fed93..68a54b8 100644 (file)
     // IE extensions
 
 #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C || defined(LANGUAGE_GOBJECT) && LANGUAGE_GOBJECT
-    [TreatReturnedNullStringAs=Undefined, TreatNullAs=NullString] attribute DOMString charset;
+    attribute DOMString charset;
 #else
     [ImplementedAs=characterSetWithUTF8Fallback] readonly attribute DOMString charset;
 #endif
-    [TreatReturnedNullStringAs=Undefined] readonly attribute DOMString defaultCharset;
-    [TreatReturnedNullStringAs=Undefined] readonly attribute DOMString readyState;
+    readonly attribute DOMString defaultCharset;
+    readonly attribute DOMString readyState;
 
     Element            elementFromPoint([Default=Undefined] optional long x, 
                                         [Default=Undefined] optional long y);
index 4a18c0b..7ba335c 100644 (file)
@@ -961,7 +961,7 @@ void XMLHttpRequest::setRequestHeader(const String& name, const String& value, E
 String XMLHttpRequest::getAllResponseHeaders() const
 {
     if (m_state < HEADERS_RECEIVED || m_error)
-        return "";
+        return emptyString();
 
     StringBuilder stringBuilder;
 
index 72a541a..2ad5cba 100644 (file)
@@ -69,7 +69,7 @@ enum XMLHttpRequestResponseType {
     readonly attribute XMLHttpRequestUpload upload;
 
     // response
-    [TreatReturnedNullStringAs=Undefined] DOMString getAllResponseHeaders();
+    DOMString getAllResponseHeaders();
     DOMString? getResponseHeader(DOMString header);
     [GetterRaisesException, CustomGetter] readonly attribute DOMString? responseText;
     [GetterRaisesException] readonly attribute Document responseXML;
index 1ecd61f..d9297e5 100644 (file)
@@ -41,7 +41,7 @@
     Document transformToDocument([Default=Undefined] optional Node source);
 
     [Custom] void setParameter(DOMString namespaceURI, DOMString localName, DOMString value);
-    [Custom, TreatReturnedNullStringAs=Undefined] DOMString getParameter(DOMString namespaceURI, DOMString localName);
+    [Custom] DOMString getParameter(DOMString namespaceURI, DOMString localName);
     [Custom] void removeParameter(DOMString namespaceURI, DOMString localName);
     void clearParameters();