<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[212181] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/212181">212181</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-02-10 21:49:23 -0800 (Fri, 10 Feb 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WebIDL] Cleanup XMLHttpRequest's bindings
https://bugs.webkit.org/show_bug.cgi?id=168067

Patch by Sam Weinig &lt;sam@webkit.org&gt; on 2017-02-10
Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/XMLHttpRequest/setrequestheader-bogus-name-expected.txt:
* web-platform-tests/XMLHttpRequest/setrequestheader-bogus-value-expected.txt:
Update results now that we pass.

Source/WebCore:

* bindings/js/JSDOMBinding.cpp:
(WebCore::jsOwnedStringOrNull): Deleted.
* bindings/js/JSDOMBinding.h:
Remove jsOwnedStringOrNull and inline it into it's one use
in JSXMLHttpRequestCustom.

* bindings/js/JSXMLHttpRequestCustom.cpp:
(WebCore::JSXMLHttpRequest::responseText):
(WebCore::SendFunctor::SendFunctor): Deleted.
(WebCore::SendFunctor::line): Deleted.
(WebCore::SendFunctor::column): Deleted.
(WebCore::SendFunctor::url): Deleted.
(WebCore::SendFunctor::operator()): Deleted.
(WebCore::JSXMLHttpRequest::send): Deleted.
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::send):
* xml/XMLHttpRequest.h:
Remove custom send, replacing it with a single send implementation that
takes a variant.

* xml/XMLHttpRequest.idl:
Cleanup the IDL to better match the spec. Update correct types where trivial.

LayoutTests:

* http/tests/xmlhttprequest/set-bad-headervalue.html:
Update test now that we throw the correct exceptions.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestsxmlhttprequestsetbadheadervaluehtml">trunk/LayoutTests/http/tests/xmlhttprequest/set-bad-headervalue.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsXMLHttpRequestsetrequestheaderbogusnameexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-bogus-name-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsXMLHttpRequestsetrequestheaderbogusvalueexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-bogus-value-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMBindingcpp">trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMBindingh">trunk/Source/WebCore/bindings/js/JSDOMBinding.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSXMLHttpRequestCustomcpp">trunk/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorexmlXMLHttpRequestcpp">trunk/Source/WebCore/xml/XMLHttpRequest.cpp</a></li>
<li><a href="#trunkSourceWebCorexmlXMLHttpRequesth">trunk/Source/WebCore/xml/XMLHttpRequest.h</a></li>
<li><a href="#trunkSourceWebCorexmlXMLHttpRequestidl">trunk/Source/WebCore/xml/XMLHttpRequest.idl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (212180 => 212181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-02-11 05:33:44 UTC (rev 212180)
+++ trunk/LayoutTests/ChangeLog        2017-02-11 05:49:23 UTC (rev 212181)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2017-02-10  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        [WebIDL] Cleanup XMLHttpRequest's bindings
+        https://bugs.webkit.org/show_bug.cgi?id=168067
+
+        Reviewed by Chris Dumez.
+
+        * http/tests/xmlhttprequest/set-bad-headervalue.html:
+        Update test now that we throw the correct exceptions.
+
</ins><span class="cx"> 2017-02-10  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         document.origin doesn't match spec
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsxmlhttprequestsetbadheadervaluehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/xmlhttprequest/set-bad-headervalue.html (212180 => 212181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/xmlhttprequest/set-bad-headervalue.html        2017-02-11 05:33:44 UTC (rev 212180)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/set-bad-headervalue.html        2017-02-11 05:49:23 UTC (rev 212181)
</span><span class="lines">@@ -15,21 +15,21 @@
</span><span class="cx">           var client = new XMLHttpRequest()
</span><span class="cx">           client.open(&quot;GET&quot;, &quot;...&quot;)
</span><span class="cx">           if (expectError)
</span><del>-              assert_throws(&quot;SyntaxError&quot;, function() { client.setRequestHeader(&quot;x-test&quot;, value) }, ' given value ' + value+', ')
</del><ins>+              assert_throws(expectError, function() { client.setRequestHeader(&quot;x-test&quot;, value) }, ' given value ' + value+', ')
</ins><span class="cx">           else
</span><span class="cx">               client.setRequestHeader(&quot;x-test&quot;, value)  
</span><span class="cx">           })
</span><span class="cx">       }
</span><span class="cx"> 
</span><del>-      try_value(&quot;t\rt&quot;, true)
-      try_value(&quot;t\nt&quot;, true)
-      try_value(&quot;テスト&quot;, true)
-      try_value(&quot;t\bt&quot;, true)
-      try_value(&quot;t\vt&quot;, true)
-      try_value(&quot;t\tt&quot;, false)
-      try_value(&quot;t t&quot;, false)
-      try_value(&quot;\xd0\xa1&quot;, false)
-      try_value(&quot;\x7f&quot;, true)
</del><ins>+      try_value(&quot;t\rt&quot;, {name:'SyntaxError'})
+      try_value(&quot;t\nt&quot;, {name:'SyntaxError'})
+      try_value(&quot;テスト&quot;, {name:'TypeError'})
+      try_value(&quot;t\bt&quot;, {name:'SyntaxError'})
+      try_value(&quot;t\vt&quot;, {name:'SyntaxError'})
+      try_value(&quot;t\tt&quot;)
+      try_value(&quot;t t&quot;)
+      try_value(&quot;\xd0\xa1&quot;)
+      try_value(&quot;\x7f&quot;, {name:'SyntaxError'})
</ins><span class="cx">       test(function() {
</span><span class="cx">         var client = new XMLHttpRequest()
</span><span class="cx">         client.open(&quot;GET&quot;, &quot;...&quot;)
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (212180 => 212181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2017-02-11 05:33:44 UTC (rev 212180)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2017-02-11 05:49:23 UTC (rev 212181)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-02-10  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        [WebIDL] Cleanup XMLHttpRequest's bindings
+        https://bugs.webkit.org/show_bug.cgi?id=168067
+
+        Reviewed by Chris Dumez.
+
+        * web-platform-tests/XMLHttpRequest/setrequestheader-bogus-name-expected.txt:
+        * web-platform-tests/XMLHttpRequest/setrequestheader-bogus-value-expected.txt:
+        Update results now that we pass.
+
</ins><span class="cx"> 2017-02-10  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         document.origin doesn't match spec
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsXMLHttpRequestsetrequestheaderbogusnameexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-bogus-name-expected.txt (212180 => 212181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-bogus-name-expected.txt        2017-02-11 05:33:44 UTC (rev 212180)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-bogus-name-expected.txt        2017-02-11 05:49:23 UTC (rev 212181)
</span><span class="lines">@@ -68,6 +68,6 @@
</span><span class="cx"> PASS setRequestHeader should throw with header name &quot;\x1d&quot;. 
</span><span class="cx"> PASS setRequestHeader should throw with header name &quot;\x1e&quot;. 
</span><span class="cx"> PASS setRequestHeader should throw with header name &quot;\x1f&quot;. 
</span><del>-FAIL setRequestHeader should throw with header name &quot;テスト&quot;. assert_throws: function &quot;function () { client.setRequestHeader(name, 'x-value') }&quot; threw object &quot;SyntaxError (DOM Exception 12): The string did not match the expected pattern.&quot; (&quot;SyntaxError&quot;) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
-FAIL setRequestHeader should throw with header name &quot;X-テスト&quot;. assert_throws: function &quot;function () { client.setRequestHeader(name, 'x-value') }&quot; threw object &quot;SyntaxError (DOM Exception 12): The string did not match the expected pattern.&quot; (&quot;SyntaxError&quot;) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
</del><ins>+PASS setRequestHeader should throw with header name &quot;テスト&quot;. 
+PASS setRequestHeader should throw with header name &quot;X-テスト&quot;. 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsXMLHttpRequestsetrequestheaderbogusvalueexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-bogus-value-expected.txt (212180 => 212181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-bogus-value-expected.txt        2017-02-11 05:33:44 UTC (rev 212180)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/setrequestheader-bogus-value-expected.txt        2017-02-11 05:49:23 UTC (rev 212181)
</span><span class="lines">@@ -3,6 +3,6 @@
</span><span class="cx"> PASS XMLHttpRequest: setRequestHeader() value argument checks 1 
</span><span class="cx"> PASS XMLHttpRequest: setRequestHeader() value argument checks 2 
</span><span class="cx"> PASS XMLHttpRequest: setRequestHeader() value argument checks 3 
</span><del>-FAIL XMLHttpRequest: setRequestHeader() value argument checks 4 assert_throws:  given value テスト, function &quot;function () { client.setRequestHeader(&quot;x-test&quot;, &quot;テスト&quot;) }&quot; threw object &quot;SyntaxError (DOM Exception 12): The string did not match the expected pattern.&quot; (&quot;SyntaxError&quot;) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
</del><ins>+PASS XMLHttpRequest: setRequestHeader() value argument checks 4 
</ins><span class="cx"> PASS Omitted value argument 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (212180 => 212181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-02-11 05:33:44 UTC (rev 212180)
+++ trunk/Source/WebCore/ChangeLog        2017-02-11 05:49:23 UTC (rev 212181)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2017-02-10  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        [WebIDL] Cleanup XMLHttpRequest's bindings
+        https://bugs.webkit.org/show_bug.cgi?id=168067
+
+        Reviewed by Chris Dumez.
+
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::jsOwnedStringOrNull): Deleted.
+        * bindings/js/JSDOMBinding.h:
+        Remove jsOwnedStringOrNull and inline it into it's one use
+        in JSXMLHttpRequestCustom.
+
+        * bindings/js/JSXMLHttpRequestCustom.cpp:
+        (WebCore::JSXMLHttpRequest::responseText):
+        (WebCore::SendFunctor::SendFunctor): Deleted.
+        (WebCore::SendFunctor::line): Deleted.
+        (WebCore::SendFunctor::column): Deleted.
+        (WebCore::SendFunctor::url): Deleted.
+        (WebCore::SendFunctor::operator()): Deleted.
+        (WebCore::JSXMLHttpRequest::send): Deleted.
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::send):
+        * xml/XMLHttpRequest.h:
+        Remove custom send, replacing it with a single send implementation that
+        takes a variant.
+
+        * xml/XMLHttpRequest.idl:
+        Cleanup the IDL to better match the spec. Update correct types where trivial.
+
</ins><span class="cx"> 2017-02-10  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         document.origin doesn't match spec
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMBindingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp (212180 => 212181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp        2017-02-11 05:33:44 UTC (rev 212180)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp        2017-02-11 05:49:23 UTC (rev 212181)
</span><span class="lines">@@ -33,13 +33,6 @@
</span><span class="cx">     commonVM().addImpureProperty(propertyName);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSValue jsOwnedStringOrNull(ExecState* exec, const String&amp; s)
-{
-    if (s.isNull())
-        return jsNull();
-    return jsOwnedString(exec, s);
-}
-
</del><span class="cx"> JSValue jsStringOrUndefined(ExecState* exec, const String&amp; s)
</span><span class="cx"> {
</span><span class="cx">     if (s.isNull())
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMBindingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (212180 => 212181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h        2017-02-11 05:33:44 UTC (rev 212180)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h        2017-02-11 05:49:23 UTC (rev 212181)
</span><span class="lines">@@ -51,10 +51,6 @@
</span><span class="cx"> 
</span><span class="cx"> JSC::JSValue jsStringOrUndefined(JSC::ExecState*, const String&amp;); // undefined if the string is null
</span><span class="cx"> 
</span><del>-// See JavaScriptCore for explanation: Should be used for any string that is already owned by another
-// object, to let the engine know that collecting the JSString wrapper is unlikely to save memory.
-JSC::JSValue jsOwnedStringOrNull(JSC::ExecState*, const String&amp;);
-
</del><span class="cx"> WEBCORE_EXPORT bool hasIteratorMethod(JSC::ExecState&amp;, JSC::JSValue);
</span><span class="cx"> 
</span><span class="cx"> template&lt;JSC::NativeFunction nativeFunction, int length&gt; JSC::EncodedJSValue nonCachingStaticFunctionGetter(JSC::ExecState* exec, JSC::EncodedJSValue, JSC::PropertyName propertyName)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSXMLHttpRequestCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp (212180 => 212181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp        2017-02-11 05:33:44 UTC (rev 212180)
+++ trunk/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp        2017-02-11 05:49:23 UTC (rev 212181)
</span><span class="lines">@@ -46,7 +46,6 @@
</span><span class="cx"> #include &quot;JSEvent.h&quot;
</span><span class="cx"> #include &quot;JSEventListener.h&quot;
</span><span class="cx"> #include &quot;XMLHttpRequest.h&quot;
</span><del>-#include &lt;interpreter/StackVisitor.h&gt;
</del><span class="cx"> #include &lt;runtime/ArrayBuffer.h&gt;
</span><span class="cx"> #include &lt;runtime/Error.h&gt;
</span><span class="cx"> #include &lt;runtime/JSArrayBuffer.h&gt;
</span><span class="lines">@@ -66,85 +65,6 @@
</span><span class="cx">         visitor.addOpaqueRoot(responseDocument);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-class SendFunctor {
-public:
-    SendFunctor()
-        : m_hasSkippedFirstFrame(false)
-        , m_line(0)
-        , m_column(0)
-    {
-    }
-
-    unsigned line() const { return m_line; }
-    unsigned column() const { return m_column; }
-    String url() const { return m_url; }
-
-    StackVisitor::Status operator()(StackVisitor&amp; visitor) const
-    {
-        if (!m_hasSkippedFirstFrame) {
-            m_hasSkippedFirstFrame = true;
-            return StackVisitor::Continue;
-        }
-
-        unsigned line = 0;
-        unsigned column = 0;
-        visitor-&gt;computeLineAndColumn(line, column);
-        m_line = line;
-        m_column = column;
-        m_url = visitor-&gt;sourceURL();
-        return StackVisitor::Done;
-    }
-
-private:
-    mutable bool m_hasSkippedFirstFrame;
-    mutable unsigned m_line;
-    mutable unsigned m_column;
-    mutable String m_url;
-};
-
-JSValue JSXMLHttpRequest::send(ExecState&amp; state)
-{
-    InspectorInstrumentation::willSendXMLHttpRequest(wrapped().scriptExecutionContext(), wrapped().url());
-
-    VM&amp; vm = state.vm();
-    JSValue value = state.argument(0);
-    ExceptionOr&lt;void&gt; result;
-    if (value.isUndefinedOrNull())
-        result = wrapped().send();
-    else if (value.inherits(vm, JSDocument::info()))
-        result = wrapped().send(*JSDocument::toWrapped(vm, value));
-    else if (value.inherits(vm, JSBlob::info()))
-        result = wrapped().send(*JSBlob::toWrapped(vm, value));
-    else if (value.inherits(vm, JSDOMFormData::info()))
-        result = wrapped().send(*JSDOMFormData::toWrapped(vm, value));
-    else if (RefPtr&lt;ArrayBuffer&gt; arrayBuffer = toUnsharedArrayBuffer(vm, value))
-        result = wrapped().send(*arrayBuffer);
-    else if (RefPtr&lt;ArrayBufferView&gt; arrayBufferView = toUnsharedArrayBufferView(vm, value))
-        result = wrapped().send(*arrayBufferView);
-    else {
-        // FIXME: If toString raises an exception, should we exit before calling willSendXMLHttpRequest?
-        // FIXME: If toString raises an exception, should we exit before calling send?
-        result = wrapped().send(value.toWTFString(&amp;state));
-    }
-
-    // FIXME: This should probably use ShadowChicken so that we get the right frame even when it did a tail call.
-    // https://bugs.webkit.org/show_bug.cgi?id=155688
-    SendFunctor functor;
-    state.iterate(functor);
-    wrapped().setLastSendLineAndColumnNumber(functor.line(), functor.column());
-    wrapped().setLastSendURL(functor.url());
-
-    // FIXME: Is it correct to do this only after the paragraph code of code just above, or should we exit earlier?
-    if (UNLIKELY(result.hasException())) {
-        auto&amp; vm = state.vm();
-        auto scope = DECLARE_THROW_SCOPE(vm);
-        propagateException(state, scope, result.releaseException());
-        return { };
-    }
-
-    return jsUndefined();
-}
-
</del><span class="cx"> JSValue JSXMLHttpRequest::responseText(ExecState&amp; state) const
</span><span class="cx"> {
</span><span class="cx">     auto result = wrapped().responseText();
</span><span class="lines">@@ -156,7 +76,13 @@
</span><span class="cx">         return { };
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return jsOwnedStringOrNull(&amp;state, result.releaseReturnValue());
</del><ins>+    auto resultValue = result.releaseReturnValue();
+    if (resultValue.isNull())
+        return jsNull();
+
+    // See JavaScriptCore for explanation: Should be used for any string that is already owned by another
+    // object, to let the engine know that collecting the JSString wrapper is unlikely to save memory.
+    return jsOwnedString(&amp;state, resultValue);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> JSValue JSXMLHttpRequest::retrieveResponse(ExecState&amp; state)
</span></span></pre></div>
<a id="trunkSourceWebCorexmlXMLHttpRequestcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (212180 => 212181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp        2017-02-11 05:33:44 UTC (rev 212180)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp        2017-02-11 05:49:23 UTC (rev 212181)
</span><span class="lines">@@ -54,6 +54,7 @@
</span><span class="cx"> #include &quot;XMLHttpRequestProgressEvent.h&quot;
</span><span class="cx"> #include &quot;XMLHttpRequestUpload.h&quot;
</span><span class="cx"> #include &quot;markup.h&quot;
</span><ins>+#include &lt;interpreter/StackVisitor.h&gt;
</ins><span class="cx"> #include &lt;mutex&gt;
</span><span class="cx"> #include &lt;runtime/ArrayBuffer.h&gt;
</span><span class="cx"> #include &lt;runtime/ArrayBufferView.h&gt;
</span><span class="lines">@@ -498,6 +499,72 @@
</span><span class="cx">     return std::nullopt;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+namespace {
+
+// FIXME: This should be abstracted out, so that any IDL function can be passed the line/column/url tuple.
+
+// FIXME: This should probably use ShadowChicken so that we get the right frame even when it did a tail call.
+// https://bugs.webkit.org/show_bug.cgi?id=155688
+
+class SendFunctor {
+public:
+    SendFunctor() = default;
+
+    unsigned line() const { return m_line; }
+    unsigned column() const { return m_column; }
+    String url() const { return m_url; }
+
+    JSC::StackVisitor::Status operator()(JSC::StackVisitor&amp; visitor) const
+    {
+        if (!m_hasSkippedFirstFrame) {
+            m_hasSkippedFirstFrame = true;
+            return JSC::StackVisitor::Continue;
+        }
+
+        unsigned line = 0;
+        unsigned column = 0;
+        visitor-&gt;computeLineAndColumn(line, column);
+        m_line = line;
+        m_column = column;
+        m_url = visitor-&gt;sourceURL();
+        return JSC::StackVisitor::Done;
+    }
+
+private:
+    mutable bool m_hasSkippedFirstFrame { false };
+    mutable unsigned m_line { 0 };
+    mutable unsigned m_column { 0 };
+    mutable String m_url;
+};
+
+}
+
+ExceptionOr&lt;void&gt; XMLHttpRequest::send(JSC::ExecState&amp; state, std::optional&lt;SendTypes&gt;&amp;&amp; sendType)
+{
+    InspectorInstrumentation::willSendXMLHttpRequest(scriptExecutionContext(), url());
+
+    ExceptionOr&lt;void&gt; result;
+    if (!sendType)
+        result = send();
+    else {
+        result = WTF::switchOn(sendType.value(),
+            [this] (const RefPtr&lt;Document&gt;&amp; document) -&gt; ExceptionOr&lt;void&gt; { return send(*document); },
+            [this] (const RefPtr&lt;Blob&gt;&amp; blob) -&gt; ExceptionOr&lt;void&gt; { return send(*blob); },
+            [this] (const RefPtr&lt;JSC::ArrayBufferView&gt;&amp; arrayBufferView) -&gt; ExceptionOr&lt;void&gt; { return send(*arrayBufferView); },
+            [this] (const RefPtr&lt;JSC::ArrayBuffer&gt;&amp; arrayBuffer) -&gt; ExceptionOr&lt;void&gt; { return send(*arrayBuffer); },
+            [this] (const RefPtr&lt;DOMFormData&gt;&amp; formData) -&gt; ExceptionOr&lt;void&gt; { return send(*formData); },
+            [this] (const String&amp; string) -&gt; ExceptionOr&lt;void&gt; { return send(string); }
+        );
+    }
+
+    SendFunctor functor;
+    state.iterate(functor);
+    setLastSendLineAndColumnNumber(functor.line(), functor.column());
+    setLastSendURL(functor.url());
+
+    return result;
+}
+
</ins><span class="cx"> ExceptionOr&lt;void&gt; XMLHttpRequest::send(Document&amp; document)
</span><span class="cx"> {
</span><span class="cx">     if (auto result = prepareToSend())
</span></span></pre></div>
<a id="trunkSourceWebCorexmlXMLHttpRequesth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/XMLHttpRequest.h (212180 => 212181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/XMLHttpRequest.h        2017-02-11 05:33:44 UTC (rev 212180)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.h        2017-02-11 05:49:23 UTC (rev 212181)
</span><span class="lines">@@ -26,13 +26,16 @@
</span><span class="cx"> #include &quot;FormData.h&quot;
</span><span class="cx"> #include &quot;ResourceResponse.h&quot;
</span><span class="cx"> #include &quot;ThreadableLoaderClient.h&quot;
</span><ins>+#include &quot;URL.h&quot;
</ins><span class="cx"> #include &quot;XMLHttpRequestEventTarget.h&quot;
</span><span class="cx"> #include &quot;XMLHttpRequestProgressEventThrottle.h&quot;
</span><ins>+#include &lt;wtf/Variant.h&gt;
</ins><span class="cx"> #include &lt;wtf/text/StringBuilder.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> class ArrayBuffer;
</span><span class="cx"> class ArrayBufferView;
</span><ins>+class ExecState;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -65,6 +68,8 @@
</span><span class="cx">     EventTargetInterface eventTargetInterface() const override { return XMLHttpRequestEventTargetInterfaceType; }
</span><span class="cx">     ScriptExecutionContext* scriptExecutionContext() const override { return ActiveDOMObject::scriptExecutionContext(); }
</span><span class="cx"> 
</span><ins>+    using SendTypes = Variant&lt;RefPtr&lt;Document&gt;, RefPtr&lt;Blob&gt;, RefPtr&lt;JSC::ArrayBufferView&gt;, RefPtr&lt;JSC::ArrayBuffer&gt;, RefPtr&lt;DOMFormData&gt;, String&gt;;
+
</ins><span class="cx">     const URL&amp; url() const { return m_url; }
</span><span class="cx">     String statusText() const;
</span><span class="cx">     int status() const;
</span><span class="lines">@@ -74,12 +79,7 @@
</span><span class="cx">     ExceptionOr&lt;void&gt; open(const String&amp; method, const String&amp; url);
</span><span class="cx">     ExceptionOr&lt;void&gt; open(const String&amp; method, const URL&amp;, bool async);
</span><span class="cx">     ExceptionOr&lt;void&gt; open(const String&amp; method, const String&amp;, bool async, const String&amp; user, const String&amp; password);
</span><del>-    ExceptionOr&lt;void&gt; send(Document&amp;);
-    ExceptionOr&lt;void&gt; send(const String&amp; = { });
-    ExceptionOr&lt;void&gt; send(Blob&amp;);
-    ExceptionOr&lt;void&gt; send(DOMFormData&amp;);
-    ExceptionOr&lt;void&gt; send(JSC::ArrayBuffer&amp;);
-    ExceptionOr&lt;void&gt; send(JSC::ArrayBufferView&amp;);
</del><ins>+    ExceptionOr&lt;void&gt; send(JSC::ExecState&amp;, std::optional&lt;SendTypes&gt;&amp;&amp;);
</ins><span class="cx">     void abort();
</span><span class="cx">     ExceptionOr&lt;void&gt; setRequestHeader(const String&amp; name, const String&amp; value);
</span><span class="cx">     ExceptionOr&lt;void&gt; overrideMimeType(const String&amp; override);
</span><span class="lines">@@ -154,6 +154,12 @@
</span><span class="cx">     bool responseIsXML() const;
</span><span class="cx"> 
</span><span class="cx">     std::optional&lt;ExceptionOr&lt;void&gt;&gt; prepareToSend();
</span><ins>+    ExceptionOr&lt;void&gt; send(Document&amp;);
+    ExceptionOr&lt;void&gt; send(const String&amp; = { });
+    ExceptionOr&lt;void&gt; send(Blob&amp;);
+    ExceptionOr&lt;void&gt; send(DOMFormData&amp;);
+    ExceptionOr&lt;void&gt; send(JSC::ArrayBuffer&amp;);
+    ExceptionOr&lt;void&gt; send(JSC::ArrayBufferView&amp;);
</ins><span class="cx">     ExceptionOr&lt;void&gt; sendBytesData(const void*, size_t);
</span><span class="cx"> 
</span><span class="cx">     void changeState(State);
</span></span></pre></div>
<a id="trunkSourceWebCorexmlXMLHttpRequestidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/XMLHttpRequest.idl (212180 => 212181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/XMLHttpRequest.idl        2017-02-11 05:33:44 UTC (rev 212180)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.idl        2017-02-11 05:49:23 UTC (rev 212181)
</span><span class="lines">@@ -26,6 +26,10 @@
</span><span class="cx">  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">  */
</span><span class="cx"> 
</span><ins>+typedef (ArrayBufferView or ArrayBuffer) BufferSource;
+// FIXME: Add URLSearchParams and ReadableStream to the union when supported.
+typedef (Blob or BufferSource or DOMFormData or USVString) BodyInit;
+
</ins><span class="cx"> enum XMLHttpRequestResponseType {
</span><span class="cx">     &quot;&quot;,
</span><span class="cx">     &quot;arraybuffer&quot;,
</span><span class="lines">@@ -47,6 +51,7 @@
</span><span class="cx">     PrivateIdentifier,
</span><span class="cx">     PublicIdentifier,
</span><span class="cx"> ] interface XMLHttpRequest : XMLHttpRequestEventTarget {
</span><ins>+    // event handler
</ins><span class="cx">     attribute EventHandler onreadystatechange;
</span><span class="cx"> 
</span><span class="cx">     // state
</span><span class="lines">@@ -55,38 +60,33 @@
</span><span class="cx">     const unsigned short HEADERS_RECEIVED = 2;
</span><span class="cx">     const unsigned short LOADING = 3;
</span><span class="cx">     const unsigned short DONE = 4;
</span><ins>+    readonly attribute unsigned short readyState;
</ins><span class="cx"> 
</span><ins>+    // request
+    [MayThrowException] void open(ByteString method, DOMString url); // FIXME: url should be a USVString.
+    [MayThrowException] void open(ByteString method, DOMString url, boolean async, optional DOMString? user = null, optional DOMString? password = null); // FIXME: url/user/password should all be a USVStrings.
+    [MayThrowException] void setRequestHeader(ByteString header, ByteString value);
</ins><span class="cx">     [SetterMayThrowException] attribute unsigned long timeout;
</span><del>-    readonly attribute unsigned short readyState;
-
</del><span class="cx">     [SetterMayThrowException] attribute boolean withCredentials;
</span><del>-
-    // Use overloading rather than &quot;boolean async = true&quot; because legacy content prevents treating the 'async' argument being undefined identical from it being omitted.
-    [MayThrowException] void open(DOMString method, DOMString url);
-    [MayThrowException] void open(DOMString method, DOMString url, boolean async, optional DOMString? user = null, optional DOMString? password = null);
-
-    [MayThrowException] void setRequestHeader(DOMString header, DOMString value);
-
-    [Custom, MayThrowException] void send();
-
</del><ins>+    readonly attribute XMLHttpRequestUpload upload;
+    [CallWith=ScriptState, MayThrowException] void send(optional (Document or BodyInit)? body = null);
</ins><span class="cx">     void abort();
</span><span class="cx"> 
</span><del>-    readonly attribute XMLHttpRequestUpload upload;
-
-    DOMString getAllResponseHeaders();
-    DOMString? getResponseHeader(DOMString header);
-    [GetterMayThrowException, CustomGetter] readonly attribute DOMString? responseText;
-    [GetterMayThrowException] readonly attribute Document responseXML;
-
</del><ins>+    // response
+    readonly attribute USVString responseURL;
+    readonly attribute unsigned short status;
+    readonly attribute ByteString statusText;
+    ByteString? getResponseHeader(ByteString name);
+    ByteString getAllResponseHeaders();
+    [MayThrowException] void overrideMimeType(DOMString mime);
</ins><span class="cx">     [SetterMayThrowException] attribute XMLHttpRequestResponseType responseType;
</span><del>-    [JSBuiltin] readonly attribute Object response;
</del><ins>+    [JSBuiltin] readonly attribute any response;
+    [GetterMayThrowException, CustomGetter] readonly attribute USVString? responseText;
+    // FIXME: responseXML should be annotated with [Exposed=Window].
+    [GetterMayThrowException] readonly attribute Document? responseXML;
</ins><span class="cx"> 
</span><del>-    readonly attribute unsigned short status;
-    readonly attribute DOMString statusText;
-    readonly attribute DOMString responseURL;
-
</del><ins>+    // internals
</ins><span class="cx">     [PrivateIdentifier] boolean responseCacheIsValid();
</span><span class="cx">     [PrivateIdentifier, Custom] any retrieveResponse();
</span><span class="cx"> 
</span><del>-    [MayThrowException] void overrideMimeType(DOMString override);
</del><span class="cx"> };
</span></span></pre>
</div>
</div>

</body>
</html>