Commit 8cbef17e authored by Mason Freed's avatar Mason Freed Committed by Commit Bot

Disable the HTML Imports API

```yaml
IN CASE OF PROBLEMS: If this CL causes your site/app to break, you are
using deprecated features that have now been removed. Please see [2] to
enroll in the Deprecation Extension program to give yourself more time.
```

With this CL, the HTML Imports Web Components v0 API is disabled by
default. The other two Web Components v0 APIs were already disabled
by another CL ([4]).

These features were deprecated in August, 2018, in [1]. The original
removal timeline called for a deadline of M73. Due to high use counters
for the features, this deadline was extended to M80, which is now here.
For those sites that need additional time, there is a "deprecation
extension" (sometimes called a "reverse origin trial") that can be used
to extend this removal for specific sites through M87. For more
information on that, see [2]. For overall context on this removal,
including motivation and ways to test/upgrade, see [3].

With this CL, these features will still be enabled for testing across
all test suites. Once this CL has had a chance to land and stabilize,
subsequent CLs will disable the features for all tests by default, and
enable a virtual test suite to continue testing specific code with WCv0
features enabled, to ensure the features continue to function through
the end of the deprecation extension period.

Note that this CL re-enables all three Web Components v0 APIs on Android
Webview, due to lingering issues with origin trial support. See
crbug.com/1021631 for more information. See https://crbug.com/1020737
for why all three APIs are being re-enabled.

[1] https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/h-JwMiPUnuU/sl79aLoLBQAJ
[2] https://developers.chrome.com/origintrials/#/view_trial/2431943798780067841
[3] https://developers.google.com/web/updates/2019/07/web-components-time-to-upgrade
[4] https://chromium.googlesource.com/chromium/src/+/f52dff0d3c5bc52ba608920f843162832f2da6b1

Bug: 911943, 1021631, 1020737
Change-Id: I0df0898674cfec7c0db50ada9900a9a4027eb226
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1869562
Commit-Queue: Mason Freed <masonfreed@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarDarin Fisher <darin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713537}
parent 2c5d73b6
......@@ -45,6 +45,7 @@ void PopulateFixedWebPreferences(WebPreferences* web_prefs) {
web_prefs->picture_in_picture_enabled = false;
web_prefs->disable_features_depending_on_viz = true;
web_prefs->disable_accelerated_small_canvases = true;
web_prefs->reenable_web_components_v0 = true;
}
const void* const kAwSettingsUserDataKey = &kAwSettingsUserDataKey;
......
......@@ -3123,6 +3123,35 @@ public class AwSettingsTest {
Assert.assertEquals(expectedTitle, actualTitle);
}
@Test
@SmallTest
@Feature({"AndroidWebView", "Preferences"})
public void testWebComponentsV0Reenabled() throws Throwable {
// TODO(1021631): This test should be removed once Android Webview
// disables Web Components v0 by default.
final TestAwContentsClient client = new TestAwContentsClient();
final AwTestContainerView view =
mActivityTestRule.createAwTestContainerViewOnMainSync(client);
final AwContents awContents = view.getAwContents();
CallbackHelper onPageFinishedHelper = client.getOnPageFinishedHelper();
AwActivityTestRule.enableJavaScriptOnUiThread(awContents);
final String expectedTitle = "enabled"; // https://crbug.com/1021631
final String page = "<!doctype html>"
+ "<script>"
+ "const htmlImportsEnabled = 'import' in document.createElement('link');"
+ "const customElementsV0Enabled = 'registerElement' in document;"
+ "const shadowDomV0Enabled = 'createShadowRoot' in document.createElement('div');"
+ "if (htmlImportsEnabled && customElementsV0Enabled && shadowDomV0Enabled) {"
+ " document.title = 'enabled';"
+ "} else {"
+ " document.title = 'disabled';"
+ "}"
+ "</script>";
mActivityTestRule.loadDataSync(awContents, onPageFinishedHelper, page, "text/html", false);
String actualTitle = mActivityTestRule.getTitleOnUiThread(awContents);
Assert.assertEquals(expectedTitle, actualTitle);
}
private static class SelectionRangeTestDependencyFactory extends TestDependencyFactory {
private boolean mDoNotUpdate;
public SelectionRangeTestDependencyFactory(boolean doNotUpdate) {
......
......@@ -68,6 +68,7 @@
"js/volume.js"
]
},
"content_security_policy": "default-src 'none'; script-src 'self' chrome://resources; style-src 'unsafe-inline' chrome://resources;"
// connect-src for Polymer: crbug.com/1022018
"content_security_policy": "default-src 'none'; script-src 'self' chrome://resources; style-src 'unsafe-inline' chrome://resources; connect-src chrome://resources"
}
}
......@@ -234,6 +234,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::WebPreferences)
IPC_STRUCT_TRAITS_MEMBER(scroll_top_left_interop_enabled)
IPC_STRUCT_TRAITS_MEMBER(disable_features_depending_on_viz)
IPC_STRUCT_TRAITS_MEMBER(disable_accelerated_small_canvases)
IPC_STRUCT_TRAITS_MEMBER(reenable_web_components_v0)
#endif // defined(OS_ANDROID)
IPC_STRUCT_TRAITS_MEMBER(force_dark_mode_enabled)
IPC_STRUCT_TRAITS_MEMBER(default_minimum_page_scale_factor)
......
......@@ -207,6 +207,7 @@ WebPreferences::WebPreferences()
scroll_top_left_interop_enabled(true),
disable_features_depending_on_viz(false),
disable_accelerated_small_canvases(false),
reenable_web_components_v0(false),
#endif // defined(OS_ANDROID)
#if defined(OS_ANDROID)
default_minimum_page_scale_factor(0.25f),
......
......@@ -280,6 +280,9 @@ struct CONTENT_EXPORT WebPreferences {
bool disable_features_depending_on_viz;
// Don't accelerate small canvases to avoid crashes TODO(crbug.com/1004304)
bool disable_accelerated_small_canvases;
// Re-enable Web Components v0 on Webview, temporarily. This should get
// removed when crbug.com/1021631 gets fixed.
bool reenable_web_components_v0;
#endif // defined(OS_ANDROID)
// Enable forcibly modifying content rendering to result in a light on dark
......
......@@ -860,6 +860,11 @@ void RenderView::ApplyWebPreferences(const WebPreferences& prefs,
!prefs.disable_features_depending_on_viz);
WebRuntimeFeatures::EnableAcceleratedSmallCanvases(
!prefs.disable_accelerated_small_canvases);
if (prefs.reenable_web_components_v0) {
WebRuntimeFeatures::EnableShadowDOMV0(true);
WebRuntimeFeatures::EnableCustomElementsV0(true);
WebRuntimeFeatures::EnableHTMLImports(true);
}
#endif // defined(OS_ANDROID)
settings->SetForceDarkModeEnabled(prefs.force_dark_mode_enabled);
......
......@@ -773,12 +773,12 @@
origin_trial_feature_name: "HrefTranslate",
status: "experimental",
},
// TODO(911943): HTML Imports is temporarily being left enabled after
// the planned removal milestone of M80.
// TODO(937746): Web Components v0 is disabled by default, and will be
// removed after M87.
{
name: "HTMLImports",
origin_trial_feature_name: "WebComponentsV0",
status: "stable",
status: "test",
},
{
name: "IDBObserver",
......
......@@ -700,7 +700,6 @@ html element link
property hreflang
property imageSizes
property imageSrcset
property import
property integrity
property media
property referrerPolicy
......
......@@ -2842,7 +2842,6 @@ interface HTMLLinkElement : HTMLElement
getter hreflang
getter imageSizes
getter imageSrcset
getter import
getter integrity
getter media
getter referrerPolicy
......
......@@ -357,6 +357,7 @@ crbug.com/1009838 [ mac ] system_health.memory_desktop/browse:tools:maps:2019 [
crbug.com/1008001 [ win ] system_health.memory_desktop/browse:tools:sheets:2019 [ Skip ]
crbug.com/1017290 [ linux ] system_health.memory_desktop/browse:search:google_india:2018 [ Skip ]
crbug.com/1017244 [ desktop ] system_health.memory_desktop/browse_accessibility:media:youtube [ Skip ]
crbug.com/1017346 [ desktop ] system_health.memory_desktop/browse:media:youtube:2019 [ Skip ]
# Benchmark: system_health.memory_mobile
crbug.com/1013317 [ android ] system_health.memory_mobile/load:news:nytimes [ Skip ]
......
......@@ -68,7 +68,8 @@ class ToolbarController {
* @const
*/
this.deleteCommand_ = assertInstanceof(
queryRequiredElement('#delete', assert(this.toolbar_.ownerDocument)),
queryRequiredElement(
'#delete', assert(this.toolbar_.ownerDocument.body)),
cr.ui.Command);
/**
......@@ -76,7 +77,8 @@ class ToolbarController {
* @const
*/
this.refreshCommand_ = assertInstanceof(
queryRequiredElement('#refresh', assert(this.toolbar_.ownerDocument)),
queryRequiredElement(
'#refresh', assert(this.toolbar_.ownerDocument.body)),
cr.ui.Command);
/**
......@@ -85,7 +87,7 @@ class ToolbarController {
*/
this.newFolderCommand_ = assertInstanceof(
queryRequiredElement(
'#new-folder', assert(this.toolbar_.ownerDocument)),
'#new-folder', assert(this.toolbar_.ownerDocument.body)),
cr.ui.Command);
/**
......
......@@ -177,8 +177,10 @@ testcase.zipFileOpenDownloadsEncryptedCancelPassphrase = async () => {
const passphraseCloseScript = `
function clickClose() {
HTMLImports.whenReady(() => {
let dialog = document.querySelector("passphrase-dialog");
dialog.shadowRoot.querySelector("#cancelButton").click();
});
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", clickClose);
......
......@@ -74,7 +74,7 @@ cr.define('cr.ui', function() {
}
if (typeof command == 'string' && command[0] == '#') {
command = assert(this.ownerDocument.getElementById(command.slice(1)));
command = assert(this.ownerDocument.body.querySelector(command));
cr.ui.decorate(command, Command);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment