Title: [285057] trunk/Tools
Revision
285057
Author
[email protected]
Date
2021-10-29 15:06:46 -0700 (Fri, 29 Oct 2021)

Log Message

[ Monterey iOS15 ] TestWebKitAPI.URLSchemeHandler.Ranges is a constant timeout
https://bugs.webkit.org/show_bug.cgi?id=231394

Reviewed by Jer Noble.

For some reason, AVFoundation used to play videos from custom schemes when you respond to range requests with 1 fewer byte than requested.
They stopped successfully playing videos in such circumstances, which is fine.  I had accidentally done that in my test.
When I respond properly, the test starts passing again.

* TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (285056 => 285057)


--- trunk/Tools/ChangeLog	2021-10-29 21:48:15 UTC (rev 285056)
+++ trunk/Tools/ChangeLog	2021-10-29 22:06:46 UTC (rev 285057)
@@ -1,3 +1,16 @@
+2021-10-29  Alex Christensen  <[email protected]>
+
+        [ Monterey iOS15 ] TestWebKitAPI.URLSchemeHandler.Ranges is a constant timeout
+        https://bugs.webkit.org/show_bug.cgi?id=231394
+
+        Reviewed by Jer Noble.
+
+        For some reason, AVFoundation used to play videos from custom schemes when you respond to range requests with 1 fewer byte than requested.
+        They stopped successfully playing videos in such circumstances, which is fine.  I had accidentally done that in my test.
+        When I respond properly, the test starts passing again.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:
+
 2021-10-29  John Pascoe  <[email protected]>
 
         Add last modified and creation time to +[_WKWebAuthenticationPanel getAllLocalAuthenticatorCredentials]

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm (285056 => 285057)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm	2021-10-29 21:48:15 UTC (rev 285056)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm	2021-10-29 22:06:46 UTC (rev 285057)
@@ -1571,8 +1571,6 @@
     EXPECT_WK_STREQ(@"Document URL: redirectone://bar.com/anothertest.html", [lastScriptMessage body]);
 }
 
-// FIXME: Re-enable this test once webkit.org/b/231394 is resolved.
-#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 120000) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 150000)
 TEST(URLSchemeHandler, Ranges)
 {
     RetainPtr<NSData> videoData = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"test" withExtension:@"mp4" subdirectory:@"TestWebKitAPI.resources"]];
@@ -1606,15 +1604,16 @@
         auto rangeBeginString = requestRangeString.substring(begin + rangeBytes.length(), dash - begin - rangeBytes.length());
         auto rangeEndString = requestRangeString.substring(dash + 1, end - dash - 1);
         auto rangeBegin = parseInteger<uint64_t>(rangeBeginString).value_or(0);
-        auto rangeEnd = rangeEndString == "*" ? [videoData length] : parseInteger<uint64_t>(rangeEndString).value_or(0);
+        auto rangeEnd = rangeEndString == "*" ? [videoData length] - 1 : parseInteger<uint64_t>(rangeEndString).value_or(0);
+        auto contentLength = rangeEnd - rangeBegin + 1;
 
         auto response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@"https://webkit.org/"] statusCode:206 HTTPVersion:@"HTTP/1.1" headerFields:@{
             @"Content-Range" : [NSString stringWithFormat:@"bytes %llu-%llu/%lu", rangeBegin, rangeEnd, (unsigned long)[videoData length]],
-            @"Content-Length" : [NSString stringWithFormat:@"%llu", rangeEnd - rangeBegin + 1]
+            @"Content-Length" : [NSString stringWithFormat:@"%llu", contentLength]
         }]);
 
         [task didReceiveResponse:response.get()];
-        [task didReceiveData:[videoData subdataWithRange:NSMakeRange(rangeBegin, rangeEnd - rangeBegin)]];
+        [task didReceiveData:[videoData subdataWithRange:NSMakeRange(rangeBegin, contentLength)]];
         [task didFinish];
         foundRangeRequest = true;
     }];
@@ -1622,7 +1621,6 @@
     EXPECT_WK_STREQ([webView _test_waitForAlert], "playing");
     EXPECT_TRUE(foundRangeRequest);
 }
-#endif
 
 TEST(URLSchemeHandler, HandleURLRewrittenByPlugIn)
 {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to