Changeset 259622 in webkit


Ignore:
Timestamp:
Apr 6, 2020 8:39:38 PM (4 years ago)
Author:
Peng Liu
Message:

REGRESSION (r259531?): [iOS] TestWebKitAPI.WebKitLegacy.ScrollingDoesNotPauseMedia is timing out
https://bugs.webkit.org/show_bug.cgi?id=210013

Reviewed by Daniel Bates.

Fix mistakes in the test and make it more reliable.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollingDoesNotPauseMedia.mm:

(-[ScrollingDoesNotPauseMediaDelegate handleEvent:]):
(TestWebKitAPI::TEST):

  • TestWebKitAPI/Tests/WebKitLegacy/ios/one-video.html: Added.
Location:
trunk/Tools
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r259617 r259622  
     12020-04-06  Peng Liu  <peng.liu6@apple.com>
     2
     3        REGRESSION (r259531?): [iOS] TestWebKitAPI.WebKitLegacy.ScrollingDoesNotPauseMedia is timing out
     4        https://bugs.webkit.org/show_bug.cgi?id=210013
     5
     6        Reviewed by Daniel Bates.
     7
     8        Fix mistakes in the test and make it more reliable.
     9
     10        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     11        * TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollingDoesNotPauseMedia.mm:
     12        (-[ScrollingDoesNotPauseMediaDelegate handleEvent:]):
     13        (TestWebKitAPI::TEST):
     14        * TestWebKitAPI/Tests/WebKitLegacy/ios/one-video.html: Added.
     15
    1162020-04-06  Don Olmstead  <don.olmstead@sony.com>
    217
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r259531 r259622  
    116116                1D67BFDC2433E0A7006B5047 /* PreemptVideoFullscreen.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1D67BFDB2433E0A7006B5047 /* PreemptVideoFullscreen.mm */; };
    117117                1D67BFDD2433EE66006B5047 /* two-videos.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1D67BFD92433DFD8006B5047 /* two-videos.html */; };
     118                1DAA52CC243BE805001A3159 /* one-video.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1DAA52CB243BE621001A3159 /* one-video.html */; };
    118119                1F83571B1D3FFB2300E3967B /* WKBackForwardList.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F83571A1D3FFB0E00E3967B /* WKBackForwardList.mm */; };
    119120                26DF5A6315A2A27E003689C2 /* CancelLoadFromResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 26DF5A6115A2A22B003689C2 /* CancelLoadFromResourceLoadDelegate.html */; };
     
    14551456                                93E2D2761ED7D53200FA76F6 /* offscreen-iframe-of-media-document.html in Copy Resources */,
    14561457                                074994421EA5034B000DA44F /* ondevicechange.html in Copy Resources */,
     1458                                1DAA52CC243BE805001A3159 /* one-video.html in Copy Resources */,
    14571459                                CEA6CF2819CCF69D0064F5A7 /* open-and-close-window.html in Copy Resources */,
    14581460                                7CCB99231D3B4A46003922F6 /* open-multiple-external-url.html in Copy Resources */,
     
    16701672                1D67BFD92433DFD8006B5047 /* two-videos.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "two-videos.html"; sourceTree = "<group>"; };
    16711673                1D67BFDB2433E0A7006B5047 /* PreemptVideoFullscreen.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PreemptVideoFullscreen.mm; sourceTree = "<group>"; };
     1674                1DAA52CB243BE621001A3159 /* one-video.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "one-video.html"; sourceTree = "<group>"; };
    16721675                1F83571A1D3FFB0E00E3967B /* WKBackForwardList.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKBackForwardList.mm; path = Tests/WebKit/WKBackForwardList.mm; sourceTree = SOURCE_ROOT; };
    16731676                260BA5781B1D2E7B004FA07C /* DFACombiner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DFACombiner.cpp; sourceTree = "<group>"; };
     
    43444347                        children = (
    43454348                                CD9E292D1C90C1BA000BB800 /* audio-only.html */,
     4349                                1DAA52CB243BE621001A3159 /* one-video.html */,
    43464350                                1D67BFD92433DFD8006B5047 /* two-videos.html */,
    43474351                                CDC8E4891BC5C96200594FEC /* video-with-audio.html */,
  • trunk/Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollingDoesNotPauseMedia.mm

    r255116 r259622  
    3131#import <WebKit/DOMHTMLMediaElement.h>
    3232#import <WebKit/WebFramePrivate.h>
     33#import <WebKitLegacy/WebPreferencesPrivate.h>
    3334#import <wtf/MainThread.h>
    3435#import <wtf/RetainPtr.h>
     
    3839@end
    3940
    40 static bool didFinishLoad;
    41 static bool gotMainFrame;
    42 static WebFrame* mainFrame;
     41static bool didFinishLoad = false;
     42static bool gotMainFrame = false;
     43static RetainPtr<WebFrame> mainFrame;
     44
     45static bool readyToTest = false;
     46static bool didReceivePause  = false;
     47static bool didReceivePlaying = false;
    4348
    4449@implementation ScrollingDoesNotPauseMediaDelegate
     
    5762}
    5863
    59 static bool didReceivePause;
    60 static bool didReceivePlaying;
    61 
    6264- (void)handleEvent:(DOMEvent *)event
    6365{
    64     if ([event.type isEqualToString:@"pause"])
     66    if ([event.type isEqualToString:@"canplaythrough"])
     67        readyToTest = true;
     68    else if ([event.type isEqualToString:@"pause"])
    6569        didReceivePause = true;
    6670    else if ([event.type isEqualToString:@"playing"])
     
    7377TEST(WebKitLegacy, ScrollingDoesNotPauseMedia)
    7478{
     79    RetainPtr<WebPreferences> preferences = [WebPreferences standardPreferences];
     80    preferences.get().mediaDataLoadsAutomatically = YES;
     81    preferences.get().mediaPlaybackAllowsInline = YES;
     82    preferences.get().mediaPlaybackRequiresUserGesture = NO;
     83
    7584    RetainPtr<UIWindow> uiWindow = adoptNS([[UIWindow alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
    7685    RetainPtr<UIWebView> uiWebView = adoptNS([[UIWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
    7786    [uiWindow addSubview:uiWebView.get()];
    7887
    79     uiWebView.get().mediaPlaybackRequiresUserAction = NO;
    80     uiWebView.get().allowsInlineMediaPlayback = YES;
    81 
    8288    RetainPtr<ScrollingDoesNotPauseMediaDelegate> testController = adoptNS([ScrollingDoesNotPauseMediaDelegate new]);
    8389    uiWebView.get().delegate = testController.get();
    8490
    85     didFinishLoad = false;
    86     gotMainFrame = false;
    87     mainFrame = nil;
    88 
    89     [uiWebView loadRequest:[NSURLRequest requestWithURL:[NSBundle.mainBundle URLForResource:@"video-with-audio" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
     91    [uiWebView loadRequest:[NSURLRequest requestWithURL:[NSBundle.mainBundle URLForResource:@"one-video" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
    9092
    9193    Util::run(&didFinishLoad);
     
    9597        [mainFrame setTimeoutsPaused:YES];
    9698
    97         DOMHTMLMediaElement* video = (DOMHTMLMediaElement*)[mainFrame.DOMDocument querySelector:@"video"];
     99        DOMHTMLMediaElement* video = (DOMHTMLMediaElement*)[[mainFrame DOMDocument] querySelector:@"video"];
    98100        ASSERT_TRUE([video isKindOfClass:[DOMHTMLMediaElement class]]);
    99101
     102        [video addEventListener:@"canplaythrough" listener:testController.get() useCapture:NO];
    100103        [video addEventListener:@"playing" listener:testController.get() useCapture:NO];
    101         didReceivePlaying = false;
    102         [video play];
     104        [video addEventListener:@"pause" listener:testController.get() useCapture:NO];
     105        [video setSrc:@"video-with-audio.mp4"];
    103106
    104107        [mainFrame setTimeoutsPaused:NO];
     108    });
     109
     110    Util::run(&readyToTest);
     111
     112    callOnMainThreadAndWait([&] () mutable {
     113        DOMHTMLMediaElement* video = (DOMHTMLMediaElement*)[[mainFrame DOMDocument] querySelector:@"video"];
     114        ASSERT_TRUE([video isKindOfClass:[DOMHTMLMediaElement class]]);
     115
     116        [video play];
    105117    });
    106118
     
    108120
    109121    callOnMainThreadAndWait([&] () mutable {
    110         [mainFrame setTimeoutsPaused:YES];
    111 
    112         DOMHTMLMediaElement* video = (DOMHTMLMediaElement*)[mainFrame.DOMDocument querySelector:@"video"];
     122        DOMHTMLMediaElement* video = (DOMHTMLMediaElement*)[[mainFrame DOMDocument] querySelector:@"video"];
    113123        ASSERT_TRUE([video isKindOfClass:[DOMHTMLMediaElement class]]);
    114124
    115         [video addEventListener:@"pause" listener:testController.get() useCapture:NO];
    116         didReceivePause = false;
    117125        [video pause];
    118 
    119         [mainFrame setTimeoutsPaused:NO];
    120126    });
    121127
Note: See TracChangeset for help on using the changeset viewer.