[iOS] REGRESSION (r197953): User gesture required to load video in iOS 9-built apps
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Oct 2016 20:17:58 +0000 (20:17 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Oct 2016 20:17:58 +0000 (20:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163244
<rdar://problem/27250015>

Reviewed by Jer Noble.

Source/WebCore:

Adds a new setting to toggle requiring a user gesture to load a video (enabled by default).
Disable this setting for apps built against iOS 9 or earlier.

Tests: media/loadedmetadata-fires-without-user-gesture-when-setRequiresUserGestureToLoadVideo-false.html
       media/require-user-gesture-to-load-video.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): Only require a user gesture to load a video
when Settings::requiresUserGestureToLoadVideo() is true.
* page/Settings.cpp: Enable setting requiresUserGestureToLoadVideo by default.
* page/Settings.in: Add setting, requiresUserGestureToLoadVideo.

Source/WebKit/mac:

Enable or disable the Setting::requiresUserGestureToLoadVideo() in legacy WebKit depending
on the version of iOS SDK that the app was linked against. We require a user gesture to
begin loading a video as of iOS 10.

* WebView/WebView.mm:
(shouldRequireUserGestureToLoadVideo):
(-[WebView _preferencesChanged:]): Modified to pass the WebKit requiresUserGestureToLoadVideo
preference to WebCore.

Source/WebKit2:

Enable or disable the Setting::requiresUserGestureToLoadVideo() in WebKit depending on the
version of iOS SDK that the app was linked against. We require a user gesture to begin
loading a video as of iOS 10.

* Shared/WebPreferencesDefinitions.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(shouldRequireUserGestureToLoadVideo): Added.
(-[WKWebView _initializeWithConfiguration:]): Set the requiresUserGestureToLoadVideo preference.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences): Modified to pass the WebKit requiresUserGestureToLoadVideo
preference to WebCore.

LayoutTests:

Add tests to ensure that Settings::setRequiresUserGestureToLoadVideo() behaves as expected.

* media/loadedmetadata-fires-without-user-gesture-when-setRequiresUserGestureToLoadVideo-false-expected.txt: Added.
* media/loadedmetadata-fires-without-user-gesture-when-setRequiresUserGestureToLoadVideo-false.html: Added.
* media/media-controls.js:
(clickPlayButton): Added.
* media/require-user-gesture-to-load-video-expected.txt: Added.
* media/require-user-gesture-to-load-video.html: Added.
* media/video-controls-transformed.html: Write in terms of clickPlayButton().
* media/video-controls-visible-audio-only.html: Ditto.
* media/video-fullscreeen-only-playback.html: Ditto.
* media/video-play-audio-require-user-gesture.html: Ditto.
* media/video-play-require-user-gesture.html: Ditto.
* media/video-test.js:
(passTest): Added.
* platform/ios-simulator/TestExpectations: Skip test media/require-user-gesture-to-load-video.html as
we need to fix <https://bugs.webkit.org/show_bug.cgi?id=163291> to support tapping the play button on iOS.

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

23 files changed:
LayoutTests/ChangeLog
LayoutTests/media/loadedmetadata-fires-without-user-gesture-when-setRequiresUserGestureToLoadVideo-false-expected.txt [new file with mode: 0644]
LayoutTests/media/loadedmetadata-fires-without-user-gesture-when-setRequiresUserGestureToLoadVideo-false.html [new file with mode: 0644]
LayoutTests/media/media-controls.js
LayoutTests/media/require-user-gesture-to-load-video-expected.txt [new file with mode: 0644]
LayoutTests/media/require-user-gesture-to-load-video.html [new file with mode: 0644]
LayoutTests/media/video-controls-transformed.html
LayoutTests/media/video-controls-visible-audio-only.html
LayoutTests/media/video-fullscreeen-only-playback.html
LayoutTests/media/video-play-audio-require-user-gesture.html
LayoutTests/media/video-play-require-user-gesture.html
LayoutTests/media/video-test.js
LayoutTests/platform/ios-simulator/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/page/Settings.cpp
Source/WebCore/page/Settings.in
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPreferencesDefinitions.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 21a916b..cac91b1 100644 (file)
@@ -1,5 +1,31 @@
 2016-10-11  Daniel Bates  <dabates@apple.com>
 
+        [iOS] REGRESSION (r197953): User gesture required to load video in iOS 9-built apps
+        https://bugs.webkit.org/show_bug.cgi?id=163244
+        <rdar://problem/27250015>
+
+        Reviewed by Jer Noble.
+
+        Add tests to ensure that Settings::setRequiresUserGestureToLoadVideo() behaves as expected.
+
+        * media/loadedmetadata-fires-without-user-gesture-when-setRequiresUserGestureToLoadVideo-false-expected.txt: Added.
+        * media/loadedmetadata-fires-without-user-gesture-when-setRequiresUserGestureToLoadVideo-false.html: Added.
+        * media/media-controls.js:
+        (clickPlayButton): Added.
+        * media/require-user-gesture-to-load-video-expected.txt: Added.
+        * media/require-user-gesture-to-load-video.html: Added.
+        * media/video-controls-transformed.html: Write in terms of clickPlayButton().
+        * media/video-controls-visible-audio-only.html: Ditto.
+        * media/video-fullscreeen-only-playback.html: Ditto.
+        * media/video-play-audio-require-user-gesture.html: Ditto.
+        * media/video-play-require-user-gesture.html: Ditto.
+        * media/video-test.js:
+        (passTest): Added.
+        * platform/ios-simulator/TestExpectations: Skip test media/require-user-gesture-to-load-video.html as
+        we need to fix <https://bugs.webkit.org/show_bug.cgi?id=163291> to support tapping the play button on iOS.
+
+2016-10-11  Daniel Bates  <dabates@apple.com>
+
         [iOS] Sandbox QuickLook previews
         https://bugs.webkit.org/show_bug.cgi?id=163240
         <rdar://problem/25961633>
diff --git a/LayoutTests/media/loadedmetadata-fires-without-user-gesture-when-setRequiresUserGestureToLoadVideo-false-expected.txt b/LayoutTests/media/loadedmetadata-fires-without-user-gesture-when-setRequiresUserGestureToLoadVideo-false-expected.txt
new file mode 100644 (file)
index 0000000..a6925a2
--- /dev/null
@@ -0,0 +1,5 @@
+
+EVENT(loadedmetadata)
+Did load metadata without user gesture OK
+END OF TEST
+
diff --git a/LayoutTests/media/loadedmetadata-fires-without-user-gesture-when-setRequiresUserGestureToLoadVideo-false.html b/LayoutTests/media/loadedmetadata-fires-without-user-gesture-when-setRequiresUserGestureToLoadVideo-false.html
new file mode 100644 (file)
index 0000000..f485fdb
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="media-file.js"></script>
+<script src="video-test.js"></script>
+<script>
+if (window.internals) {
+    internals.settings.setVideoPlaybackRequiresUserGesture(true);
+    internals.settings.setRequiresUserGestureToLoadVideo(false);
+}
+
+function done()
+{
+    passTest("Did load metadata without user gesture");
+}
+
+function start()
+{
+    findMediaElement();
+    waitForEvent("loadedmetadata", done);
+    video.src = findMediaFile("video", "content/test");
+}
+</script>
+</head>
+<body onload="start()">
+    <video id="video"></video>
+</body>
+</html>
index 5ceef1f..a0a3d77 100644 (file)
@@ -92,3 +92,18 @@ function textTrackDisplayElement(parentElement, id, cueNumber)
 
     return displayElement;
 }
+
+// FIXME: Make this work for iOS.
+function clickPlayButton(video)
+{
+    if (!window.eventSender)
+        return;
+
+    var playButtonCoordinates = mediaControlsButtonCoordinates(video, "play-button");
+    var x = playButtonCoordinates[0];
+    var y = playButtonCoordinates[1];
+
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
diff --git a/LayoutTests/media/require-user-gesture-to-load-video-expected.txt b/LayoutTests/media/require-user-gesture-to-load-video-expected.txt
new file mode 100644 (file)
index 0000000..1550c2d
--- /dev/null
@@ -0,0 +1,5 @@
+
+EVENT(loadedmetadata)
+Did load metadata after user gesture. OK
+END OF TEST
+
diff --git a/LayoutTests/media/require-user-gesture-to-load-video.html b/LayoutTests/media/require-user-gesture-to-load-video.html
new file mode 100644 (file)
index 0000000..2fe7702
--- /dev/null
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="media-controls.js"></script>
+<script src="media-file.js"></script>
+<script src="video-test.js"></script>
+<script>
+if (window.internals) {
+    internals.settings.setVideoPlaybackRequiresUserGesture(true);
+    internals.settings.setRequiresUserGestureToLoadVideo(true);
+}
+
+var didUserGesture = false;
+
+function checkDidLoadMetadataAfterUserGesture()
+{
+    if (didUserGesture)
+        passTest("Did load metadata after user gesture.");
+    else
+        failTest("Did load metadata without user gesture");
+}
+
+function performClickOnPlayButton()
+{
+    didUserGesture = true;
+    clickPlayButton(video);
+}
+
+function start()
+{
+    findMediaElement();
+    waitForEvent("loadedmetadata", checkDidLoadMetadataAfterUserGesture);
+    video.src = findMediaFile("video", "content/test");
+
+    window.setTimeout(performClickOnPlayButton, 0);
+}
+</script>
+</head>
+<body onload="start()">
+    <video id="video" controls></video>
+</body>
+</html>
index b25a93f..265db63 100644 (file)
     <script>
         testExpected("video.controls", null, '!=');
         waitForEvent('canplaythrough', function () {
-            if (window.eventSender) {
-                // Find the play button and click the middle of its bounding box.
-                var playCoords;
-                try {
-                    playCoords = mediaControlsButtonCoordinates(video, "play-button");
-                } catch (exception) {
-                    failTest(exception.description);
-                    return;
-                }
-                var clickX = playCoords[0];
-                var clickY = playCoords[1];
-                eventSender.mouseMoveTo(clickX, clickY);
-                eventSender.mouseDown();
-                eventSender.mouseUp();
+            try {
+                clickPlayButton(video);
+            } catch (exception) {
+                failTest(exception.description);
+                return;
             }
             testExpected("video.paused", false);
             endTest();
index a267a38..b2a35ca 100644 (file)
                 if (!window.testRunner)
                     return;
 
-                // start playback
-                var playCoords
                 try {
-                    playCoords = mediaControlsButtonCoordinates(video, "play-button");
+                    clickPlayButton(video);
                 } catch (exception) {
                     consoleWrite(exception.description);
                     testRunner.notifyDone();
                     return;
                 }
-                var clickX = playCoords[0];
-                var clickY = playCoords[1];
-                eventSender.mouseMoveTo(clickX, clickY);
-                eventSender.mouseDown();
-                eventSender.mouseUp();
                 testcondition("!video.paused");
 
                 // move the mouse off of the element
index 920df35..0af0e52 100644 (file)
 
                 consoleWrite("<br>** Clicking \'play\' button...");
 
-                var playCoords;
                 try {
-                    playCoords = mediaControlsButtonCoordinates(video, "play-button");
+                    clickPlayButton(video);
                 } catch (exception) {
                     failTest(exception.description);
                     return;
                 }
-
-                eventSender.mouseMoveTo(playCoords[0], playCoords[1]);
-                eventSender.mouseDown();
-                eventSender.mouseUp();
             }
 
 
index b16fb2a..062472f 100644 (file)
@@ -9,26 +9,6 @@
             if (window.internals) 
                 window.internals.settings.setAudioPlaybackRequiresUserGesture(true);
 
-            function click()
-            {
-                if (window.eventSender) {
-                    var playCoords;
-                    try {
-                        playCoords = mediaControlsButtonCoordinates(video, "play-button");
-                    } catch (exception) {
-                        failTest(exception.description);
-                        return;
-                    }
-                    var x = playCoords[0];
-                    var y = playCoords[1];
-                     
-                    userGestureInitiated = 1;
-                    eventSender.mouseMoveTo(x, y);
-                    eventSender.mouseDown();
-                    eventSender.mouseUp();
-                }
-            }
-
             function playing()
             {
                 if (userGestureInitiated == 0) {
                 consoleWrite("");
 
                 consoleWrite("* User gesture initiated");
-                click();
+                userGestureInitiated = 1;
+                try {
+                    clickPlayButton(video);
+                } catch (exception) {
+                    failTest(exception.description);
+                    return;
+                }
             }
 
             function start()
index f5cf604..a3a2364 100644 (file)
@@ -9,26 +9,6 @@
             if (window.internals) 
                 window.internals.settings.setVideoPlaybackRequiresUserGesture(true);
 
-            function click()
-            {
-                if (window.eventSender) {
-                    var playCoords;
-                    try {
-                        playCoords = mediaControlsButtonCoordinates(video, "play-button");
-                    } catch (exception) {
-                        failTest(exception.description);
-                        return;
-                    }
-                    var x = playCoords[0];
-                    var y = playCoords[1];
-                     
-                    userGestureInitiated = 1;
-                    eventSender.mouseMoveTo(x, y);
-                    eventSender.mouseDown();
-                    eventSender.mouseUp();
-                }
-            }
-
             function playing()
             {
                 if (userGestureInitiated == 0) {
                 consoleWrite("");
 
                 consoleWrite("* User gesture initiated");
-                click();
+                userGestureInitiated = 1;
+                try {
+                    clickPlayButton(video);
+                } catch (exception) {
+                    failTest(exception.description);
+                    return;
+                }
             }
 
             function start()
index 5f2054d..19a7f62 100644 (file)
@@ -4,6 +4,7 @@ var mediaElement = document; // If not set, an event from any element will trigg
 var consoleElement = null;
 var printFullTestDetails = true; // This is optionaly switched of by test whose tested values can differ. (see disableFullTestDetailsPrinting())
 var Failed = false;
+var Success = true;
 
 var track = null; // Current TextTrack being tested.
 var cues = null; // Current TextTrackCueList being tested.
@@ -266,6 +267,11 @@ function failTest(text)
     endTest();
 }
 
+function passTest(text)
+{
+    logResult(Success, text);
+    endTest();
+}
 
 function logResult(success, text)
 {
index 831def7..8c0e2aa 100644 (file)
@@ -2545,7 +2545,6 @@ media/video-controls-fullscreen-volume.html
 media/video-controls-no-display-with-text-track.html
 media/video-controls-show-on-kb-or-ax-event.html
 media/video-fullscreen-restriction-removed.html
-media/video-play-require-user-gesture.html
 media/video-playsinline.html
 media/video-remote-control-playpause.html
 media/video-volume-slider-drag.html
@@ -2626,15 +2625,11 @@ media/video-controls-drop-and-restore-timeline.html [ Failure ]
 media/video-controls-in-media-document.html [ Failure ]
 media/video-controls-no-scripting.html [ Failure ]
 media/video-controls-toggling.html [ Failure ]
-media/video-controls-transformed.html [ Failure ]
-media/video-controls-visible-audio-only.html [ Failure ]
 media/video-controls-visible-exiting-fullscreen.html [ Failure ]
 media/video-controls-zoomed.html [ Failure ]
 media/video-frame-accurate-seek.html [ Failure ]
 media/video-fullscreeen-only-controls.html [ Failure ]
-media/video-fullscreeen-only-playback.html [ Failure ]
 media/video-initially-hidden-volume-slider-up.html [ Failure ]
-media/video-play-audio-require-user-gesture.html [ Failure ]
 media/video-trackmenu-selection.html [ Failure ]
 media/video-volume.html [ Failure ]
 
@@ -2685,3 +2680,12 @@ webkit.org/b/163009 media/modern-media-controls/icon-button/icon-button-active-s
 webkit.org/b/163093 fast/text/variations/advances.html [ Failure ]
 
 webkit.org/b/162647 http/tests/xmlhttprequest/onabort-response-getters.html [ Pass Failure ]
+
+# Media tests cannot tap play button on iOS.
+webkit.org/b/163291 media/require-user-gesture-to-load-video.html
+webkit.org/b/163291 media/video-controls-transformed.html [ Failure ]
+webkit.org/b/163291 media/video-controls-visible-audio-only.html [ Failure ]
+webkit.org/b/163291 media/video-fullscreeen-only-playback.html [ Failure ]
+webkit.org/b/163291 media/video-play-audio-require-user-gesture.html [ Failure ]
+webkit.org/b/163291 media/video-play-require-user-gesture.html
+
index 1369a31..9c2081c 100644 (file)
@@ -1,3 +1,23 @@
+2016-10-11  Daniel Bates  <dabates@apple.com>
+
+        [iOS] REGRESSION (r197953): User gesture required to load video in iOS 9-built apps
+        https://bugs.webkit.org/show_bug.cgi?id=163244
+        <rdar://problem/27250015>
+
+        Reviewed by Jer Noble.
+
+        Adds a new setting to toggle requiring a user gesture to load a video (enabled by default).
+        Disable this setting for apps built against iOS 9 or earlier.
+
+        Tests: media/loadedmetadata-fires-without-user-gesture-when-setRequiresUserGestureToLoadVideo-false.html
+               media/require-user-gesture-to-load-video.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::HTMLMediaElement): Only require a user gesture to load a video
+        when Settings::requiresUserGestureToLoadVideo() is true.
+        * page/Settings.cpp: Enable setting requiresUserGestureToLoadVideo by default.
+        * page/Settings.in: Add setting, requiresUserGestureToLoadVideo.
+
 2016-10-11  Sam Weinig  <sam@webkit.org>
 
         Fix the iOS build.
index f7ee734..c559dc4 100644 (file)
@@ -504,7 +504,8 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum
     if (document.ownerElement() || !document.isMediaDocument()) {
         if (settings && settings->videoPlaybackRequiresUserGesture()) {
             m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureForVideoRateChange);
-            m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureForLoad);
+            if (settings->requiresUserGestureToLoadVideo())
+                m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureForLoad);
         }
 
         if (settings && settings->audioPlaybackRequiresUserGesture())
index 84f6f1f..287f457 100644 (file)
@@ -167,6 +167,8 @@ static const bool defaultMediaControlsScaleWithPageZoom = true;
 static const bool defaultQuickTimePluginReplacementEnabled = false;
 #endif
 
+static const bool defaultRequiresUserGestureToLoadVideo = true;
+
 static const bool defaultAllowsPictureInPictureMediaPlayback = true;
 
 static const double defaultIncrementalRenderingSuppressionTimeoutInSeconds = 5;
index 85fcdf8..9716396 100644 (file)
@@ -127,6 +127,7 @@ shouldInjectUserScriptsInInitialEmptyDocument initial=false
 fixedElementsLayoutRelativeToFrame initial=false
 allowDisplayOfInsecureContent initial=false
 allowRunningOfInsecureContent initial=false
+requiresUserGestureToLoadVideo initial=defaultRequiresUserGestureToLoadVideo
 videoPlaybackRequiresUserGesture initial=defaultVideoPlaybackRequiresUserGesture
 audioPlaybackRequiresUserGesture initial=defaultAudioPlaybackRequiresUserGesture
 mainContentUserGestureOverrideEnabled initial=false
index 7f3d273..9705f6c 100644 (file)
@@ -1,3 +1,20 @@
+2016-10-11  Daniel Bates  <dabates@apple.com>
+
+        [iOS] REGRESSION (r197953): User gesture required to load video in iOS 9-built apps
+        https://bugs.webkit.org/show_bug.cgi?id=163244
+        <rdar://problem/27250015>
+
+        Reviewed by Jer Noble.
+
+        Enable or disable the Setting::requiresUserGestureToLoadVideo() in legacy WebKit depending
+        on the version of iOS SDK that the app was linked against. We require a user gesture to
+        begin loading a video as of iOS 10.
+
+        * WebView/WebView.mm:
+        (shouldRequireUserGestureToLoadVideo):
+        (-[WebView _preferencesChanged:]): Modified to pass the WebKit requiresUserGestureToLoadVideo
+        preference to WebCore.
+
 2016-10-11  Alex Christensen  <achristensen@webkit.org>
 
         Remove dead networking code
index b02690f..d6a576c 100644 (file)
@@ -903,6 +903,12 @@ static bool shouldConvertInvalidURLsToBlank()
     return shouldConvertInvalidURLsToBlank;
 }
 
+static bool shouldRequireUserGestureToLoadVideo()
+{
+    static bool shouldRequireUserGestureToLoadVideo = dyld_get_program_sdk_version() >= DYLD_IOS_VERSION_10_0;
+    return shouldRequireUserGestureToLoadVideo;
+}
+
 #if ENABLE(GAMEPAD)
 static void WebKitInitializeGamepadProviderIfNecessary()
 {
@@ -2370,6 +2376,7 @@ static bool needsSelfRetainWhileLoadingQuirk()
     BOOL mediaPlaybackRequiresUserGesture = [preferences mediaPlaybackRequiresUserGesture];
     settings.setVideoPlaybackRequiresUserGesture(mediaPlaybackRequiresUserGesture || [preferences videoPlaybackRequiresUserGesture]);
     settings.setAudioPlaybackRequiresUserGesture(mediaPlaybackRequiresUserGesture || [preferences audioPlaybackRequiresUserGesture]);
+    settings.setRequiresUserGestureToLoadVideo(shouldRequireUserGestureToLoadVideo());
     settings.setMainContentUserGestureOverrideEnabled([preferences overrideUserGestureRequirementForMainContent]);
     settings.setAllowsInlineMediaPlayback([preferences mediaPlaybackAllowsInline]);
     settings.setAllowsInlineMediaPlaybackAfterFullscreen([preferences allowsInlineMediaPlaybackAfterFullscreen]);
index d77d125..3649101 100644 (file)
@@ -1,3 +1,23 @@
+2016-10-11  Daniel Bates  <dabates@apple.com>
+
+        [iOS] REGRESSION (r197953): User gesture required to load video in iOS 9-built apps
+        https://bugs.webkit.org/show_bug.cgi?id=163244
+        <rdar://problem/27250015>
+
+        Reviewed by Jer Noble.
+
+        Enable or disable the Setting::requiresUserGestureToLoadVideo() in WebKit depending on the
+        version of iOS SDK that the app was linked against. We require a user gesture to begin
+        loading a video as of iOS 10.
+
+        * Shared/WebPreferencesDefinitions.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (shouldRequireUserGestureToLoadVideo): Added.
+        (-[WKWebView _initializeWithConfiguration:]): Set the requiresUserGestureToLoadVideo preference.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences): Modified to pass the WebKit requiresUserGestureToLoadVideo
+        preference to WebCore.
+
 2016-10-11  Alex Christensen  <achristensen@webkit.org>
 
         Remove dead networking code
index ab657db..05ce1cf 100644 (file)
     macro(RequiresUserGestureForMediaPlayback, requiresUserGestureForMediaPlayback, Bool, bool, false, "", "") \
     macro(RequiresUserGestureForVideoPlayback, requiresUserGestureForVideoPlayback, Bool, bool, false, "", "") \
     macro(RequiresUserGestureForAudioPlayback, requiresUserGestureForAudioPlayback, Bool, bool, DEFAULT_REQUIRES_USER_GESTURE_FOR_AUDIO_PLAYBACK, "", "") \
+    macro(RequiresUserGestureToLoadVideo, requiresUserGestureToLoadVideo, Bool, bool, false, "", "") \
     macro(MainContentUserGestureOverrideEnabled, mainContentUserGestureOverrideEnabled, Bool, bool, false, "", "") \
     macro(AllowsInlineMediaPlayback, allowsInlineMediaPlayback, Bool, bool, DEFAULT_ALLOWS_INLINE_MEDIA_PLAYBACK, "", "") \
     macro(AllowsInlineMediaPlaybackAfterFullscreen, allowsInlineMediaPlaybackAfterFullscreen, Bool, bool, DEFAULT_ALLOWS_INLINE_MEDIA_PLAYBACK_AFTER_FULLSCREEN, "", "") \
index 3511203..b436242 100644 (file)
@@ -326,6 +326,12 @@ static bool shouldAllowPictureInPictureMediaPlayback()
 
 #endif
 
+static bool shouldRequireUserGestureToLoadVideo()
+{
+    static bool shouldRequireUserGestureToLoadVideo = dyld_get_program_sdk_version() >= DYLD_IOS_VERSION_10_0;
+    return shouldRequireUserGestureToLoadVideo;
+}
+
 #if ENABLE(DATA_DETECTION) && PLATFORM(IOS)
 static WebCore::DataDetectorTypes fromWKDataDetectorTypes(uint64_t types)
 {
@@ -455,6 +461,7 @@ static uint32_t convertSystemLayoutDirection(NSUserInterfaceLayoutDirection dire
     WKAudiovisualMediaTypes mediaTypesRequiringUserGesture = [_configuration mediaTypesRequiringUserActionForPlayback];
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::requiresUserGestureForVideoPlaybackKey(), WebKit::WebPreferencesStore::Value((mediaTypesRequiringUserGesture & WKAudiovisualMediaTypeVideo) == WKAudiovisualMediaTypeVideo));
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::requiresUserGestureForAudioPlaybackKey(), WebKit::WebPreferencesStore::Value(((mediaTypesRequiringUserGesture & WKAudiovisualMediaTypeAudio) == WKAudiovisualMediaTypeAudio)));
+    pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::requiresUserGestureToLoadVideoKey(), WebKit::WebPreferencesStore::Value(shouldRequireUserGestureToLoadVideo()));
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::mainContentUserGestureOverrideEnabledKey(), WebKit::WebPreferencesStore::Value(!![_configuration _mainContentUserGestureOverrideEnabled]));
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::invisibleAutoplayNotPermittedKey(), WebKit::WebPreferencesStore::Value(!![_configuration _invisibleAutoplayNotPermitted]));
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::mediaDataLoadsAutomaticallyKey(), WebKit::WebPreferencesStore::Value(!![_configuration _mediaDataLoadsAutomatically]));
index 8861618..284b712 100644 (file)
@@ -3021,6 +3021,7 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
     bool requiresUserGestureForMedia = store.getBoolValueForKey(WebPreferencesKey::requiresUserGestureForMediaPlaybackKey());
     settings.setVideoPlaybackRequiresUserGesture(requiresUserGestureForMedia || store.getBoolValueForKey(WebPreferencesKey::requiresUserGestureForVideoPlaybackKey()));
     settings.setAudioPlaybackRequiresUserGesture(requiresUserGestureForMedia || store.getBoolValueForKey(WebPreferencesKey::requiresUserGestureForAudioPlaybackKey()));
+    settings.setRequiresUserGestureToLoadVideo(store.getBoolValueForKey(WebPreferencesKey::requiresUserGestureToLoadVideoKey()));
     settings.setMainContentUserGestureOverrideEnabled(store.getBoolValueForKey(WebPreferencesKey::mainContentUserGestureOverrideEnabledKey()));
     settings.setAllowsInlineMediaPlayback(store.getBoolValueForKey(WebPreferencesKey::allowsInlineMediaPlaybackKey()));
     settings.setAllowsInlineMediaPlaybackAfterFullscreen(store.getBoolValueForKey(WebPreferencesKey::allowsInlineMediaPlaybackAfterFullscreenKey()));