Title: [208332] branches/safari-602-branch

Diff

Modified: branches/safari-602-branch/LayoutTests/ChangeLog (208331 => 208332)


--- branches/safari-602-branch/LayoutTests/ChangeLog	2016-11-03 18:04:28 UTC (rev 208331)
+++ branches/safari-602-branch/LayoutTests/ChangeLog	2016-11-03 18:04:33 UTC (rev 208332)
@@ -1,5 +1,23 @@
 2016-11-03  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r208101. rdar://problem/29053206
+
+    2016-10-29  Youenn Fablet  <you...@apple.com>
+
+            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-11-03  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r208025. rdar://problem/28216240
 
     2016-10-27  Simon Fraser  <simon.fra...@apple.com>

Added: branches/safari-602-branch/LayoutTests/http/tests/xmlhttprequest/resetting-timeout-to-zero-expected.txt (0 => 208332)


--- branches/safari-602-branch/LayoutTests/http/tests/xmlhttprequest/resetting-timeout-to-zero-expected.txt	                        (rev 0)
+++ branches/safari-602-branch/LayoutTests/http/tests/xmlhttprequest/resetting-timeout-to-zero-expected.txt	2016-11-03 18:04:33 UTC (rev 208332)
@@ -0,0 +1,3 @@
+
+PASS Resetting a timeout to zero after sending the request 
+

Added: branches/safari-602-branch/LayoutTests/http/tests/xmlhttprequest/resetting-timeout-to-zero.html (0 => 208332)


--- branches/safari-602-branch/LayoutTests/http/tests/xmlhttprequest/resetting-timeout-to-zero.html	                        (rev 0)
+++ branches/safari-602-branch/LayoutTests/http/tests/xmlhttprequest/resetting-timeout-to-zero.html	2016-11-03 18:04:33 UTC (rev 208332)
@@ -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: branches/safari-602-branch/LayoutTests/http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout-expected.txt (0 => 208332)


--- branches/safari-602-branch/LayoutTests/http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout-expected.txt	                        (rev 0)
+++ branches/safari-602-branch/LayoutTests/http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout-expected.txt	2016-11-03 18:04:33 UTC (rev 208332)
@@ -0,0 +1,3 @@
+
+PASS Setting a timeout greater than network default 
+

Added: branches/safari-602-branch/LayoutTests/http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout.html (0 => 208332)


--- branches/safari-602-branch/LayoutTests/http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout.html	                        (rev 0)
+++ branches/safari-602-branch/LayoutTests/http/tests/xmlhttprequest/timeout-greater-than-default-network-timeout.html	2016-11-03 18:04:33 UTC (rev 208332)
@@ -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: branches/safari-602-branch/Source/WebCore/ChangeLog (208331 => 208332)


--- branches/safari-602-branch/Source/WebCore/ChangeLog	2016-11-03 18:04:28 UTC (rev 208331)
+++ branches/safari-602-branch/Source/WebCore/ChangeLog	2016-11-03 18:04:33 UTC (rev 208332)
@@ -1,5 +1,25 @@
 2016-11-03  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r208101. rdar://problem/29053206
+
+    2016-10-29  Youenn Fablet  <you...@apple.com>
+
+            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-11-03  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r208025. rdar://problem/28216240
 
     2016-10-27  Simon Fraser  <simon.fra...@apple.com>

Modified: branches/safari-602-branch/Source/WebCore/xml/XMLHttpRequest.cpp (208331 => 208332)


--- branches/safari-602-branch/Source/WebCore/xml/XMLHttpRequest.cpp	2016-11-03 18:04:28 UTC (rev 208331)
+++ branches/safari-602-branch/Source/WebCore/xml/XMLHttpRequest.cpp	2016-11-03 18:04:33 UTC (rev 208332)
@@ -266,11 +266,10 @@
     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()));
 }
 
@@ -722,6 +721,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
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to