Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Allow the MediaSource API to be enabled via website policy
https://bugs.webkit.org/show_bug.cgi?id=196429 <rdar://problem/48774333> Reviewed by Tim Horton. Source/WebCore: Add support in DocumentLoader for adjusting page settings using its per-site policies. See WebKit ChangeLog for more detail (in particular, the implementation of applyToDocumentLoader). Test: fast/media/ios/ipad/enable-MediaSource-API-in-modern-compatibility-mode.html * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::applyPoliciesToSettings const): (WebCore::DocumentLoader::attachToFrame): * loader/DocumentLoader.h: Add an enum class for MediaSource policies; while we're at it, make all of these enum values 8 bits wide. (WebCore::DocumentLoader::mediaSourcePolicy const): (WebCore::DocumentLoader::setMediaSourcePolicy): Source/WebKit: Adds support for using WebsitePolicies to determine whether to enable the MediaSource API. * Shared/WebPreferences.yaml: Disengage the mediaSourceEnabled internal preference from the corresponding WebCore setting; to ensure that setting the preference to `true` still results in enabling the MediaSource API, we instead make it such that turning on mediaSourceEnabled causes WebsitePolicies to set its WebsiteMediaSourcePolicy to Enable. In the future, we should deprecate and remove this preference, in favor of simply setting preferred compatibility mode on WKWebpagePreferences. * Shared/WebPreferences.yaml: * Shared/WebsiteMediaSourcePolicy.h: Copied from Source/WebKit/Shared/WebsitePoliciesData.h. * Shared/WebsitePoliciesData.cpp: (WebKit::WebsitePoliciesData::encode const): (WebKit::WebsitePoliciesData::decode): Add plumbing for m_mediaSourcePolicy in the set of website policies. (WebKit::WebsitePoliciesData::applyToDocumentLoader): Update the document loader with the given media source policy. There are two possibilities when applying the set of policies to the document loader; either the document loader is already attached to a Frame, or the document loader is yet to be attached to a Frame. In the first case, we update Frame's settings on the spot, by calling the new applyPoliciesToSettings helper method. In the second scenario, we stash the policy state on DocumentLoader; when the DocumentLoader is attached to a Frame, we'll then update the Frame's settings using DocumentLoader's policy. * Shared/WebsitePoliciesData.h: * UIProcess/API/APIWebsitePolicies.cpp: (API::WebsitePolicies::data): * UIProcess/API/APIWebsitePolicies.h: * UIProcess/API/C/WKPage.cpp: (WKPageSetPageNavigationClient): * UIProcess/Cocoa/NavigationState.mm: (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction): Move code that adjusts website policies after deciding policies for the navigation action from NavigationClient ::decidePolicyForNavigationAction to the completion handler of the policy listener. This allows us to respect default website policies on the web view configuration, even when using the C API to set the navigation client, and also allows us to have a single call site for adjustPoliciesForCompatibilityMode. This also enables our layout tests to opt into modern compatibility mode by default, when specifying modern compatibility mode on webpage preferences. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::decidePolicyForNavigationAction): (WebKit::WebPageProxy::adjustPoliciesForCompatibilityMode): * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: LayoutTests: Add an on-device layout test to ensure that enabling modern compability mode also enables MSE. * TestExpectations: * fast/media/ios/ipad/enable-MediaSource-API-in-modern-compatibility-mode-expected.txt: Added. * fast/media/ios/ipad/enable-MediaSource-API-in-modern-compatibility-mode.html: Added. * platform/ios-simulator/TestExpectations: * platform/ios/TestExpectations: Canonical link: https://commits.webkit.org/211106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244197 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
20 changed files
with
270 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...ests/fast/media/ios/ipad/enable-MediaSource-API-in-modern-compatibility-mode-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
This test verifies that the MediaSource API is enabled when enabling modern compatibility mode. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS 'MediaSource' in window is true | ||
PASS MediaSource.prototype is Object.getPrototypeOf(new MediaSource) | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
15 changes: 15 additions & 0 deletions
15
LayoutTests/fast/media/ios/ipad/enable-MediaSource-API-in-modern-compatibility-mode.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!-- webkit-test-runner [ shouldUseModernCompatibilityMode=true ] --> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<script src="../../../../resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
description("This test verifies that the MediaSource API is enabled when enabling modern compatibility mode."); | ||
shouldBe("'MediaSource' in window", "true"); | ||
shouldBe("MediaSource.prototype", "Object.getPrototypeOf(new MediaSource)"); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (C) 2019 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <wtf/Forward.h> | ||
|
||
namespace WebKit { | ||
|
||
enum class WebsiteMediaSourcePolicy : uint8_t { | ||
Default, | ||
Disable, | ||
Enable | ||
}; | ||
|
||
} // namespace WebKit | ||
|
||
namespace WTF { | ||
|
||
template<> struct EnumTraits<WebKit::WebsiteMediaSourcePolicy> { | ||
using values = EnumValues< | ||
WebKit::WebsiteMediaSourcePolicy, | ||
WebKit::WebsiteMediaSourcePolicy::Default, | ||
WebKit::WebsiteMediaSourcePolicy::Disable, | ||
WebKit::WebsiteMediaSourcePolicy::Enable | ||
>; | ||
}; | ||
|
||
} // namespace WTF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.