Title: [287332] branches/safari-612-branch/Tools
Revision
287332
Author
[email protected]
Date
2021-12-21 14:40:14 -0800 (Tue, 21 Dec 2021)

Log Message

Cherry-pick r285057. rdar://problem/84000764

    [ 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:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285057 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-612-branch/Tools/ChangeLog (287331 => 287332)


--- branches/safari-612-branch/Tools/ChangeLog	2021-12-21 22:32:27 UTC (rev 287331)
+++ branches/safari-612-branch/Tools/ChangeLog	2021-12-21 22:40:14 UTC (rev 287332)
@@ -1,5 +1,37 @@
 2021-12-21  Robert Jenner  <[email protected]>
 
+        Cherry-pick r285057. rdar://problem/84000764
+
+    [ 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:
+    
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285057 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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-12-21  Robert Jenner  <[email protected]>
+
         Cherry-pick r286040. rdar://problem/80476146
 
     [ Monterey ] TestWebKitAPI.WebpagePreferences.WebsitePoliciesDuringRedirect is a constant timeout

Modified: branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm (287331 => 287332)


--- branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm	2021-12-21 22:32:27 UTC (rev 287331)
+++ branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm	2021-12-21 22:40:14 UTC (rev 287332)
@@ -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