OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> | 3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> |
4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> | 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> |
5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. | 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. |
6 * Copyright (C) 2012 Intel Corporation | 6 * Copyright (C) 2012 Intel Corporation |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Lesser General Public | 9 * modify it under the terms of the GNU Lesser General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 m_sendFlag = true; | 934 m_sendFlag = true; |
935 // The presence of upload event listeners forces us to use preflighting | 935 // The presence of upload event listeners forces us to use preflighting |
936 // because POSTing to an URL that does not permit cross origin requests should | 936 // because POSTing to an URL that does not permit cross origin requests should |
937 // look exactly like POSTing to an URL that does not respond at all. | 937 // look exactly like POSTing to an URL that does not respond at all. |
938 // Also, only async requests support upload progress events. | 938 // Also, only async requests support upload progress events. |
939 bool uploadEvents = false; | 939 bool uploadEvents = false; |
940 if (m_async) { | 940 if (m_async) { |
941 InspectorInstrumentation::asyncTaskScheduled( | 941 InspectorInstrumentation::asyncTaskScheduled( |
942 &executionContext, "XMLHttpRequest.send", this, true); | 942 &executionContext, "XMLHttpRequest.send", this, true); |
943 dispatchProgressEvent(EventTypeNames::loadstart, 0, 0); | 943 dispatchProgressEvent(EventTypeNames::loadstart, 0, 0); |
| 944 // Event handler could have invalidated this send operation, |
| 945 // (re)setting the send flag and/or initiating another send |
| 946 // operation; leave quietly if so. |
| 947 if (!m_sendFlag || m_loader) |
| 948 return; |
944 if (httpBody && m_upload) { | 949 if (httpBody && m_upload) { |
945 uploadEvents = m_upload->hasEventListeners(); | 950 uploadEvents = m_upload->hasEventListeners(); |
946 m_upload->dispatchEvent( | 951 m_upload->dispatchEvent( |
947 ProgressEvent::create(EventTypeNames::loadstart, false, 0, 0)); | 952 ProgressEvent::create(EventTypeNames::loadstart, false, 0, 0)); |
| 953 // See above. |
| 954 if (!m_sendFlag || m_loader) |
| 955 return; |
948 } | 956 } |
949 } | 957 } |
950 | 958 |
951 m_sameOriginRequest = getSecurityOrigin()->canRequestNoSuborigin(m_url); | 959 m_sameOriginRequest = getSecurityOrigin()->canRequestNoSuborigin(m_url); |
952 | 960 |
953 // Per https://w3c.github.io/webappsec-suborigins/#security-model-opt-outs, | 961 // Per https://w3c.github.io/webappsec-suborigins/#security-model-opt-outs, |
954 // credentials are forced when credentials mode is "same-origin", the | 962 // credentials are forced when credentials mode is "same-origin", the |
955 // 'unsafe-credentials' option is set, and the request's physical origin is | 963 // 'unsafe-credentials' option is set, and the request's physical origin is |
956 // the same as the URL's. | 964 // the same as the URL's. |
957 bool includeCredentials = | 965 bool includeCredentials = |
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1839 visitor->traceWrappers(m_responseDocument); | 1847 visitor->traceWrappers(m_responseDocument); |
1840 visitor->traceWrappers(m_responseArrayBuffer); | 1848 visitor->traceWrappers(m_responseArrayBuffer); |
1841 XMLHttpRequestEventTarget::traceWrappers(visitor); | 1849 XMLHttpRequestEventTarget::traceWrappers(visitor); |
1842 } | 1850 } |
1843 | 1851 |
1844 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr) { | 1852 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr) { |
1845 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr); | 1853 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr); |
1846 } | 1854 } |
1847 | 1855 |
1848 } // namespace blink | 1856 } // namespace blink |
OLD | NEW |