Skip to content
Permalink
Browse files
REGRESSION(r293671): [ iOS ] 2 TestWebKitAPI.MediaLoading.RangeReques…
…tSynthesis (API-Tests) are constant failures

https://bugs.webkit.org/show_bug.cgi?id=240033
rdar://92689429

Refactor the new code, add the transport stream to the copy resources step.

Reviewed by Jer Noble.

* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Add .ts file, copy to resources.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/MediaLoading.mm:
(TestWebKitAPI::TEST):  Update test.

* Tools/TestWebKitAPI/Tests/WebKit/cocoa/start-offset.ts -> Tools/TestWebKitAPI/Tests/WebKitCocoa/start-offset.ts

Canonical link: https://commits.webkit.org/250879@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294658 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
eric-carlson committed May 23, 2022
1 parent dad623f commit ee06a480e9ec984ed5f9b860a56d5200c0c937f2
Showing 3 changed files with 30 additions and 34 deletions.
@@ -47,6 +47,7 @@
/* Begin PBXBuildFile section */
041A1E34216FFDBC00789E0A /* PublicSuffix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 041A1E33216FFDBC00789E0A /* PublicSuffix.cpp */; };
04DB2396235E43EC00328F17 /* BumpPointerAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0451A5A6235E438E009DF945 /* BumpPointerAllocator.cpp */; };
0721D4592838296C00A95853 /* start-offset.ts in Copy Resources */ = {isa = PBXBuildFile; fileRef = 0721D4582838295400A95853 /* start-offset.ts */; };
07492B3B1DF8B14C00633DE1 /* EnumerateMediaDevices.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07492B3A1DF8AE2D00633DE1 /* EnumerateMediaDevices.cpp */; };
07492B3C1DF8B86600633DE1 /* enumerateMediaDevices.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 07492B391DF8ADA400633DE1 /* enumerateMediaDevices.html */; };
074994421EA5034B000DA44D /* invalidDeviceIDHashSalts in Copy Resources */ = {isa = PBXBuildFile; fileRef = 4A410F4D19AF7BEF002EBAB4 /* invalidDeviceIDHashSalts */; };
@@ -1606,6 +1607,7 @@
F4CFCDDA249FC9E400527482 /* SpaceOnly.otf in Copy Resources */,
9360270625A3CF7600367670 /* speechrecognition-basic.html in Copy Resources */,
9342589E255B6A120059EEDD /* speechrecognition-user-permission-persistence.html in Copy Resources */,
0721D4592838296C00A95853 /* start-offset.ts in Copy Resources */,
E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */,
515BE16F1D428BB100DD7C68 /* StoreBlobToBeDeleted.html in Copy Resources */,
9BD6D3A21F7B218300BD4962 /* sunset-in-cupertino-100px.tiff in Copy Resources */,
@@ -1714,6 +1716,7 @@
0451A5A6235E438E009DF945 /* BumpPointerAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BumpPointerAllocator.cpp; sourceTree = "<group>"; };
0711DF51226A95FB003DD2F7 /* AVFoundationSoftLinkTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AVFoundationSoftLinkTest.mm; sourceTree = "<group>"; };
07137049265320E500CA2C9A /* AudioBufferSize.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AudioBufferSize.mm; sourceTree = "<group>"; };
0721D4582838295400A95853 /* start-offset.ts */ = {isa = PBXFileReference; lastKnownFileType = file; path = "start-offset.ts"; sourceTree = "<group>"; };
0738012E275EADAB000FA77C /* GetDisplayMediaWindowAndScreen.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GetDisplayMediaWindowAndScreen.mm; sourceTree = "<group>"; };
0746645722FF62D000E3451A /* AccessibilityTestSupportProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AccessibilityTestSupportProtocol.h; sourceTree = "<group>"; };
0746645822FF630500E3451A /* AccessibilityTestPlugin.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AccessibilityTestPlugin.mm; sourceTree = "<group>"; };
@@ -4342,6 +4345,7 @@
F4CFCDD8249FC9D900527482 /* SpaceOnly.otf */,
9360270525A3B28E00367670 /* speechrecognition-basic.html */,
9342589D255B66A00059EEDD /* speechrecognition-user-permission-persistence.html */,
0721D4582838295400A95853 /* start-offset.ts */,
515BE16E1D4288FF00DD7C68 /* StoreBlobToBeDeleted.html */,
9BD6D3A11F7B202100BD4962 /* sunset-in-cupertino-100px.tiff */,
9BD6D3A01F7B202000BD4962 /* sunset-in-cupertino-200px.png */,
@@ -137,22 +137,16 @@ HTTPServer manifestServer([&](Connection connection) mutable {
return vector;
}

static void runVideoTest(NSURLRequest *request, const char* expectedMessage, bool enableCaptivePortalMode = false)
static void runVideoTest(NSURLRequest *request, const char* expectedMessage)
{
auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
configuration.get().defaultWebpagePreferences._captivePortalModeEnabled = enableCaptivePortalMode;
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
[webView loadRequest:request];
EXPECT_WK_STREQ([webView _test_waitForAlert], expectedMessage);
}

// FIXME Re-enable when https://bugs.webkit.org/show_bug.cgi?id=240033 is resovled
#if PLATFORM(IOS)
TEST(MediaLoading, DISABLED_RangeRequestSynthesisWithContentLength)
#else
TEST(MediaLoading, RangeRequestSynthesisWithContentLength)
#endif
{
HTTPServer server({
{"/"_s, { videoPlayTestHTML }},
@@ -162,12 +156,7 @@ HTTPServer server({
EXPECT_EQ(server.totalRequests(), 2u);
}

// FIXME Re-enable when https://bugs.webkit.org/show_bug.cgi?id=240033 is resovled
#if PLATFORM(IOS)
TEST(MediaLoading, DISABLED_RangeRequestSynthesisWithoutContentLength)
#else
TEST(MediaLoading, RangeRequestSynthesisWithoutContentLength)
#endif
{
size_t totalRequests { 0 };
Function<void(Connection)> respondToRequests;
@@ -196,28 +185,27 @@ HTTPServer server([&](Connection connection) {
EXPECT_EQ(totalRequests, 2u);
}

static Vector<uint8_t> testTransportStreamBytes()
TEST(MediaLoading, CaptivePortalHLS)
{
NSData *data = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"start-offset" withExtension:@"ts" subdirectory:@"TestWebKitAPI.resources"]];
Vector<uint8_t> vector;
vector.append(static_cast<const uint8_t*>(data.bytes), data.length);
return vector;
}

constexpr auto hlsPlayTestHTML ="<script>"
"function createVideoElement() {"
"let video = document.createElement('video');"
"video.addEventListener('error', ()=>{alert('error')});"
"video.addEventListener('playing', ()=>{alert('playing')});"
"video.src='video.m3u8';"
"video.autoplay=1;"
"document.body.appendChild(video);"
"}"
"</script>"
"<body onload='createVideoElement()'></body>"_s;
constexpr auto hlsPlayTestHTML = "<script>"
"function createVideoElement() {"
"let video = document.createElement('video');"
"video.addEventListener('error', () => { alert('error') });"
"video.addEventListener('playing', () => { alert('playing') });"
"video.src='video.m3u8';"
"video.autoplay=1;"
"document.body.appendChild(video);"
"}"
"</script>"
"<body onload='createVideoElement()'></body>"_s;

auto testTransportStreamBytes = [&] () -> Vector<uint8_t> {
NSData *data = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"start-offset" withExtension:@"ts" subdirectory:@"TestWebKitAPI.resources"]];
Vector<uint8_t> vector;
vector.append(static_cast<const uint8_t*>(data.bytes), data.length);
return vector;
};

TEST(MediaLoading, DISABLED_CaptivePortalHLS)
{
HTTPServer server({
{ "/"_s, { hlsPlayTestHTML } },
{ "/start-offset.ts"_s, { testTransportStreamBytes() } }
@@ -243,10 +231,14 @@ HTTPServer server({
);
server.addResponse("/video.m3u8"_s, { m3u8Source });

runVideoTest(server.request(), "playing", true);
auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
[configuration setMediaTypesRequiringUserActionForPlayback:WKAudiovisualMediaTypeNone];
[[configuration defaultWebpagePreferences] _setCaptivePortalModeEnabled:YES];
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
[webView loadRequest:server.request()];
EXPECT_WK_STREQ([webView _test_waitForAlert], "playing");
}


} // namespace TestWebKitAPI

#endif // ENABLE(VIDEO) && USE(AVFOUNDATION)

0 comments on commit ee06a48

Please sign in to comment.