Changeset 132252 in webkit
- Timestamp:
- Oct 23, 2012 11:49:20 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 25 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r132251 r132252 1 2012-10-23 Dominik Röttsches <dominik.rottsches@intel.com> 2 3 Add timeout support to XMLHttpRequest 4 https://bugs.webkit.org/show_bug.cgi?id=74802 5 6 Reviewed by Nate Chapin. 7 8 XHR2 timeout tests were initially written by Mozilla's Alex Vincent's. He granted 9 permission to reuse them under PD/BSD license 10 in https://bugzilla.mozilla.org/show_bug.cgi?id=525816#c86 - big thanks! 11 I adapted them for W3C testharness.js and split them into groups with shorter test running time 12 so that they can be used as WebKit layout tests. Each individual test should 13 complete in less than 20 seconds. 14 15 The case of late updates to the timeout property, changing the timeout value after send() 16 is not supported yet and handled separately in bug 98156. Tests that are testing this feature 17 are commented out until this bug is tackled. 18 19 The suffix of the html test filename matches the groups in xmlhttprequest-timeout.js which contains 20 all tests that are run. The result of assertions is reported back to testharness.js. 21 22 For example, the "overrides" group is currently not run yet since all tests in that group are cases 23 of late updates, see above. Once late updates are supported we can add a file 24 xmlhttprequest-timeout-overrides.html to run them. 25 26 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-aborted-expected.txt: Added. 27 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-aborted.html: Added. 28 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-abortedonmain-expected.txt: Added. 29 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-abortedonmain.html: Added. 30 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-overridesexpires-expected.txt: Added. 31 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-overridesexpires.html: Added. 32 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-runner.js: Added. Distinguishes which group of tests to run based on filename suffix. 33 (testResultCallbackHandler.return): 34 (groupFromLocation): 35 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-simple-expected.txt: Added. 36 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-simple.html: Added. 37 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-synconmain-expected.txt: Added. 38 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-synconmain.html: Added. 39 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-twice-expected.txt: Added. 40 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-twice.html: Added. 41 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-aborted-expected.txt: Added. 42 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-aborted.html: Added. 43 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-overridesexpires-expected.txt: Added. 44 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-overridesexpires.html: Added. 45 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-simple-expected.txt: Added. 46 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-simple.html: Added. 47 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-synconworker-expected.txt: Added. 48 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-synconworker.html: Added. 49 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-twice-expected.txt: Added. 50 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-twice.html: Added. 51 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout.js: Added. Contains test cases for all individual test html files. 52 (message): Wrapper for postMessage in worker and document context case. 53 (is), 54 (ok): Assertion functions. 55 (RequestTracker): Class for variations of the regular timeout case. 56 (RequestTracker.prototype.startXHR.handleEvent): 57 (RequestTracker.prototype.startXHR): 58 (RequestTracker.prototype.getMessage): 59 (RequestTracker.prototype.handleEvent): 60 (AbortedRequest): Class for testing timeout event vs. abort events. 61 (AbortedRequest.prototype.startXHR.handleEvent): 62 (AbortedRequest.prototype.startXHR.abortReq): 63 (AbortedRequest.prototype.startXHR.else): 64 (AbortedRequest.prototype.startXHR): 65 (AbortedRequest.prototype.noEventsFired): 66 (AbortedRequest.prototype.getMessage): 67 (AbortedRequest.prototype.handleEvent): 68 (SyncRequestSettingTimeoutAfterOpen.startXHR), 69 (SyncRequestSettingTimeoutBeforeOpen.startXHR): Test classes for synchronous XHR cases. 70 (TestCounter.testComplete), 71 (TestCounter.next): Used for cycling through tests. 72 * platform/chromium/TestExpectations: Skipping XHR timeout cases since setTimeoutInterval is not supported in Chromium's HTTP stack. 73 * platform/gtk/TestExpectations: Marking XHR timeout cases as slow in order to run them with a longer test timeout threshold. 74 * platform/qt/TestExpectations: Skipping XHR timeout cases since setTimeoutInterval is not supported in Chromium's HTTP stack. 75 1 76 2012-10-23 Levi Weintraub <leviw@chromium.org> 2 77 -
trunk/LayoutTests/platform/chromium/TestExpectations
r132251 r132252 985 985 webkit.org/b/98452 [ Linux Win ] fast/text/vertical-rl-rtl-linebreak.html [ Failure ] 986 986 987 # ResourceRequest needs to support setTimeoutInterval 988 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-aborted.html [ Failure ] 989 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-abortedonmain.html [ Failure ] 990 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-overridesexpires.html [ Failure ] 991 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-simple.html [ Failure ] 992 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-synconmain.html [ Failure ] 993 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-twice.html [ Failure ] 994 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-aborted.html [ Failure ] 995 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-overridesexpires.html [ Failure ] 996 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-simple.html [ Failure ] 997 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-synconworker.html [ Failure ] 998 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-twice.html [ Failure ] 999 987 1000 # ----------------------------------------------------------------- 988 1001 # Inspector tests -
trunk/LayoutTests/platform/gtk/TestExpectations
r132236 r132252 617 617 Bug(GTK) tables/mozilla/other/slashlogo.html [ Pass Slow ] 618 618 619 Bug(GTK) http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-aborted.html [ Pass Slow ] 620 Bug(GTK) http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-abortedonmain.html [ Pass Slow ] 621 Bug(GTK) http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-overridesexpires.html [ Pass Slow ] 622 Bug(GTK) http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-simple.html [ Pass Slow ] 623 Bug(GTK) http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-synconmain.html [ Pass Slow ] 624 Bug(GTK) http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-twice.html [ Pass Slow ] 625 Bug(GTK) http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-aborted.html [ Pass Slow ] 626 Bug(GTK) http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-overridesexpires.html [ Pass Slow ] 627 Bug(GTK) http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-simple.html [ Pass Slow ] 628 Bug(GTK) http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-synconworker.html [ Pass Slow ] 629 Bug(GTK) http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-twice.html [ Pass Slow ] 630 619 631 #//////////////////////////////////////////////////////////////////////////////////////// 620 632 # End of slow tests -
trunk/LayoutTests/platform/qt/TestExpectations
r132218 r132252 798 798 http/tests/xmlhttprequest/xmlhttprequest-check-get-readystate-for-404-without-body.html 799 799 800 # ResourceRequest needs to support setTimeoutInterval 801 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-aborted.html [ Failure ] 802 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-abortedonmain.html [ Failure ] 803 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-overridesexpires.html [ Failure ] 804 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-simple.html [ Failure ] 805 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-synconmain.html [ Failure ] 806 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-twice.html [ Failure ] 807 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-aborted.html [ Failure ] 808 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-overridesexpires.html [ Failure ] 809 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-simple.html [ Failure ] 810 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-synconworker.html [ Failure ] 811 webkit.org/b/98397 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-twice.html [ Failure ] 812 800 813 # =========================================================================== # 801 814 # Failing editing/inserting tests. # -
trunk/Source/WebCore/ChangeLog
r132246 r132252 1 2012-10-23 Dominik Röttsches <dominik.rottsches@intel.com> 2 3 Add timeout support to XMLHttpRequest 4 https://bugs.webkit.org/show_bug.cgi?id=74802 5 6 Reviewed by Nate Chapin. 7 8 An implementation of XHR2 timeouts by using ResourceRequest's setTimeoutInterval. 9 This made several changes necessary in CachedResource and SubresourceLoader in order 10 to distinguish and forward the timeout case from there. 11 12 The case of late updates to the timeout property, changing the timeout value after send() 13 is not supported yet and handled separately in bug 98156. 14 15 XHR2 timeout tests were initially written by Mozilla's Alex Vincent's. He granted 16 permission to reuse them under PD/BSD license 17 in https://bugzilla.mozilla.org/show_bug.cgi?id=525816#c86 - big thanks! 18 I adapted them for W3C testharness.js and split them into groups with shorter test running time 19 so that they can be used as WebKit layout tests. 20 21 Tests: http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-aborted.html 22 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-abortedonmain.html 23 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-overridesexpires.html 24 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-simple.html 25 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-synconmain.html 26 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-twice.html 27 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-aborted.html 28 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-overridesexpires.html 29 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-simple.html 30 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-synconworker.html 31 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-twice.html 32 33 * loader/DocumentThreadableLoader.cpp: 34 (WebCore::DocumentThreadableLoader::notifyFinished): Forward information about timeout case. 35 * loader/SubresourceLoader.cpp: 36 (WebCore::SubresourceLoader::didFail): Distinguish timeout case when informing client. 37 * loader/cache/CachedResource.h: Distinguishing timeout case for errors. 38 (WebCore::CachedResource::errorOccurred): 39 (WebCore::CachedResource::loadFailedOrCanceled): 40 (WebCore::CachedResource::timedOut): 41 * xml/XMLHttpRequest.cpp: 42 (WebCore::XMLHttpRequest::XMLHttpRequest): Initializing m_timeout value to zero. 43 (WebCore::XMLHttpRequest::setTimeout): Setter function, possibly raising JS exception. 44 (WebCore): 45 (WebCore::XMLHttpRequest::open): Open call may raise exception for synchronous requests when timeout value is set. 46 (WebCore::XMLHttpRequest::createRequest): Assigning timeout value to ResourceRequest. 47 (WebCore::XMLHttpRequest::didFail): Handling timeout case separately. 48 (WebCore::XMLHttpRequest::didTimeout): Timeout case state transisition and event firing as spec'ed. 49 * xml/XMLHttpRequest.h: New event listener, member and callback for handling timeout. 50 (WebCore::XMLHttpRequest::timeout): 51 (XMLHttpRequest): 52 * xml/XMLHttpRequest.idl: New event listener and property added. 53 * xml/XMLHttpRequestException.cpp: 54 * xml/XMLHttpRequestException.h: Added an exception value for the timeout case. 55 56 1 57 2012-10-23 Christophe Dumez <christophe.dumez@intel.com> 2 58 -
trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp
r132157 r132252 310 310 if (m_resource->wasCanceled()) 311 311 error.setIsCancellation(true); 312 if (m_resource->timedOut()) 313 error.setIsTimeout(true); 312 314 didFail(error); 313 315 } else -
trunk/Source/WebCore/loader/SubresourceLoader.cpp
r131919 r132252 284 284 CachedResourceHandle<CachedResource> protectResource(m_resource); 285 285 m_state = Finishing; 286 m_resource->error(CachedResource::LoadError); 286 if (error.isTimeout()) 287 m_resource->error(CachedResource::TimeoutError); 288 else 289 m_resource->error(CachedResource::LoadError); 287 290 if (!m_resource->isPreloaded()) 288 291 memoryCache()->remove(m_resource); -
trunk/Source/WebCore/loader/cache/CachedResource.h
r131660 r132252 91 91 Canceled, 92 92 LoadError, 93 TimeoutError, 93 94 DecodeError 94 95 }; … … 208 209 209 210 bool wasCanceled() const { return m_status == Canceled; } 210 bool errorOccurred() const { return (m_status == LoadError || m_status == DecodeError); } 211 bool loadFailedOrCanceled() { return m_status == Canceled || m_status == LoadError; } 211 bool errorOccurred() const { return (m_status == LoadError || m_status == DecodeError || m_status == TimeoutError); } 212 bool loadFailedOrCanceled() { return m_status == Canceled || m_status == LoadError || m_status == TimeoutError; } 213 bool timedOut() const { return m_status == TimeoutError; } 212 214 213 215 bool shouldSendResourceLoadCallbacks() const { return m_options.sendLoadCallbacks == SendCallbacks; } -
trunk/Source/WebCore/xml/XMLHttpRequest.cpp
r130612 r132252 4 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> 5 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. 6 * Copyright (C) 2012 Intel Corporation 6 7 * 7 8 * This library is free software; you can redistribute it and/or … … 176 177 , m_async(true) 177 178 , m_includeCredentials(false) 179 , m_timeoutMilliseconds(0) 178 180 , m_state(UNSENT) 179 181 , m_createdDocument(false) … … 327 329 } 328 330 331 void XMLHttpRequest::setTimeout(unsigned long timeout, ExceptionCode& ec) 332 { 333 // FIXME: Need to trigger or update the timeout Timer here, if needed. http://webkit.org/b/98156 334 // XHR2 spec, 4.7.3. "This implies that the timeout attribute can be set while fetching is in progress. If that occurs it will still be measured relative to the start of fetching." 335 if (scriptExecutionContext()->isDocument() && !m_async) { 336 logConsoleError(scriptExecutionContext(), "XMLHttpRequest.timeout cannot be set for synchronous HTTP(S) requests made from the window context."); 337 ec = INVALID_ACCESS_ERR; 338 return; 339 } 340 m_timeoutMilliseconds = timeout; 341 } 342 343 329 344 void XMLHttpRequest::setResponseType(const String& responseType, ExceptionCode& ec) 330 345 { … … 493 508 if (url.protocolIsInHTTPFamily() && m_responseTypeCode != ResponseTypeDefault) { 494 509 logConsoleError(scriptExecutionContext(), "Synchronous HTTP(S) requests made from the window context cannot have XMLHttpRequest.responseType set."); 510 ec = INVALID_ACCESS_ERR; 511 return; 512 } 513 514 // Similarly, timeouts are disabled for synchronous requests as well. 515 if (m_timeoutMilliseconds > 0) { 516 logConsoleError(scriptExecutionContext(), "Synchronous XMLHttpRequests must not have a timeout value set."); 495 517 ec = INVALID_ACCESS_ERR; 496 518 return; … … 742 764 options.crossOriginRequestPolicy = UseAccessControl; 743 765 options.securityOrigin = securityOrigin(); 766 767 if (m_timeoutMilliseconds) 768 request.setTimeoutInterval(m_timeoutMilliseconds / 1000.0); 744 769 745 770 m_exceptionCode = 0; … … 1059 1084 } 1060 1085 1086 if (error.isTimeout()) { 1087 didTimeout(); 1088 return; 1089 } 1090 1061 1091 // Network failures are already reported to Web Inspector by ResourceLoader. 1062 1092 if (error.domain() == errorDomainWebKitInternal) … … 1183 1213 } 1184 1214 1215 void XMLHttpRequest::didTimeout() 1216 { 1217 // internalAbort() calls dropProtection(), which may release the last reference. 1218 RefPtr<XMLHttpRequest> protect(this); 1219 internalAbort(); 1220 1221 clearResponse(); 1222 clearRequest(); 1223 1224 m_error = true; 1225 m_exceptionCode = XMLHttpRequestException::TIMEOUT_ERR; 1226 1227 if (!m_async) { 1228 m_state = DONE; 1229 m_exceptionCode = TIMEOUT_ERR; 1230 return; 1231 } 1232 1233 changeState(DONE); 1234 1235 if (!m_uploadComplete) { 1236 m_uploadComplete = true; 1237 if (m_upload && m_uploadEventsAllowed) 1238 m_upload->dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().timeoutEvent)); 1239 } 1240 m_progressEventThrottle.dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().timeoutEvent)); 1241 } 1242 1185 1243 bool XMLHttpRequest::canSuspend() const 1186 1244 { -
trunk/Source/WebCore/xml/XMLHttpRequest.h
r128580 r132252 3 3 * Copyright (C) 2005, 2006 Alexey Proskuryakov <ap@nypop.com> 4 4 * Copyright (C) 2011 Google Inc. All rights reserved. 5 * Copyright (C) 2012 Intel Corporation 5 6 * 6 7 * This library is free software; you can redistribute it and/or … … 70 71 71 72 virtual void contextDestroyed(); 73 virtual void didTimeout(); 72 74 virtual bool canSuspend() const; 73 75 virtual void suspend(ReasonForSuspension); … … 105 107 Blob* responseBlob(ExceptionCode&); 106 108 Blob* optionalResponseBlob() const { return m_responseBlob.get(); } 109 unsigned long timeout() const { return m_timeoutMilliseconds; } 110 void setTimeout(unsigned long timeout, ExceptionCode&); 107 111 108 112 void sendFromInspector(PassRefPtr<FormData>, ExceptionCode&); … … 134 138 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadstart); 135 139 DEFINE_ATTRIBUTE_EVENT_LISTENER(progress); 140 DEFINE_ATTRIBUTE_EVENT_LISTENER(timeout); 136 141 137 142 using RefCounted<XMLHttpRequest>::ref; … … 192 197 bool m_async; 193 198 bool m_includeCredentials; 199 unsigned long m_timeoutMilliseconds; 194 200 RefPtr<Blob> m_responseBlob; 195 201 -
trunk/Source/WebCore/xml/XMLHttpRequest.idl
r131172 r132252 44 44 attribute EventListener onloadstart; 45 45 attribute EventListener onprogress; 46 attribute EventListener ontimeout; 46 47 47 48 // event handler attributes … … 55 56 const unsigned short DONE = 4; 56 57 58 attribute unsigned long timeout 59 setter raises(DOMException); 57 60 readonly attribute unsigned short readyState; 58 61 … … 118 121 raises(EventException); 119 122 }; 120 -
trunk/Source/WebCore/xml/XMLHttpRequestException.cpp
r113679 r132252 37 37 } exceptions[] = { 38 38 { "NETWORK_ERR", "A network error occurred in synchronous requests." }, 39 { "ABORT_ERR", "The user aborted a request in synchronous requests." } 39 { "ABORT_ERR", "The user aborted a request in synchronous requests." }, 40 { "TIMEOUT_ERR", "A timeout error occured in synchronous requests." } 40 41 }; 41 42 -
trunk/Source/WebCore/xml/XMLHttpRequestException.h
r127852 r132252 46 46 enum XMLHttpRequestExceptionCode { 47 47 NETWORK_ERR = XMLHttpRequestExceptionOffset + 101, 48 ABORT_ERR 48 ABORT_ERR, 49 TIMEOUT_ERR 49 50 }; 50 51
Note: See TracChangeset
for help on using the changeset viewer.