Title: [208101] trunk
Revision
208101
Author
[email protected]
Date
2016-10-29 06:44:27 -0700 (Sat, 29 Oct 2016)

Log Message

REGRESSION (Safari 10 / r189445): WKWebView and WebView no longer allow async XMLHttpRequest timeout to exceed 60 seconds
https://bugs.webkit.org/show_bug.cgi?id=163814
<rdar://problem/28917420>

Patch by Youenn Fablet <[email protected]> on 2016-10-29
Reviewed by Darin Adler.

Source/WebCore:

Tests: http/tests/xmlhttprequest/resetting-timeout-to-zero.html
       http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout.html

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::setTimeout): If the XHR timeout is active, resetting the timeout to zero should lead to using the default network timeout.
Since it is difficult to update the timeout once the request is sent, we mimic the default network timeout with a 60 seconds XHR timeout.
(WebCore::XMLHttpRequest::createRequest): Setting network timeout to infinity if the XHR timeout is active.

LayoutTests:

* http/tests/xmlhttprequest/resetting-timeout-to-zero-expected.txt: Added.
* http/tests/xmlhttprequest/resetting-timeout-to-zero.html: Added.
* http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout-expected.txt: Added.
* http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout.html: Added.
* tests-options.json:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (208100 => 208101)


--- trunk/LayoutTests/ChangeLog	2016-10-29 13:43:06 UTC (rev 208100)
+++ trunk/LayoutTests/ChangeLog	2016-10-29 13:44:27 UTC (rev 208101)
@@ -1,3 +1,17 @@
+2016-10-29  Youenn Fablet  <[email protected]>
+
+        REGRESSION (Safari 10 / r189445): WKWebView and WebView no longer allow async XMLHttpRequest timeout to exceed 60 seconds
+        https://bugs.webkit.org/show_bug.cgi?id=163814
+        <rdar://problem/28917420>
+
+        Reviewed by Darin Adler.
+
+        * http/tests/xmlhttprequest/resetting-timeout-to-zero-expected.txt: Added.
+        * http/tests/xmlhttprequest/resetting-timeout-to-zero.html: Added.
+        * http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout-expected.txt: Added.
+        * http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout.html: Added.
+        * tests-options.json:
+
 2016-10-28  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Breakpoints not working in scripts with unicode characters

Added: trunk/LayoutTests/http/tests/xmlhttprequest/resetting-timeout-to-zero-expected.txt (0 => 208101)


--- trunk/LayoutTests/http/tests/xmlhttprequest/resetting-timeout-to-zero-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/resetting-timeout-to-zero-expected.txt	2016-10-29 13:44:27 UTC (rev 208101)
@@ -0,0 +1,3 @@
+
+PASS Resetting a timeout to zero after sending the request 
+

Added: trunk/LayoutTests/http/tests/xmlhttprequest/resetting-timeout-to-zero.html (0 => 208101)


--- trunk/LayoutTests/http/tests/xmlhttprequest/resetting-timeout-to-zero.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/resetting-timeout-to-zero.html	2016-10-29 13:44:27 UTC (rev 208101)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>XMLHttpRequest: make timeouts bigger than default timeout</title>
+    <script src=""
+    <script src=""
+  </head>
+  <body>
+    <script type="text/_javascript_">
+
+promise_test((test) => {
+    return new Promise((resolve, reject) => {
+        var xhr = new XMLHttpRequest();
+        var startTime = new Date();
+        xhr.open('GET', "/misc/resources/delayed-log.php?delay=10000000", true);
+
+        xhr.timeout = 70000; // time in milliseconds
+
+        xhr._onabort_ = () => { reject("onabort is called"); }
+        xhr._onload_ = () => { reject("onload is called"); };
+        xhr._onerror_ = () => { reject("onerror is called"); };
+        xhr._onloadend_ = () => { reject("onloadend is called but ontimeout was not"); };
+
+        xhr._ontimeout_ = function (e) {
+            var elapsed = new Date() - startTime;
+            if (elapsed > 65000 || elapsed < 55000) {
+                reject("elapsed time should be close to 60000 but is " + elapsed);
+                return;
+            }
+            resolve();
+        };
+
+        xhr.send(null);
+
+        xhr.timeout = 0;
+    });
+}, "Resetting a timeout to zero after sending the request");
+
+    </script>
+  </body>
+</html>
+

Added: trunk/LayoutTests/http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout-expected.txt (0 => 208101)


--- trunk/LayoutTests/http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout-expected.txt	2016-10-29 13:44:27 UTC (rev 208101)
@@ -0,0 +1,3 @@
+
+PASS Setting a timeout greater than network default 
+

Added: trunk/LayoutTests/http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout.html (0 => 208101)


--- trunk/LayoutTests/http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout.html	2016-10-29 13:44:27 UTC (rev 208101)
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>XMLHttpRequest: make timeouts bigger than default timeout</title>
+    <script src=""
+    <script src=""
+  </head>
+  <body>
+    <script type="text/_javascript_">
+
+promise_test((test) => {
+    return new Promise((resolve, reject) => {
+        var xhr = new XMLHttpRequest();
+        var startTime = new Date();
+        xhr.open('GET', "/misc/resources/delayed-log.php?delay=10000000", true);
+
+        xhr.timeout = 70000;
+
+        xhr._onabort_ = () => { reject("onabort is called"); }
+        xhr._onload_ = () => { reject("onload is called"); };
+        xhr._onerror_ = () => { reject("onerror is called"); };
+        xhr._onloadend_ = () => { reject("onloadend is called but ontimeout was not"); };
+
+        xhr._ontimeout_ = () => {
+            var elapsed = new Date() - startTime;
+            if (elapsed < 65000) {
+                reject("elapsed time should be greater than timeout value, got " + elapsed);
+                return;
+            }
+            resolve();
+        };
+
+        xhr.send(null);
+    });
+}, "Setting a timeout greater than network default");
+
+    </script>
+  </body>
+</html>
+

Modified: trunk/LayoutTests/tests-options.json (208100 => 208101)


--- trunk/LayoutTests/tests-options.json	2016-10-29 13:43:06 UTC (rev 208100)
+++ trunk/LayoutTests/tests-options.json	2016-10-29 13:44:27 UTC (rev 208101)
@@ -2,6 +2,12 @@
     "http/tests/xmlhttprequest/on-network-timeout-error-during-preflight.html": [
         "slow"
     ],
+    "http/tests/xmlhttprequest/resetting-timeout-to-zero.html": [
+        "slow"
+    ],
+    "http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout.html": [
+        "slow"
+    ],
     "imported/w3c/web-platform-tests/IndexedDB/idbcursor-continuePrimaryKey-exception-order.htm": [
         "slow"
     ],

Modified: trunk/Source/WebCore/ChangeLog (208100 => 208101)


--- trunk/Source/WebCore/ChangeLog	2016-10-29 13:43:06 UTC (rev 208100)
+++ trunk/Source/WebCore/ChangeLog	2016-10-29 13:44:27 UTC (rev 208101)
@@ -1,5 +1,21 @@
 2016-10-29  Youenn Fablet  <[email protected]>
 
+        REGRESSION (Safari 10 / r189445): WKWebView and WebView no longer allow async XMLHttpRequest timeout to exceed 60 seconds
+        https://bugs.webkit.org/show_bug.cgi?id=163814
+        <rdar://problem/28917420>
+
+        Reviewed by Darin Adler.
+
+        Tests: http/tests/xmlhttprequest/resetting-timeout-to-zero.html
+               http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout.html
+
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::setTimeout): If the XHR timeout is active, resetting the timeout to zero should lead to using the default network timeout.
+        Since it is difficult to update the timeout once the request is sent, we mimic the default network timeout with a 60 seconds XHR timeout.
+        (WebCore::XMLHttpRequest::createRequest): Setting network timeout to infinity if the XHR timeout is active.
+
+2016-10-29  Youenn Fablet  <[email protected]>
+
         MediaEndpoint::generateDtlsInfo is not needed
         https://bugs.webkit.org/show_bug.cgi?id=164130
 

Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (208100 => 208101)


--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2016-10-29 13:43:06 UTC (rev 208100)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2016-10-29 13:44:27 UTC (rev 208101)
@@ -244,11 +244,9 @@
     m_timeoutMilliseconds = timeout;
     if (!m_timeoutTimer.isActive())
         return { };
-    if (!m_timeoutMilliseconds) {
-        m_timeoutTimer.stop();
-        return { };
-    }
-    std::chrono::duration<double> interval = std::chrono::milliseconds { m_timeoutMilliseconds } - (std::chrono::steady_clock::now() - m_sendingTime);
+
+    // If timeout is zero, we should use the default network timeout. But we disabled it so let's mimic it with a 60 seconds timeout value.
+    std::chrono::duration<double> interval = std::chrono::milliseconds { m_timeoutMilliseconds ? m_timeoutMilliseconds : 60000 } - (std::chrono::steady_clock::now() - m_sendingTime);
     m_timeoutTimer.startOneShot(std::max(0.0, interval.count()));
     return { };
 }
@@ -676,6 +674,7 @@
         if (!m_async)
             request.setTimeoutInterval(m_timeoutMilliseconds / 1000.0);
         else {
+            request.setTimeoutInterval(std::numeric_limits<double>::infinity());
             m_sendingTime = std::chrono::steady_clock::now();
             m_timeoutTimer.startOneShot(std::chrono::milliseconds { m_timeoutMilliseconds });
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to