- Revision
- 226150
- Author
- [email protected]
- Date
- 2017-12-19 15:16:09 -0800 (Tue, 19 Dec 2017)
Log Message
Playing media elements which call "pause(); play()" will have the play promise rejected.
https://bugs.webkit.org/show_bug.cgi?id=180781
<rdar://problem/33191377>
Reviewed by Eric Carlson.
Source/WebCore:
Follow-up to address failing iOS API tests. Rather than skipping the call to
prepareForLoad() in the case where media elements are not allowed to load data,
unconditionally call prepareForLoad(), but conditionally call selectMediaResource() inside
that function only if the media elemnet is allowed to load. This ensures that the
MediaPlayer is created when play(), pause(), or load() are called during a user gesture
later, and selectMediaResource() (which depends on having a non-null m_player) is called.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::parseAttribute):
(WebCore::HTMLMediaElement::insertedIntoAncestor):
(WebCore::HTMLMediaElement::load):
(WebCore::HTMLMediaElement::prepareForLoad):
(WebCore::HTMLMediaElement::playInternal):
Source/WebKit:
shouldRequireUserGestureToLoadVideo() should default to false on Mac.
* UIProcess/API/Cocoa/WKWebView.mm:
(shouldRequireUserGestureToLoadVideo):
Source/WebKitLegacy/mac:
shouldRequireUserGestureToLoadVideo() should default to false on Mac.
* WebView/WebView.mm:
(shouldRequireUserGestureToLoadVideo):
LayoutTests:
* media/video-load-require-user-gesture.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (226149 => 226150)
--- trunk/LayoutTests/ChangeLog 2017-12-19 23:13:05 UTC (rev 226149)
+++ trunk/LayoutTests/ChangeLog 2017-12-19 23:16:09 UTC (rev 226150)
@@ -1,3 +1,13 @@
+2017-12-19 Jer Noble <[email protected]>
+
+ Playing media elements which call "pause(); play()" will have the play promise rejected.
+ https://bugs.webkit.org/show_bug.cgi?id=180781
+ <rdar://problem/33191377>
+
+ Reviewed by Eric Carlson.
+
+ * media/video-load-require-user-gesture.html:
+
2017-12-19 Chris Dumez <[email protected]>
scopeURL should start with the provided scriptURL
Modified: trunk/LayoutTests/media/video-load-require-user-gesture.html (226149 => 226150)
--- trunk/LayoutTests/media/video-load-require-user-gesture.html 2017-12-19 23:13:05 UTC (rev 226149)
+++ trunk/LayoutTests/media/video-load-require-user-gesture.html 2017-12-19 23:16:09 UTC (rev 226150)
@@ -6,8 +6,10 @@
var state = 0;
var userGestureInitiated = 0;
- if (window.internals)
+ if (window.internals) {
window.internals.settings.setVideoPlaybackRequiresUserGesture(true);
+ window.internals.settings.setRequiresUserGestureToLoadVideo(true);
+ }
function finishTest(success)
{
Modified: trunk/Source/WebCore/ChangeLog (226149 => 226150)
--- trunk/Source/WebCore/ChangeLog 2017-12-19 23:13:05 UTC (rev 226149)
+++ trunk/Source/WebCore/ChangeLog 2017-12-19 23:16:09 UTC (rev 226150)
@@ -1,3 +1,25 @@
+2017-12-19 Jer Noble <[email protected]>
+
+ Playing media elements which call "pause(); play()" will have the play promise rejected.
+ https://bugs.webkit.org/show_bug.cgi?id=180781
+ <rdar://problem/33191377>
+
+ Reviewed by Eric Carlson.
+
+ Follow-up to address failing iOS API tests. Rather than skipping the call to
+ prepareForLoad() in the case where media elements are not allowed to load data,
+ unconditionally call prepareForLoad(), but conditionally call selectMediaResource() inside
+ that function only if the media elemnet is allowed to load. This ensures that the
+ MediaPlayer is created when play(), pause(), or load() are called during a user gesture
+ later, and selectMediaResource() (which depends on having a non-null m_player) is called.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::parseAttribute):
+ (WebCore::HTMLMediaElement::insertedIntoAncestor):
+ (WebCore::HTMLMediaElement::load):
+ (WebCore::HTMLMediaElement::prepareForLoad):
+ (WebCore::HTMLMediaElement::playInternal):
+
2017-12-19 Timothy Hatcher <[email protected]>
Build failure in WebGL2 when Video feature is disabled
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (226149 => 226150)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2017-12-19 23:13:05 UTC (rev 226149)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2017-12-19 23:16:09 UTC (rev 226150)
@@ -835,13 +835,7 @@
// If a src attribute of a media element is set or changed, the user
// agent must invoke the media element's media element load algorithm.
-#if PLATFORM(IOS)
- // Note, unless the restriction on requiring user action has been removed,
- // do not begin downloading data on iOS.
- if (!value.isNull() && m_mediaSession->dataLoadingPermitted(*this))
-#else
if (!value.isNull())
-#endif
prepareForLoad();
} else if (name == controlsAttr)
configureMediaControls();
@@ -918,11 +912,7 @@
if (insertionType.connectedToDocument) {
m_inActiveDocument = true;
-#if PLATFORM(IOS)
- if (m_networkState == NETWORK_EMPTY && !attributeWithoutSynchronization(srcAttr).isEmpty() && m_mediaSession->dataLoadingPermitted(*this))
-#else
if (m_networkState == NETWORK_EMPTY && !attributeWithoutSynchronization(srcAttr).isEmpty())
-#endif
prepareForLoad();
}
@@ -1232,8 +1222,6 @@
INFO_LOG(LOGIDENTIFIER);
- if (!m_mediaSession->dataLoadingPermitted(*this))
- return;
if (processingUserGestureForMedia())
removeBehaviorsRestrictionsAfterFirstUserGesture();
@@ -1342,7 +1330,10 @@
mediaSession().clientWillBeginAutoplaying();
// 9 - Invoke the media element's resource selection algorithm.
- selectMediaResource();
+ // Note, unless the restriction on requiring user action has been removed,
+ // do not begin downloading data.
+ if (m_mediaSession->dataLoadingPermitted(*this))
+ selectMediaResource();
// 10 - Note: Playback of any previously playing media resource for this element stops.
@@ -3451,7 +3442,7 @@
if (!m_mediaSession->clientWillBeginPlayback()) {
ALWAYS_LOG(LOGIDENTIFIER, " returning because of interruption");
- return; // Treat as success because we will begin playback on cessation of the interruption.
+ return;
}
// 4.8.10.9. Playing the media resource
Modified: trunk/Source/WebCore/page/SettingsDefaultValues.h (226149 => 226150)
--- trunk/Source/WebCore/page/SettingsDefaultValues.h 2017-12-19 23:13:05 UTC (rev 226149)
+++ trunk/Source/WebCore/page/SettingsDefaultValues.h 2017-12-19 23:16:09 UTC (rev 226150)
@@ -70,6 +70,7 @@
static const bool defaultScrollingTreeIncludesFrames = true;
static const bool defaultMediaControlsScaleWithPageZoom = true;
static const bool defaultQuickTimePluginReplacementEnabled = true;
+static const bool defaultRequiresUserGestureToLoadVideo = true;
#else
static const bool defaultFixedBackgroundsPaintRelativeToDocument = false;
static const bool defaultAcceleratedCompositingForFixedPositionEnabled = false;
@@ -83,9 +84,9 @@
static const bool defaultScrollingTreeIncludesFrames = false;
static const bool defaultMediaControlsScaleWithPageZoom = true;
static const bool defaultQuickTimePluginReplacementEnabled = false;
+static const bool defaultRequiresUserGestureToLoadVideo = false;
#endif
-static const bool defaultRequiresUserGestureToLoadVideo = true;
static const bool defaultAllowsPictureInPictureMediaPlayback = true;
static const double defaultIncrementalRenderingSuppressionTimeoutInSeconds = 5;
Modified: trunk/Source/WebKit/ChangeLog (226149 => 226150)
--- trunk/Source/WebKit/ChangeLog 2017-12-19 23:13:05 UTC (rev 226149)
+++ trunk/Source/WebKit/ChangeLog 2017-12-19 23:16:09 UTC (rev 226150)
@@ -1,3 +1,16 @@
+2017-12-19 Jer Noble <[email protected]>
+
+ Playing media elements which call "pause(); play()" will have the play promise rejected.
+ https://bugs.webkit.org/show_bug.cgi?id=180781
+ <rdar://problem/33191377>
+
+ Reviewed by Eric Carlson.
+
+ shouldRequireUserGestureToLoadVideo() should default to false on Mac.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (shouldRequireUserGestureToLoadVideo):
+
2017-12-19 Chris Dumez <[email protected]>
Handle Fetch should wait for the service worker's state to become activated
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (226149 => 226150)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2017-12-19 23:13:05 UTC (rev 226149)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2017-12-19 23:16:09 UTC (rev 226150)
@@ -430,7 +430,7 @@
static bool shouldRequireUserGestureToLoadVideo = dyld_get_program_sdk_version() >= DYLD_IOS_VERSION_10_0;
return shouldRequireUserGestureToLoadVideo;
#else
- return true;
+ return false;
#endif
}
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (226149 => 226150)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2017-12-19 23:13:05 UTC (rev 226149)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2017-12-19 23:16:09 UTC (rev 226150)
@@ -1,3 +1,16 @@
+2017-12-19 Jer Noble <[email protected]>
+
+ Playing media elements which call "pause(); play()" will have the play promise rejected.
+ https://bugs.webkit.org/show_bug.cgi?id=180781
+ <rdar://problem/33191377>
+
+ Reviewed by Eric Carlson.
+
+ shouldRequireUserGestureToLoadVideo() should default to false on Mac.
+
+ * WebView/WebView.mm:
+ (shouldRequireUserGestureToLoadVideo):
+
2017-12-19 Wenson Hsieh <[email protected]>
API test WKAttachmentTests.InsertPastedAttributedStringContainingMultipleAttachments is failing on El Capitan and Sierra
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (226149 => 226150)
--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2017-12-19 23:13:05 UTC (rev 226149)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2017-12-19 23:16:09 UTC (rev 226150)
@@ -1310,7 +1310,7 @@
static bool shouldRequireUserGestureToLoadVideo = dyld_get_program_sdk_version() >= DYLD_IOS_VERSION_10_0;
return shouldRequireUserGestureToLoadVideo;
#else
- return true;
+ return false;
#endif
}