Commit f369a9d6 authored by Jeremy Roman's avatar Jeremy Roman Committed by Commit Bot

Enable Portals same-origin origin trial on Android.

This makes the origin trial functional pending the issuance of tokens.
It includes a test that verifies that the default feature state is
appropriate for this trial, and adjusts those defaults.

Also as a consequence of this, cross-origin portals will now be
disabled by default. They can be re-enabled for development purposes
only via:
  flags: chrome://flags/#enable-portals-cross-origin
or switch:
  --enable-features=PortalsCrossOrigin

Finally, the toggling of these makes our tests a little wonky.
Previously we were forcing the browser-side logic on in response
to experimental web platform features, but some tests rely on
cross-origin portals which probably shouldn't be on for all users
with experimental web platform features. Instead these tests are
moved to a virtual test suite for the time being, consistent with
a number of other unlaunched features.

Bug: 1040212,1093466
Change-Id: I7dd75e0e2053206368d806439eed4b6b918a1a3a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2240057
Auto-Submit: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarCharlie Reis <creis@chromium.org>
Reviewed-by: default avatarLucas Gadani <lfg@chromium.org>
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782003}
parent 40fda92a
...@@ -133,7 +133,9 @@ class PageLoadMetricsBrowserTest : public InProcessBrowserTest { ...@@ -133,7 +133,9 @@ class PageLoadMetricsBrowserTest : public InProcessBrowserTest {
public: public:
PageLoadMetricsBrowserTest() { PageLoadMetricsBrowserTest() {
scoped_feature_list_.InitWithFeatures( scoped_feature_list_.InitWithFeatures(
{ukm::kUkmFeature, blink::features::kPortals}, {}); {ukm::kUkmFeature, blink::features::kPortals,
blink::features::kPortalsCrossOrigin},
{});
} }
~PageLoadMetricsBrowserTest() override {} ~PageLoadMetricsBrowserTest() override {}
......
...@@ -54,7 +54,10 @@ class PortalBrowserTest : public InProcessBrowserTest { ...@@ -54,7 +54,10 @@ class PortalBrowserTest : public InProcessBrowserTest {
PortalBrowserTest() = default; PortalBrowserTest() = default;
void SetUp() override { void SetUp() override {
scoped_feature_list_.InitAndEnableFeature(blink::features::kPortals); scoped_feature_list_.InitWithFeatures(
/*enabled_features=*/{blink::features::kPortals,
blink::features::kPortalsCrossOrigin},
/*disabled_features=*/{});
InProcessBrowserTest::SetUp(); InProcessBrowserTest::SetUp();
} }
......
...@@ -60,9 +60,7 @@ Portal::~Portal() { ...@@ -60,9 +60,7 @@ Portal::~Portal() {
// static // static
bool Portal::IsEnabled() { bool Portal::IsEnabled() {
return base::FeatureList::IsEnabled(blink::features::kPortals) || return base::FeatureList::IsEnabled(blink::features::kPortals);
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableExperimentalWebPlatformFeatures);
} }
// static // static
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/optional.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
...@@ -44,6 +46,7 @@ ...@@ -44,6 +46,7 @@
#include "content/public/test/navigation_handle_observer.h" #include "content/public/test/navigation_handle_observer.h"
#include "content/public/test/render_frame_host_test_support.h" #include "content/public/test/render_frame_host_test_support.h"
#include "content/public/test/test_navigation_observer.h" #include "content/public/test/test_navigation_observer.h"
#include "content/public/test/url_loader_interceptor.h"
#include "content/shell/browser/shell.h" #include "content/shell/browser/shell.h"
#include "content/shell/browser/shell_browser_context.h" #include "content/shell/browser/shell_browser_context.h"
#include "content/shell/browser/shell_content_browser_client.h" #include "content/shell/browser/shell_content_browser_client.h"
...@@ -54,6 +57,7 @@ ...@@ -54,6 +57,7 @@
#include "content/test/test_render_frame_host_factory.h" #include "content/test/test_render_frame_host_factory.h"
#include "net/base/escape.h" #include "net/base/escape.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/base/url_util.h"
#include "net/dns/mock_host_resolver.h" #include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
...@@ -74,7 +78,10 @@ class PortalBrowserTest : public ContentBrowserTest { ...@@ -74,7 +78,10 @@ class PortalBrowserTest : public ContentBrowserTest {
PortalBrowserTest() {} PortalBrowserTest() {}
void SetUp() override { void SetUp() override {
scoped_feature_list_.InitAndEnableFeature(blink::features::kPortals); scoped_feature_list_.InitWithFeatures(
/*enabled_features=*/{blink::features::kPortals,
blink::features::kPortalsCrossOrigin},
/*disabled_features=*/{});
ContentBrowserTest::SetUp(); ContentBrowserTest::SetUp();
} }
...@@ -2120,4 +2127,108 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest, DownloadsBlockedViaDownloadLink) { ...@@ -2120,4 +2127,108 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest, DownloadsBlockedViaDownloadLink) {
EXPECT_FALSE(download_observer.AwaitDownload()); EXPECT_FALSE(download_observer.AwaitDownload());
} }
namespace {
static constexpr struct {
base::StringPiece token_id;
base::StringPiece token;
} kOriginTrialTokens[] = {
// Generated by:
// tools/origin_trials/generate_token.py --version 3 --expire-days 3650 \
// https://portal.test Portals
// Token details:
// Version: 3
// Origin: https://portal.test:443
// Is Subdomain: None
// Is Third Party: None
// Usage Restriction: None
// Feature: Portals
// Expiry: 1907172789 (2030-06-08 18:13:09 UTC)
// Signature (Base64):
// 3nrCPtI01xhkOinmRegbwhnA5VrNBJUnxLv2yPxSKdtUMyoo9iUZszqtkaTFyV8Al/VJigcAOzLLsKOZ2N6DBQ==
{"portals",
"A956wj7SNNcYZDop5kXoG8IZwOVazQSVJ8S79sj8UinbVDMqKPYlGbM6rZGkxclfAJf1SYoHA"
"Dsyy7CjmdjegwUAAABReyJvcmlnaW4iOiAiaHR0cHM6Ly9wb3J0YWwudGVzdDo0NDMiLCAiZm"
"VhdHVyZSI6ICJQb3J0YWxzIiwgImV4cGlyeSI6IDE5MDcxNzI3ODl9"},
};
} // namespace
// Tests that origin trials correctly toggle the feature, and that default
// states are as intended for the same-origin origin trial
// (https://crbug.com/1040212).
//
// That these controls provide suitable safeguards and functionality is tested
// elsewhere.
class PortalOriginTrialBrowserTest : public ContentBrowserTest {
protected:
PortalOriginTrialBrowserTest() = default;
bool PlatformSupportsPortalsOriginTrial() {
#if defined(OS_ANDROID)
return true;
#else
return false;
#endif
}
void SetUp() override {
ContentBrowserTest::SetUp();
EXPECT_EQ(base::FeatureList::IsEnabled(blink::features::kPortals),
PlatformSupportsPortalsOriginTrial());
EXPECT_FALSE(
base::FeatureList::IsEnabled(blink::features::kPortalsCrossOrigin));
}
void SetUpOnMainThread() override {
ContentBrowserTest::SetUpOnMainThread();
url_loader_interceptor_.emplace(
base::BindRepeating(&PortalOriginTrialBrowserTest::InterceptRequest));
}
void TearDownOnMainThread() override { url_loader_interceptor_.reset(); }
// URLLoaderInterceptor callback
static bool InterceptRequest(URLLoaderInterceptor::RequestParams* params) {
// Find the appropriate origin trial token.
base::StringPiece origin_trial_token;
std::string origin_trial_query_param;
if (net::GetValueForKeyInQuery(params->url_request.url, "origintrial",
&origin_trial_query_param)) {
for (const auto& pair : kOriginTrialTokens)
if (pair.token_id == origin_trial_query_param)
origin_trial_token = pair.token;
}
// Construct and send the response.
std::string headers =
"HTTP/1.1 200 OK\nContent-Type: text/html; charset=utf-8\n";
if (!origin_trial_token.empty())
base::StrAppend(&headers, {"Origin-Trial: ", origin_trial_token, "\n"});
headers += '\n';
std::string body = "<!DOCTYPE html><body>Hello world!</body>";
URLLoaderInterceptor::WriteResponse(headers, body, params->client.get());
return true;
}
private:
base::Optional<URLLoaderInterceptor> url_loader_interceptor_;
};
IN_PROC_BROWSER_TEST_F(PortalOriginTrialBrowserTest, WithoutTrialToken) {
WebContentsImpl* web_contents_impl =
static_cast<WebContentsImpl*>(shell()->web_contents());
ASSERT_TRUE(NavigateToURL(web_contents_impl, GURL("https://portal.test/")));
EXPECT_EQ(false, EvalJs(web_contents_impl, "'HTMLPortalElement' in self"));
}
IN_PROC_BROWSER_TEST_F(PortalOriginTrialBrowserTest, WithTrialToken) {
WebContentsImpl* web_contents_impl =
static_cast<WebContentsImpl*>(shell()->web_contents());
ASSERT_TRUE(NavigateToURL(web_contents_impl,
GURL("https://portal.test/?origintrial=portals")));
EXPECT_EQ(PlatformSupportsPortalsOriginTrial(),
EvalJs(web_contents_impl, "'HTMLPortalElement' in self"));
}
} // namespace content } // namespace content
...@@ -102,17 +102,23 @@ const base::Feature kPlzDedicatedWorker{"PlzDedicatedWorker", ...@@ -102,17 +102,23 @@ const base::Feature kPlzDedicatedWorker{"PlzDedicatedWorker",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
// Enable Portals. https://crbug.com/865123. // Enable Portals. https://crbug.com/865123.
const base::Feature kPortals{"Portals", base::FEATURE_DISABLED_BY_DEFAULT}; // For the current origin trial (https://crbug.com/1040212), this is enabled on
// Android only.
const base::Feature kPortals {
"Portals",
#if defined(OS_ANDROID)
base::FEATURE_ENABLED_BY_DEFAULT
#else
base::FEATURE_DISABLED_BY_DEFAULT
#endif
};
// When kPortals is enabled, allow portals to load content that is third-party // When kPortals is enabled, allow portals to load content that is third-party
// (cross-origin) to the hosting page. Otherwise has no effect. // (cross-origin) to the hosting page. Otherwise has no effect.
// //
// This will be disabled by default by the time Portals is generally available,
// either in origin trial or shipped.
//
// https://crbug.com/1013389 // https://crbug.com/1013389
const base::Feature kPortalsCrossOrigin{"PortalsCrossOrigin", const base::Feature kPortalsCrossOrigin{"PortalsCrossOrigin",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
// Enable limiting previews loading hints to specific resource types. // Enable limiting previews loading hints to specific resource types.
const base::Feature kPreviewsResourceLoadingHintsSpecificResourceTypes{ const base::Feature kPreviewsResourceLoadingHintsSpecificResourceTypes{
......
...@@ -145,6 +145,21 @@ virtual/composite-after-paint/paint/frames/* [ Pass ] ...@@ -145,6 +145,21 @@ virtual/composite-after-paint/paint/frames/* [ Pass ]
virtual/composite-after-paint/scrollingcoordinator/* [ Pass ] virtual/composite-after-paint/scrollingcoordinator/* [ Pass ]
# --- End CompositeAfterPaint Tests -- # --- End CompositeAfterPaint Tests --
# These tests require portals, and some require cross-origin portals.
# Keep this in sync with VirtualTestSuites.
crbug.com/1093466 external/wpt/fetch/metadata/portal.https.sub.html [ Skip ]
crbug.com/1093466 external/wpt/portals/* [ Skip ]
crbug.com/1093466 http/tests/devtools/portals/* [ Skip ]
crbug.com/1093466 http/tests/inspector-protocol/portals/* [ Skip ]
crbug.com/1093466 http/tests/portals/* [ Skip ]
crbug.com/1093466 wpt_internal/portals/* [ Skip ]
crbug.com/1093466 virtual/portals/external/wpt/fetch/metadata/portal.https.sub.html [ Pass ]
crbug.com/1093466 virtual/portals/external/wpt/portals/* [ Pass ]
crbug.com/1093466 virtual/portals/http/tests/devtools/portals/* [ Pass ]
crbug.com/1093466 virtual/portals/http/tests/inspector-protocol/portals/* [ Pass ]
crbug.com/1093466 virtual/portals/http/tests/portals/* [ Pass ]
crbug.com/1093466 virtual/portals/wpt_internal/portals/* [ Pass ]
# Subpixel differences # Subpixel differences
crbug.com/771643 external/wpt/css/css-backgrounds/background-attachment-local/attachment-local-clipping-color-5.html [ Failure ] crbug.com/771643 external/wpt/css/css-backgrounds/background-attachment-local/attachment-local-clipping-color-5.html [ Failure ]
crbug.com/771643 external/wpt/css/css-backgrounds/background-attachment-local/attachment-local-clipping-image-5.html [ Failure ] crbug.com/771643 external/wpt/css/css-backgrounds/background-attachment-local/attachment-local-clipping-image-5.html [ Failure ]
...@@ -5765,7 +5780,7 @@ crbug.com/952708 external/wpt/css/css-paint-api/parse-input-arguments-018.https. ...@@ -5765,7 +5780,7 @@ crbug.com/952708 external/wpt/css/css-paint-api/parse-input-arguments-018.https.
# portals/csp/frame-src.sub.html crashes because of a race between cancelling a # portals/csp/frame-src.sub.html crashes because of a race between cancelling a
# speculative navigation in the browser, and committing the navigation in the # speculative navigation in the browser, and committing the navigation in the
# renderer. # renderer.
crbug.com/838348 external/wpt/portals/csp/frame-src.sub.html [ Pass Crash ] crbug.com/838348 virtual/portals/external/wpt/portals/csp/frame-src.sub.html [ Pass Crash ]
# Sheriff 2019-04-17 # Sheriff 2019-04-17
crbug.com/953591 [ Win ] css3/masking/mask-repeat-space-padding.html [ Pass Failure ] crbug.com/953591 [ Win ] css3/masking/mask-repeat-space-padding.html [ Pass Failure ]
...@@ -6223,7 +6238,7 @@ crbug.com/1006759 inspector-protocol/heap-profiler/heap-snapshot-with-no-detache ...@@ -6223,7 +6238,7 @@ crbug.com/1006759 inspector-protocol/heap-profiler/heap-snapshot-with-no-detache
# Sheriff 2019-12-13 # Sheriff 2019-12-13
crbug.com/1032451 [ Win7 ] virtual/webrtc-wpt-plan-b/external/wpt/webrtc/idlharness.https.window.html [ Failure Pass ] crbug.com/1032451 [ Win7 ] virtual/webrtc-wpt-plan-b/external/wpt/webrtc/idlharness.https.window.html [ Failure Pass ]
crbug.com/1033852 [ Win7 ] virtual/omt-worker-fetch/external/wpt/fetch/api/idlharness.any.sharedworker.html [ Failure ] crbug.com/1033852 [ Win7 ] virtual/omt-worker-fetch/external/wpt/fetch/api/idlharness.any.sharedworker.html [ Failure ]
crbug.com/1033387 [ Mac ] http/tests/portals/crbug-1031677.html [ Pass Timeout Crash ] crbug.com/1033387 [ Mac ] virtual/portals/http/tests/portals/crbug-1031677.html [ Pass Timeout Crash ]
# Sheriff 2019-12-16 # Sheriff 2019-12-16
crbug.com/1034374 http/tests/devtools/tracing/timeline-worker-events.js [ Pass Failure ] crbug.com/1034374 http/tests/devtools/tracing/timeline-worker-events.js [ Pass Failure ]
......
...@@ -811,5 +811,15 @@ ...@@ -811,5 +811,15 @@
"prefix": "transform-interop", "prefix": "transform-interop",
"bases": [ "external/wpt/css/css-transforms" ], "bases": [ "external/wpt/css/css-transforms" ],
"args": [ "--enable-features=TransformInterop" ] "args": [ "--enable-features=TransformInterop" ]
},
{
"prefix": "portals",
"bases": [ "external/wpt/fetch/metadata/portal.https.sub.html",
"external/wpt/portals",
"http/tests/devtools/portals",
"http/tests/inspector-protocol/portals",
"http/tests/portals",
"wpt_internal/portals" ],
"args": [ "--enable-features=Portals,PortalsCrossOrigin" ]
} }
] ]
Tests run with portals and cross-origin portals enabled. See crbug.com/1093466.
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