<!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 <sam@webkit.org> 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 <sam@webkit.org>
+
+ [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 <cdumez@apple.com>
</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("GET", "...")
</span><span class="cx"> if (expectError)
</span><del>- assert_throws("SyntaxError", function() { client.setRequestHeader("x-test", value) }, ' given value ' + value+', ')
</del><ins>+ assert_throws(expectError, function() { client.setRequestHeader("x-test", value) }, ' given value ' + value+', ')
</ins><span class="cx"> else
</span><span class="cx"> client.setRequestHeader("x-test", value)
</span><span class="cx"> })
</span><span class="cx"> }
</span><span class="cx">
</span><del>- try_value("t\rt", true)
- try_value("t\nt", true)
- try_value("テスト", true)
- try_value("t\bt", true)
- try_value("t\vt", true)
- try_value("t\tt", false)
- try_value("t t", false)
- try_value("\xd0\xa1", false)
- try_value("\x7f", true)
</del><ins>+ try_value("t\rt", {name:'SyntaxError'})
+ try_value("t\nt", {name:'SyntaxError'})
+ try_value("テスト", {name:'TypeError'})
+ try_value("t\bt", {name:'SyntaxError'})
+ try_value("t\vt", {name:'SyntaxError'})
+ try_value("t\tt")
+ try_value("t t")
+ try_value("\xd0\xa1")
+ try_value("\x7f", {name:'SyntaxError'})
</ins><span class="cx"> test(function() {
</span><span class="cx"> var client = new XMLHttpRequest()
</span><span class="cx"> client.open("GET", "...")
</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 <sam@webkit.org>
+
+ [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 <cdumez@apple.com>
</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 "\x1d".
</span><span class="cx"> PASS setRequestHeader should throw with header name "\x1e".
</span><span class="cx"> PASS setRequestHeader should throw with header name "\x1f".
</span><del>-FAIL setRequestHeader should throw with header name "テスト". assert_throws: function "function () { client.setRequestHeader(name, 'x-value') }" threw object "SyntaxError (DOM Exception 12): The string did not match the expected pattern." ("SyntaxError") expected object "TypeError" ("TypeError")
-FAIL setRequestHeader should throw with header name "X-テスト". assert_throws: function "function () { client.setRequestHeader(name, 'x-value') }" threw object "SyntaxError (DOM Exception 12): The string did not match the expected pattern." ("SyntaxError") expected object "TypeError" ("TypeError")
</del><ins>+PASS setRequestHeader should throw with header name "テスト".
+PASS setRequestHeader should throw with header name "X-テスト".
</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 "function () { client.setRequestHeader("x-test", "テスト") }" threw object "SyntaxError (DOM Exception 12): The string did not match the expected pattern." ("SyntaxError") expected object "TypeError" ("TypeError")
</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 <sam@webkit.org>
+
+ [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 <cdumez@apple.com>
</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& s)
-{
- if (s.isNull())
- return jsNull();
- return jsOwnedString(exec, s);
-}
-
</del><span class="cx"> JSValue jsStringOrUndefined(ExecState* exec, const String& 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&); // 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&);
-
</del><span class="cx"> WEBCORE_EXPORT bool hasIteratorMethod(JSC::ExecState&, JSC::JSValue);
</span><span class="cx">
</span><span class="cx"> template<JSC::NativeFunction nativeFunction, int length> 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 "JSEvent.h"
</span><span class="cx"> #include "JSEventListener.h"
</span><span class="cx"> #include "XMLHttpRequest.h"
</span><del>-#include <interpreter/StackVisitor.h>
</del><span class="cx"> #include <runtime/ArrayBuffer.h>
</span><span class="cx"> #include <runtime/Error.h>
</span><span class="cx"> #include <runtime/JSArrayBuffer.h>
</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& visitor) const
- {
- if (!m_hasSkippedFirstFrame) {
- m_hasSkippedFirstFrame = true;
- return StackVisitor::Continue;
- }
-
- unsigned line = 0;
- unsigned column = 0;
- visitor->computeLineAndColumn(line, column);
- m_line = line;
- m_column = column;
- m_url = visitor->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& state)
-{
- InspectorInstrumentation::willSendXMLHttpRequest(wrapped().scriptExecutionContext(), wrapped().url());
-
- VM& vm = state.vm();
- JSValue value = state.argument(0);
- ExceptionOr<void> 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<ArrayBuffer> arrayBuffer = toUnsharedArrayBuffer(vm, value))
- result = wrapped().send(*arrayBuffer);
- else if (RefPtr<ArrayBufferView> 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(&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& 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& 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(&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(&state, resultValue);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> JSValue JSXMLHttpRequest::retrieveResponse(ExecState& 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 "XMLHttpRequestProgressEvent.h"
</span><span class="cx"> #include "XMLHttpRequestUpload.h"
</span><span class="cx"> #include "markup.h"
</span><ins>+#include <interpreter/StackVisitor.h>
</ins><span class="cx"> #include <mutex>
</span><span class="cx"> #include <runtime/ArrayBuffer.h>
</span><span class="cx"> #include <runtime/ArrayBufferView.h>
</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& visitor) const
+ {
+ if (!m_hasSkippedFirstFrame) {
+ m_hasSkippedFirstFrame = true;
+ return JSC::StackVisitor::Continue;
+ }
+
+ unsigned line = 0;
+ unsigned column = 0;
+ visitor->computeLineAndColumn(line, column);
+ m_line = line;
+ m_column = column;
+ m_url = visitor->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<void> XMLHttpRequest::send(JSC::ExecState& state, std::optional<SendTypes>&& sendType)
+{
+ InspectorInstrumentation::willSendXMLHttpRequest(scriptExecutionContext(), url());
+
+ ExceptionOr<void> result;
+ if (!sendType)
+ result = send();
+ else {
+ result = WTF::switchOn(sendType.value(),
+ [this] (const RefPtr<Document>& document) -> ExceptionOr<void> { return send(*document); },
+ [this] (const RefPtr<Blob>& blob) -> ExceptionOr<void> { return send(*blob); },
+ [this] (const RefPtr<JSC::ArrayBufferView>& arrayBufferView) -> ExceptionOr<void> { return send(*arrayBufferView); },
+ [this] (const RefPtr<JSC::ArrayBuffer>& arrayBuffer) -> ExceptionOr<void> { return send(*arrayBuffer); },
+ [this] (const RefPtr<DOMFormData>& formData) -> ExceptionOr<void> { return send(*formData); },
+ [this] (const String& string) -> ExceptionOr<void> { return send(string); }
+ );
+ }
+
+ SendFunctor functor;
+ state.iterate(functor);
+ setLastSendLineAndColumnNumber(functor.line(), functor.column());
+ setLastSendURL(functor.url());
+
+ return result;
+}
+
</ins><span class="cx"> ExceptionOr<void> XMLHttpRequest::send(Document& 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 "FormData.h"
</span><span class="cx"> #include "ResourceResponse.h"
</span><span class="cx"> #include "ThreadableLoaderClient.h"
</span><ins>+#include "URL.h"
</ins><span class="cx"> #include "XMLHttpRequestEventTarget.h"
</span><span class="cx"> #include "XMLHttpRequestProgressEventThrottle.h"
</span><ins>+#include <wtf/Variant.h>
</ins><span class="cx"> #include <wtf/text/StringBuilder.h>
</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<RefPtr<Document>, RefPtr<Blob>, RefPtr<JSC::ArrayBufferView>, RefPtr<JSC::ArrayBuffer>, RefPtr<DOMFormData>, String>;
+
</ins><span class="cx"> const URL& 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<void> open(const String& method, const String& url);
</span><span class="cx"> ExceptionOr<void> open(const String& method, const URL&, bool async);
</span><span class="cx"> ExceptionOr<void> open(const String& method, const String&, bool async, const String& user, const String& password);
</span><del>- ExceptionOr<void> send(Document&);
- ExceptionOr<void> send(const String& = { });
- ExceptionOr<void> send(Blob&);
- ExceptionOr<void> send(DOMFormData&);
- ExceptionOr<void> send(JSC::ArrayBuffer&);
- ExceptionOr<void> send(JSC::ArrayBufferView&);
</del><ins>+ ExceptionOr<void> send(JSC::ExecState&, std::optional<SendTypes>&&);
</ins><span class="cx"> void abort();
</span><span class="cx"> ExceptionOr<void> setRequestHeader(const String& name, const String& value);
</span><span class="cx"> ExceptionOr<void> overrideMimeType(const String& 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<ExceptionOr<void>> prepareToSend();
</span><ins>+ ExceptionOr<void> send(Document&);
+ ExceptionOr<void> send(const String& = { });
+ ExceptionOr<void> send(Blob&);
+ ExceptionOr<void> send(DOMFormData&);
+ ExceptionOr<void> send(JSC::ArrayBuffer&);
+ ExceptionOr<void> send(JSC::ArrayBufferView&);
</ins><span class="cx"> ExceptionOr<void> 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"> "",
</span><span class="cx"> "arraybuffer",
</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 "boolean async = true" 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>