Changeset 205417 in webkit
- Timestamp:
- Sep 3, 2016 10:45:10 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r205416 r205417 1 2016-09-03 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Media controls behave strangely when videos mute from within a playing handler 4 https://bugs.webkit.org/show_bug.cgi?id=161559 5 <rdar://problem/28018438> 6 7 Reviewed by Darin Adler. 8 9 Defer showing media controls until after the media element has fired its onplaying handler. This handles cases 10 where videos that autoplay may initially meet the criteria for main content, but once the video begins to play, 11 the page may change the media in some way (e.g. muting) that makes the video no longer main content. This causes 12 media controls to flicker in and out. 13 14 These changes are covered by existing unit tests, which have been refactored to check media controller state 15 after all autoplaying videos have begun playing. Also adds an additional unit test. 16 17 * html/HTMLMediaElement.cpp: 18 (WebCore::HTMLMediaElement::notifyAboutPlaying): 19 (WebCore::HTMLMediaElement::hasEverNotifiedAboutPlaying): 20 * html/HTMLMediaElement.h: 21 * html/MediaElementSession.cpp: 22 (WebCore::MediaElementSession::canShowControlsManager): 23 1 24 2016-09-03 Ryosuke Niwa <rniwa@webkit.org> 2 25 -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r205412 r205417 482 482 , m_creatingControls(false) 483 483 , m_receivedLayoutSizeChanged(false) 484 , m_hasEverNotifiedAboutPlaying(false) 484 485 #if ENABLE(MEDIA_CONTROLS_SCRIPT) 485 486 , m_mediaControlsDependOnPageScaleFactor(false) … … 1015 1016 dispatchEvent(Event::create(eventNames().playingEvent, false, true)); 1016 1017 resolvePendingPlayPromises(); 1018 1019 m_hasEverNotifiedAboutPlaying = true; 1020 scheduleUpdatePlaybackControlsManager(); 1021 } 1022 1023 bool HTMLMediaElement::hasEverNotifiedAboutPlaying() const 1024 { 1025 return m_hasEverNotifiedAboutPlaying; 1017 1026 } 1018 1027 -
trunk/Source/WebCore/html/HTMLMediaElement.h
r205412 r205417 471 471 void resetPlaybackSessionState(); 472 472 bool isVisibleInViewport() const; 473 bool hasEverNotifiedAboutPlaying() const; 473 474 474 475 protected: … … 944 945 bool m_creatingControls : 1; 945 946 bool m_receivedLayoutSizeChanged : 1; 947 bool m_hasEverNotifiedAboutPlaying : 1; 946 948 947 949 #if ENABLE(MEDIA_CONTROLS_SCRIPT) -
trunk/Source/WebCore/html/MediaElementSession.cpp
r205412 r205417 229 229 } 230 230 231 if (m_element.document().isMediaDocument()) { 232 LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Is media document"); 233 return true; 234 } 235 231 236 if (m_element.document().activeDOMObjectsAreSuspended()) { 232 237 LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: activeDOMObjectsAreSuspended()"); … … 251 256 if (m_element.muted()) { 252 257 LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Muted"); 258 return false; 259 } 260 261 if (!m_element.hasEverNotifiedAboutPlaying()) { 262 LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Hasn't fired playing notification"); 253 263 return false; 254 264 } … … 258 268 LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No renderer"); 259 269 return false; 260 }261 262 if (m_element.document().isMediaDocument()) {263 LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Is media document");264 return true;265 270 } 266 271 -
trunk/Tools/ChangeLog
r205412 r205417 1 2016-09-03 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Media controls behave strangely when videos mute from within a playing handler 4 https://bugs.webkit.org/show_bug.cgi?id=161559 5 <rdar://problem/28018438> 6 7 Reviewed by Darin Adler. 8 9 Accounts for changes when determining whether or not to show media controls for autoplaying videos that have not 10 begun playing yet. Rather than check for a controlled media element upon page load, we force tests to wait until 11 all autoplaying videos have actually begun playing. This extends to tests that involve interaction, such as 12 clicking or scrolling. 13 14 * TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm: 15 (-[VideoControlsManagerTestWebView callJavascriptFunction:]): 16 (-[VideoControlsManagerTestWebView expectControlsManager:afterReceivingMessage:]): 17 (-[VideoControlsManagerTestWebView performAfterReceivingMessage:action:]): 18 (-[VideoControlsManagerTestWebView waitForPageToLoadWithAutoplayingVideos:]): 19 (TestWebKitAPI::TEST): 20 (-[VideoControlsManagerTestWebView loadTestPageNamed:andExpectControlsManager:afterReceivingMessage:]): Deleted. 21 * TestWebKitAPI/Tests/WebKit2Cocoa/autoplaying-video-with-audio.html: 22 * TestWebKitAPI/Tests/WebKit2Cocoa/large-video-hides-controls-after-seek-to-end.html: 23 * TestWebKitAPI/Tests/WebKit2Cocoa/large-video-playing-scroll-away.html: 24 * TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-click-to-pause.html: 25 * TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-scroll-to-video.html: 26 * TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-paused-video-hides-controls.html: 27 * TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-muted-video-hides-controls.html: 28 * TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-video-keeps-controls.html: 29 * TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-with-audio-autoplay.html: 30 1 31 2016-09-03 Wenson Hsieh <wenson_hsieh@apple.com> 2 32 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r205412 r205417 65 65 2E1DFDEF1D42A6F200714A00 /* large-videos-with-audio-autoplay.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E1DFDEE1D42A6EB00714A00 /* large-videos-with-audio-autoplay.html */; }; 66 66 2E1DFDF11D42E1E400714A00 /* large-video-seek-to-beginning-and-play-after-ending.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E1DFDF01D42E14400714A00 /* large-video-seek-to-beginning-and-play-after-ending.html */; }; 67 2E54F40D1D7BC84200921ADF /* large-video-mutes-onplaying.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E54F40C1D7BC83900921ADF /* large-video-mutes-onplaying.html */; }; 67 68 2E691AEA1D78B53600129407 /* large-videos-paused-video-hides-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E691AE81D78B52B00129407 /* large-videos-paused-video-hides-controls.html */; }; 68 69 2E691AEB1D78B53600129407 /* large-videos-playing-video-keeps-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E691AE91D78B52B00129407 /* large-videos-playing-video-keeps-controls.html */; }; … … 527 528 dstSubfolderSpec = 7; 528 529 files = ( 530 2E54F40D1D7BC84200921ADF /* large-video-mutes-onplaying.html in Copy Resources */, 529 531 2E691AF31D79E75E00129407 /* large-video-playing-scroll-away.html in Copy Resources */, 530 532 2E691AF11D79E51A00129407 /* large-videos-autoplaying-scroll-to-video.html in Copy Resources */, … … 756 758 2E1DFDEE1D42A6EB00714A00 /* large-videos-with-audio-autoplay.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-videos-with-audio-autoplay.html"; sourceTree = "<group>"; }; 757 759 2E1DFDF01D42E14400714A00 /* large-video-seek-to-beginning-and-play-after-ending.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-seek-to-beginning-and-play-after-ending.html"; sourceTree = "<group>"; }; 760 2E54F40C1D7BC83900921ADF /* large-video-mutes-onplaying.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-mutes-onplaying.html"; sourceTree = "<group>"; }; 758 761 2E691AE81D78B52B00129407 /* large-videos-paused-video-hides-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-videos-paused-video-hides-controls.html"; sourceTree = "<group>"; }; 759 762 2E691AE91D78B52B00129407 /* large-videos-playing-video-keeps-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-videos-playing-video-keeps-controls.html"; sourceTree = "<group>"; }; … … 1419 1422 isa = PBXGroup; 1420 1423 children = ( 1424 2E54F40C1D7BC83900921ADF /* large-video-mutes-onplaying.html */, 1421 1425 2E691AF21D79E75400129407 /* large-video-playing-scroll-away.html */, 1422 1426 2E691AF01D79E51400129407 /* large-videos-autoplaying-scroll-to-video.html */, -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm
r205412 r205417 44 44 @end 45 45 46 @interface MessageHandler : NSObject <WKScriptMessageHandler> { 46 @interface MessageHandler : NSObject <WKScriptMessageHandler> 47 @end 48 49 @implementation MessageHandler { 47 50 dispatch_block_t _handler; 48 51 NSString *_message; 49 52 } 50 53 51 - (instancetype)initWithMessage:(NSString *)message handler:(dispatch_block_t)handler;52 53 @end54 55 @implementation MessageHandler56 57 54 - (instancetype)initWithMessage:(NSString *)message handler:(dispatch_block_t)handler 58 55 { … … 75 72 76 73 @interface VideoControlsManagerTestWebView : WKWebView 77 78 - (void)mouseDownAtPoint:(NSPoint)point;79 - (void)performAfterLoading:(dispatch_block_t)actions;80 - (void)loadTestPageNamed:(NSString *)pageName;81 - (void)loadTestPageNamed:(NSString *)pageName andExpectControlsManager:(BOOL)expectControlsManager afterReceivingMessage:(NSString *)message;82 - (void)performAfterReceivingMessage:(NSString *)message action:(dispatch_block_t)action;83 84 @property (nonatomic, readonly) NSString *controlledElementID;85 86 74 @end 87 75 … … 105 93 } 106 94 95 - (void)callJavascriptFunction:(NSString *)functionName 96 { 97 NSString *command = [NSString stringWithFormat:@"%@()", functionName]; 98 [self evaluateJavaScript:command completionHandler:nil]; 99 } 100 107 101 - (void)loadTestPageNamed:(NSString *)pageName 108 102 { … … 111 105 } 112 106 113 - (void) loadTestPageNamed:(NSString *)pageName andExpectControlsManager:(BOOL)expectControlsManager afterReceivingMessage:(NSString *)message107 - (void)expectControlsManager:(BOOL)expectControlsManager afterReceivingMessage:(NSString *)message 114 108 { 115 109 __block bool doneWaiting = false; … … 123 117 }]; 124 118 125 [self loadTestPageNamed:pageName];126 119 TestWebKitAPI::Util::run(&doneWaiting); 127 120 } … … 130 123 { 131 124 RetainPtr<MessageHandler> handler = adoptNS([[MessageHandler alloc] initWithMessage:message handler:action]); 132 [[[self configuration] userContentController] addScriptMessageHandler:handler.get() name:@"playingHandler"]; 125 WKUserContentController* contentController = [[self configuration] userContentController]; 126 [contentController removeScriptMessageHandlerForName:@"playingHandler"]; 127 [contentController addScriptMessageHandler:handler.get() name:@"playingHandler"]; 128 } 129 130 - (void)waitForPageToLoadWithAutoplayingVideos:(int)numberOfAutoplayingVideos 131 { 132 __block int remainingAutoplayedCount = numberOfAutoplayingVideos; 133 __block bool autoplayingIsFinished = !numberOfAutoplayingVideos; 134 __block bool pageHasLoaded = false; 135 136 [self performAfterLoading:^() 137 { 138 pageHasLoaded = true; 139 }]; 140 141 if (numberOfAutoplayingVideos) { 142 [self performAfterReceivingMessage:@"autoplayed" action:^() 143 { 144 remainingAutoplayedCount--; 145 if (remainingAutoplayedCount <= 0) 146 autoplayingIsFinished = true; 147 }]; 148 } 149 150 TestWebKitAPI::Util::run(&pageHasLoaded); 151 TestWebKitAPI::Util::run(&autoplayingIsFinished); 133 152 } 134 153 … … 168 187 // A large video with audio should have a controls manager even if it is played via script like this video. 169 188 // So the expectation is YES. 170 [webView loadTestPageNamed:@"large-video-with-audio" andExpectControlsManager:YES afterReceivingMessage:@"playing"]; 189 [webView loadTestPageNamed:@"large-video-with-audio"]; 190 [webView expectControlsManager:YES afterReceivingMessage:@"playing"]; 171 191 } 172 192 … … 177 197 // A small video will not have a controls manager unless it started playing because of a user gesture. Since this 178 198 // video is started with a script, the expectation is NO. 179 [webView loadTestPageNamed:@"video-with-audio" andExpectControlsManager:NO afterReceivingMessage:@"playing"]; 199 [webView loadTestPageNamed:@"video-with-audio"]; 200 [webView expectControlsManager:NO afterReceivingMessage:@"playing"]; 180 201 } 181 202 … … 184 205 RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100)); 185 206 186 __block BOOL didShowMediaControls;187 __block bool isDoneLoading = false;188 189 [webView performAfterLoading:^ {190 didShowMediaControls = [webView _hasActiveVideoForControlsManager];191 isDoneLoading = true;192 }];193 194 207 [webView loadTestPageNamed:@"large-videos-with-audio"]; 195 196 TestWebKitAPI::Util::run(&isDoneLoading); 197 EXPECT_FALSE( didShowMediaControls);208 [webView waitForPageToLoadWithAutoplayingVideos:0]; 209 210 EXPECT_FALSE([webView _hasActiveVideoForControlsManager]); 198 211 } 199 212 … … 202 215 RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100)); 203 216 204 __block BOOL didShowMediaControls;205 __block bool isDoneLoading = false;206 207 [webView performAfterLoading:^ {208 didShowMediaControls = [webView _hasActiveVideoForControlsManager];209 isDoneLoading = true;210 }];211 212 217 [webView loadTestPageNamed:@"large-videos-with-audio-autoplay"]; 213 214 TestWebKitAPI::Util::run(&isDoneLoading); 215 EXPECT_TRUE(didShowMediaControls); 218 [webView waitForPageToLoadWithAutoplayingVideos:1]; 219 220 EXPECT_TRUE([webView _hasActiveVideoForControlsManager]); 221 EXPECT_TRUE([[webView controlledElementID] isEqualToString:@"bar"]); 216 222 } 217 223 … … 220 226 RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500)); 221 227 222 [webView loadTestPageNamed:@"large-videos-paused-video-hides-controls" andExpectControlsManager:NO afterReceivingMessage:@"paused"]; 228 [webView loadTestPageNamed:@"large-videos-paused-video-hides-controls"]; 229 [webView waitForPageToLoadWithAutoplayingVideos:1]; 230 231 [webView callJavascriptFunction:@"pauseFirstVideoAndScrollToSecondVideo"]; 232 [webView expectControlsManager:NO afterReceivingMessage:@"paused"]; 223 233 } 224 234 … … 227 237 RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500)); 228 238 229 [webView loadTestPageNamed:@"large-videos-playing-video-keeps-controls" andExpectControlsManager:YES afterReceivingMessage:@"playing"]; 239 [webView loadTestPageNamed:@"large-videos-playing-video-keeps-controls"]; 240 [webView waitForPageToLoadWithAutoplayingVideos:1]; 241 242 [webView callJavascriptFunction:@"scrollToSecondVideo"]; 243 [webView expectControlsManager:YES afterReceivingMessage:@"scrolled"]; 230 244 } 231 245 … … 234 248 RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500)); 235 249 236 [webView loadTestPageNamed:@"large-videos-playing-muted-video-hides-controls" andExpectControlsManager:NO afterReceivingMessage:@"playing"]; 250 [webView loadTestPageNamed:@"large-videos-playing-muted-video-hides-controls"]; 251 [webView waitForPageToLoadWithAutoplayingVideos:1]; 252 253 [webView callJavascriptFunction:@"muteFirstVideoAndScrollToSecondVideo"]; 254 [webView expectControlsManager:NO afterReceivingMessage:@"playing"]; 237 255 } 238 256 … … 242 260 NSPoint clickPoint = NSMakePoint(400, 300); 243 261 244 [webView performAfterLoading:^ { 245 [webView mouseDownAtPoint:clickPoint]; 246 }]; 262 [webView loadTestPageNamed:@"large-videos-autoplaying-click-to-pause"]; 263 [webView waitForPageToLoadWithAutoplayingVideos:2]; 264 265 [webView mouseDownAtPoint:clickPoint]; 247 266 248 267 __block bool firstVideoPaused = false; … … 251 270 NSString *controlledElementID = [webView controlledElementID]; 252 271 if (firstVideoPaused) { 272 EXPECT_TRUE([controlledElementID isEqualToString:@"second"]); 253 273 secondVideoPaused = true; 254 EXPECT_TRUE([controlledElementID isEqualToString:@"second"]);255 274 } else { 275 EXPECT_TRUE([controlledElementID isEqualToString:@"first"]); 256 276 [webView mouseDownAtPoint:clickPoint]; 257 EXPECT_TRUE([controlledElementID isEqualToString:@"first"]);258 277 } 259 278 firstVideoPaused = true; 260 279 }]; 261 280 262 [webView loadTestPageNamed:@"large-videos-autoplaying-click-to-pause"];263 281 TestWebKitAPI::Util::run(&secondVideoPaused); 264 282 } … … 268 286 RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 800, 600)); 269 287 270 __block bool scrolledSecondVideoIntoView = false;271 288 [webView loadTestPageNamed:@"large-videos-autoplaying-scroll-to-video"]; 272 [webView performAfterReceivingMessage:@"scrolled" action:^ {273 scrolledSecondVideoIntoView = true; 274 }];275 276 TestWebKitAPI::Util::run(&scrolledSecondVideoIntoView); 289 [webView waitForPageToLoadWithAutoplayingVideos:2]; 290 291 [webView callJavascriptFunction:@"scrollToSecondView"]; 292 [webView expectControlsManager:YES afterReceivingMessage:@"scrolled"]; 293 277 294 EXPECT_TRUE([[webView controlledElementID] isEqualToString:@"second"]); 278 295 } … … 282 299 RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500)); 283 300 284 [webView loadTestPageNamed:@"large-video-playing-scroll-away" andExpectControlsManager:YES afterReceivingMessage:@"scrolled"]; 301 [webView loadTestPageNamed:@"large-video-playing-scroll-away"]; 302 [webView waitForPageToLoadWithAutoplayingVideos:1]; 303 [webView callJavascriptFunction:@"scrollVideoOutOfView"]; 304 [webView expectControlsManager:YES afterReceivingMessage:@"scrolled"]; 285 305 } 286 306 … … 289 309 RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100)); 290 310 291 [webView performAfterLoading:^ {292 [webView mouseDownAtPoint:NSMakePoint(50, 50)];293 }]; 294 295 [webView loadTestPageNamed:@"autoplaying-video-with-audio" andExpectControlsManager:YES afterReceivingMessage:@"paused"];311 [webView loadTestPageNamed:@"autoplaying-video-with-audio"]; 312 [webView waitForPageToLoadWithAutoplayingVideos:1]; 313 314 [webView mouseDownAtPoint:NSMakePoint(50, 50)]; 315 [webView expectControlsManager:YES afterReceivingMessage:@"paused"]; 296 316 } 297 317 … … 301 321 302 322 // Since the video has ended, the expectation is NO even if the page programmatically seeks to the beginning. 303 [webView loadTestPageNamed:@"large-video-seek-after-ending" andExpectControlsManager:NO afterReceivingMessage:@"ended"]; 323 [webView loadTestPageNamed:@"large-video-seek-after-ending"]; 324 [webView expectControlsManager:NO afterReceivingMessage:@"ended"]; 304 325 } 305 326 … … 309 330 310 331 // Since the video is still playing, the expectation is YES even if the video has ended once. 311 [webView loadTestPageNamed:@"large-video-seek-to-beginning-and-play-after-ending" andExpectControlsManager:YES afterReceivingMessage:@"replaying"]; 332 [webView loadTestPageNamed:@"large-video-seek-to-beginning-and-play-after-ending"]; 333 [webView expectControlsManager:YES afterReceivingMessage:@"replaying"]; 312 334 } 313 335 … … 316 338 RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 100, 100)); 317 339 318 [webView performAfterLoading:^ {319 [webView mouseDownAtPoint:NSMakePoint(50, 50)];320 }];340 [webView loadTestPageNamed:@"large-video-hides-controls-after-seek-to-end"]; 341 [webView waitForPageToLoadWithAutoplayingVideos:1]; 342 [webView mouseDownAtPoint:NSMakePoint(50, 50)]; 321 343 322 344 // We expect there to be media controls, since this is a user gestured seek to the end. 323 345 // This is akin to seeking to the end by scrubbing in the controls. 324 [webView loadTestPageNamed:@"large-video-hides-controls-after-seek-to-end" andExpectControlsManager:YES afterReceivingMessage:@"ended"];346 [webView expectControlsManager:YES afterReceivingMessage:@"ended"]; 325 347 } 326 348 … … 331 353 // A large video with no audio will not have a controls manager unless it started playing because of a user gesture. Since this 332 354 // video is started with a script, the expectation is NO. 333 [webView loadTestPageNamed:@"large-video-without-audio" andExpectControlsManager:NO afterReceivingMessage:@"playing"]; 355 [webView loadTestPageNamed:@"large-video-without-audio"]; 356 [webView expectControlsManager:NO afterReceivingMessage:@"playing"]; 334 357 } 335 358 … … 339 362 340 363 // An audio element MUST be started with a user gesture in order to have a controls manager, so the expectation is NO. 341 [webView loadTestPageNamed:@"audio-only" andExpectControlsManager:NO afterReceivingMessage:@"playing"]; 364 [webView loadTestPageNamed:@"audio-only"]; 365 [webView expectControlsManager:NO afterReceivingMessage:@"playing"]; 342 366 } 343 367 … … 384 408 RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 1600, 800)); 385 409 386 [webView loadTestPageNamed:@"skinny-autoplaying-video-with-audio" andExpectControlsManager:NO afterReceivingMessage:@"playing"]; 410 [webView loadTestPageNamed:@"skinny-autoplaying-video-with-audio"]; 411 [webView expectControlsManager:NO afterReceivingMessage:@"playing"]; 387 412 } 388 413 … … 391 416 RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 1600, 800)); 392 417 393 [webView loadTestPageNamed:@"full-size-autoplaying-video-with-audio" andExpectControlsManager:YES afterReceivingMessage:@"playing"]; 418 [webView loadTestPageNamed:@"full-size-autoplaying-video-with-audio"]; 419 [webView expectControlsManager:YES afterReceivingMessage:@"playing"]; 420 } 421 422 TEST(VideoControlsManager, VideoControlsManagerVideoMutesOnPlaying) 423 { 424 RetainPtr<VideoControlsManagerTestWebView*> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500)); 425 426 [webView loadTestPageNamed:@"large-video-mutes-onplaying"]; 427 [webView expectControlsManager:NO afterReceivingMessage:@"playing"]; 394 428 } 395 429 -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/autoplaying-video-with-audio.html
r203464 r205417 5 5 var timeout; 6 6 7 function beginTest() {8 timeout = window.setTimeout(stillPlaying, 5000);9 window.addEventListener("mousedown", pauseVideo);10 try {11 window.webkit.messageHandlers.onloadHandler.postMessage('loaded');12 } catch(e) { }13 }14 15 7 function pauseVideo() { 16 document.getElementsByTagName('video')[0].pause(); 17 window.clearTimeout(timeout); 8 document.getElementsByTagName("video")[0].pause(); 18 9 } 19 10 … … 22 13 setTimeout(function() { 23 14 try { 24 window.webkit.messageHandlers.playingHandler.postMessage( 'paused');15 window.webkit.messageHandlers.playingHandler.postMessage("paused"); 25 16 } catch(e) { } 26 17 }, 0); 27 18 } 28 19 29 function stillPlaying() { 30 try { 31 window.webkit.messageHandlers.playingHandler.postMessage('playing'); 32 } catch(e) { } 20 function beganAutoplaying() { 21 setTimeout(function() { 22 try { 23 window.webkit.messageHandlers.playingHandler.postMessage("autoplayed"); 24 } catch(e) { 25 } 26 }, 0) 33 27 } 34 28 35 29 </script> 36 30 </head> 37 <body on load="beginTest()">38 <video controls autoplay src="video-with-audio.mp4" webkit-playsinline onpause="handlePaused()"></video>31 <body onmousedown=pauseVideo()> 32 <video autoplay controls onplaying=beganAutoplaying() src="video-with-audio.mp4" webkit-playsinline onpause=handlePaused()></video> 39 33 </body> 40 34 </html> -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-hides-controls-after-seek-to-end.html
r203690 r205417 24 24 } 25 25 26 function beganAutoplaying() { 27 setTimeout(function() { 28 try { 29 window.webkit.messageHandlers.playingHandler.postMessage("autoplayed"); 30 } catch(e) { 31 } 32 }, 0) 33 } 34 26 35 </script> 27 36 </head> 28 37 <body onmousedown=seekToEnd() onload=beginTest()> 29 <video autoplay on ended=handleEnded() src="large-video-with-audio.mp4" webkit-playsinline style="width: 800px; height: 600px;"></video>38 <video autoplay onplaying=beganAutoplaying() onended=handleEnded() src="large-video-with-audio.mp4" webkit-playsinline style="width: 800px; height: 600px;"></video> 30 39 </body> 31 40 </html> -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-video-playing-scroll-away.html
r205412 r205417 12 12 </style> 13 13 <script> 14 function handleLoaded() {14 function scrollVideoOutOfView() { 15 15 document.querySelector("div").scrollIntoView(); 16 16 setTimeout(function() { … … 18 18 }, 0); 19 19 } 20 21 function beganAutoplaying() { 22 setTimeout(function() { 23 try { 24 window.webkit.messageHandlers.playingHandler.postMessage("autoplayed"); 25 } catch(e) { 26 } 27 }, 0) 28 } 20 29 </script> 21 30 </head> 22 <body onload=handleLoaded()>23 <video autoplay loop id="first" src="large-video-with-audio.mp4"></video>31 <body> 32 <video autoplay onplaying=beganAutoplaying() loop id="first" src="large-video-with-audio.mp4"></video> 24 33 <br> 25 34 <div>hello world!</div> -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-click-to-pause.html
r205412 r205417 30 30 }, 0); 31 31 } 32 33 function beganAutoplaying() { 34 setTimeout(function() { 35 try { 36 window.webkit.messageHandlers.playingHandler.postMessage("autoplayed"); 37 } catch(e) { 38 } 39 }, 0) 40 } 32 41 </script> 33 42 </head> 34 43 <body onmousedown=handleMouseDown()> 35 <video autoplay loop id="first" src="large-video-with-audio.mp4" onpause=handleFirstPause()></video>36 <video autoplay loop id="second" src="large-video-with-audio.mp4" onpause=handleSecondPause()></video>44 <video autoplay onplaying=beganAutoplaying() loop id="first" src="large-video-with-audio.mp4" onpause=handleFirstPause()></video> 45 <video autoplay onplaying=beganAutoplaying() loop id="second" src="large-video-with-audio.mp4" onpause=handleSecondPause()></video> 37 46 </body> 38 47 <html> -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-autoplaying-scroll-to-video.html
r205412 r205417 12 12 </style> 13 13 <script> 14 function handleLoaded() {14 function scrollToSecondView() { 15 15 document.querySelector("#second").scrollIntoView(); 16 16 setTimeout(function() { … … 18 18 }, 0); 19 19 } 20 function beganAutoplaying() { 21 setTimeout(function() { 22 try { 23 window.webkit.messageHandlers.playingHandler.postMessage("autoplayed"); 24 } catch(e) { 25 } 26 }, 0) 27 } 20 28 </script> 21 29 </head> 22 <body onload=handleLoaded()>23 <video autoplay loop id="first" src="large-video-with-audio.mp4"></video>30 <body> 31 <video autoplay onplaying=beganAutoplaying() loop id="first" src="large-video-with-audio.mp4"></video> 24 32 <br> 25 <video autoplay loop id="second" src="large-video-with-audio.mp4"></video>33 <video autoplay onplaying=beganAutoplaying() loop id="second" src="large-video-with-audio.mp4"></video> 26 34 </body> 27 35 <html> -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-paused-video-hides-controls.html
r205412 r205417 11 11 </style> 12 12 <script> 13 function handleLoaded() {13 function pauseFirstVideoAndScrollToSecondVideo() { 14 14 document.querySelector("#bar").scrollIntoView(); 15 15 document.querySelector("#foo").pause(); … … 22 22 }, 0); 23 23 } 24 function beganAutoplaying() { 25 setTimeout(function() { 26 try { 27 window.webkit.messageHandlers.playingHandler.postMessage("autoplayed"); 28 } catch(e) { 29 } 30 }, 0) 31 } 24 32 </script> 25 <body onload=handleLoaded()>26 <video autoplay loop id="foo" onpause=handlePaused()><source src="large-video-with-audio.mp4"></video>33 <body> 34 <video autoplay onplaying=beganAutoplaying() loop id="foo" onpause=handlePaused()><source src="large-video-with-audio.mp4"></video> 27 35 <br> 28 36 <video id="bar"><source src="large-video-with-audio.mp4"></video> -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-muted-video-hides-controls.html
r205412 r205417 11 11 </style> 12 12 <script> 13 function handleLoaded() {13 function muteFirstVideoAndScrollToSecondVideo() { 14 14 document.querySelector("#foo").muted = true; 15 15 document.querySelector("#bar").scrollIntoView(); … … 20 20 }, 0); 21 21 } 22 function beganAutoplaying() { 23 setTimeout(function() { 24 try { 25 window.webkit.messageHandlers.playingHandler.postMessage("autoplayed"); 26 } catch(e) { 27 } 28 }, 0) 29 } 22 30 </script> 23 <body onload=handleLoaded()>24 <video autoplay loop id="foo"><source src="large-video-with-audio.mp4"></video>31 <body> 32 <video autoplay onplaying=beganAutoplaying() loop id="foo"><source src="large-video-with-audio.mp4"></video> 25 33 <br> 26 34 <video id="bar"><source src="large-video-with-audio.mp4"></video> -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-playing-video-keeps-controls.html
r205412 r205417 11 11 </style> 12 12 <script> 13 function handleLoaded() {13 function scrollToSecondVideo() { 14 14 document.querySelector("#bar").scrollIntoView(); 15 15 setTimeout(function() { 16 16 try { 17 window.webkit.messageHandlers.playingHandler.postMessage(" playing");17 window.webkit.messageHandlers.playingHandler.postMessage("scrolled"); 18 18 } catch(e) { } 19 19 }, 0); 20 20 } 21 function beganAutoplaying() { 22 setTimeout(function() { 23 try { 24 window.webkit.messageHandlers.playingHandler.postMessage("autoplayed"); 25 } catch(e) { 26 } 27 }, 0) 28 } 21 29 </script> 22 <body onload=handleLoaded()>23 <video autoplay loop id="foo"><source src="large-video-with-audio.mp4"></video>30 <body> 31 <video autoplay onplaying=beganAutoplaying() loop id="foo"><source src="large-video-with-audio.mp4"></video> 24 32 <br> 25 33 <video id="bar"><source src="large-video-with-audio.mp4"></video> -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/large-videos-with-audio-autoplay.html
r203698 r205417 2 2 <html> 3 3 <script> 4 function handleLoaded() { 5 // The media controls should be updated on the next runloop. 4 function beganAutoplaying() { 6 5 setTimeout(function() { 7 6 try { 8 window.webkit.messageHandlers.onloadHandler.postMessage("loaded"); 9 } catch(e) { } 10 }, 0); 7 window.webkit.messageHandlers.playingHandler.postMessage("autoplayed"); 8 } catch(e) { 9 } 10 }, 0) 11 11 } 12 12 </script> 13 <body onload=handleLoaded()>13 <body> 14 14 <video id="foo" style="width: 480px; height: 320px;"><source src="large-video-with-audio.mp4"></video> 15 <video autoplay id="bar" style="width: 480px; height: 320px;"><source src="large-video-with-audio.mp4"></video>15 <video autoplay onplaying=beganAutoplaying() id="bar" style="width: 480px; height: 320px;"><source src="large-video-with-audio.mp4"></video> 16 16 <video id="baz" style="width: 480px; height: 320px;"><source src="large-video-with-audio.mp4"></video> 17 17 </body>
Note: See TracChangeset
for help on using the changeset viewer.