Commit 3cfbfbc2 authored by Findit's avatar Findit

Revert "Portals: Restrict portal navigations to HTTP family."

This reverts commit 69ec73d0.

Reason for revert:

Findit (https://goo.gl/kROfz5) identified CL at revision 660918 as the
culprit for flakes in the build cycles as shown on:
https://analysis.chromium.org/p/chromium/flake-portal/analysis/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyQwsSDEZsYWtlQ3VscHJpdCIxY2hyb21pdW0vNjllYzczZDBmYWJjZTViMzM5YjBiMTI1ZmM2MGY2NzIyZTdlOTU4ZAw

Sample Failed Build: https://ci.chromium.org/buildbot/chromium.memory/Linux%20ChromiumOS%20MSan%20Tests/12979

Sample Failed Step: viz_content_browsertests

Sample Flaky Test: PortalBrowserTest.NavigateToChrome

Original change's description:
> Portals: Restrict portal navigations to HTTP family.
> 
> This is also enforced with a renderer kill in case the browser receives
> a non-HTTP navigation request.
> 
> Bug: 962500
> Change-Id: Id7c122ba80ef1cc00620d07d5ecdb1f268b04d79
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1615499
> Commit-Queue: Lucas Gadani <lfg@chromium.org>
> Reviewed-by: Charlie Reis <creis@chromium.org>
> Reviewed-by: Jeremy Roman <jbroman@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#660918}


Change-Id: I3322c1b1721eca98d08ce9b39f2363cf23b424b5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 962500
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1618315
Cr-Commit-Position: refs/heads/master@{#661127}
parent a7de7515
...@@ -163,15 +163,6 @@ RenderFrameProxyHost* Portal::CreateProxyAndAttachPortal() { ...@@ -163,15 +163,6 @@ RenderFrameProxyHost* Portal::CreateProxyAndAttachPortal() {
} }
void Portal::Navigate(const GURL& url) { void Portal::Navigate(const GURL& url) {
if (!url.SchemeIsHTTPOrHTTPS()) {
mojo::ReportBadMessage("Portal::Navigate tried to use non-HTTP protocol.");
binding_->Close(); // Also deletes |this|.
return;
}
// TODO(lfg): Investigate which other restrictions we might need when
// navigating portals. See http://crbug.com/964395.
NavigationController::LoadURLParams load_url_params(url); NavigationController::LoadURLParams load_url_params(url);
portal_contents_impl_->GetController().LoadURLWithParams(load_url_params); portal_contents_impl_->GetController().LoadURLWithParams(load_url_params);
} }
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "content/public/test/hit_test_region_observer.h" #include "content/public/test/hit_test_region_observer.h"
#include "content/public/test/test_navigation_observer.h" #include "content/public/test/test_navigation_observer.h"
#include "content/shell/browser/shell.h" #include "content/shell/browser/shell.h"
#include "content/test/content_browser_test_utils_internal.h"
#include "mojo/public/cpp/bindings/strong_associated_binding.h" #include "mojo/public/cpp/bindings/strong_associated_binding.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"
...@@ -60,15 +59,6 @@ class PortalInterceptorForTesting final ...@@ -60,15 +59,6 @@ class PortalInterceptorForTesting final
portal_->Activate(std::move(data), std::move(callback)); portal_->Activate(std::move(data), std::move(callback));
} }
void Navigate(const GURL& url) override {
if (navigate_callback_) {
navigate_callback_.Run(url);
return;
}
portal_->Navigate(url);
}
void WaitForActivate() { void WaitForActivate() {
if (portal_activated_) if (portal_activated_)
return; return;
...@@ -82,9 +72,6 @@ class PortalInterceptorForTesting final ...@@ -82,9 +72,6 @@ class PortalInterceptorForTesting final
content::Portal* GetPortal() { return portal_.get(); } content::Portal* GetPortal() { return portal_.get(); }
WebContents* GetPortalContents() { return portal_->GetPortalContents(); } WebContents* GetPortalContents() { return portal_->GetPortalContents(); }
// IPC callbacks
base::RepeatingCallback<void(const GURL&)> navigate_callback_;
private: private:
PortalInterceptorForTesting(RenderFrameHostImpl* render_frame_host_impl) PortalInterceptorForTesting(RenderFrameHostImpl* render_frame_host_impl)
: portal_(content::Portal::CreateForTesting(render_frame_host_impl)) {} : portal_(content::Portal::CreateForTesting(render_frame_host_impl)) {}
...@@ -500,39 +487,6 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest, AsyncEventTargetingIgnoresPortals) { ...@@ -500,39 +487,6 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest, AsyncEventTargetingIgnoresPortals) {
<< "Note: The portal's FrameSinkId is " << portal_view->GetFrameSinkId(); << "Note: The portal's FrameSinkId is " << portal_view->GetFrameSinkId();
} }
// Tests that trying to navigate to a chrome:// URL kills the renderer.
IN_PROC_BROWSER_TEST_F(PortalBrowserTest, NavigateToChrome) {
EXPECT_TRUE(NavigateToURL(
shell(), embedded_test_server()->GetURL("portal.test", "/title1.html")));
WebContentsImpl* web_contents_impl =
static_cast<WebContentsImpl*>(shell()->web_contents());
RenderFrameHostImpl* main_frame = web_contents_impl->GetMainFrame();
// Create portal.
PortalCreatedObserver portal_created_observer(main_frame);
EXPECT_TRUE(ExecJs(main_frame,
"var portal = document.createElement('portal');"
"document.body.appendChild(portal);"));
Portal* portal = portal_created_observer.WaitUntilPortalCreated();
PortalInterceptorForTesting* portal_interceptor =
PortalInterceptorForTesting::From(portal);
WebContentsImpl* portal_contents = portal->GetPortalContents();
// Try to navigate to chrome://settings and wait for the process to die.
portal_interceptor->navigate_callback_ = base::BindRepeating(
[](Portal* portal, const GURL& url) {
GURL chrome_url("chrome://settings");
portal->Navigate(chrome_url);
},
portal);
RenderProcessHostKillWaiter kill_waiter(
portal_contents->GetMainFrame()->GetProcess());
GURL a_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
EXPECT_TRUE(ExecJs(main_frame, JsReplace("portal.src = $1;", a_url)));
EXPECT_EQ(base::nullopt, kill_waiter.Wait());
}
class PortalOOPIFBrowserTest : public PortalBrowserTest { class PortalOOPIFBrowserTest : public PortalBrowserTest {
protected: protected:
PortalOOPIFBrowserTest() {} PortalOOPIFBrowserTest() {}
......
...@@ -67,18 +67,9 @@ HTMLElement* HTMLPortalElement::Create(Document& document) { ...@@ -67,18 +67,9 @@ HTMLElement* HTMLPortalElement::Create(Document& document) {
void HTMLPortalElement::Navigate() { void HTMLPortalElement::Navigate() {
KURL url = GetNonEmptyURLAttribute(html_names::kSrcAttr); KURL url = GetNonEmptyURLAttribute(html_names::kSrcAttr);
if (!portal_ptr_ || url.IsEmpty()) if (!url.IsEmpty() && portal_ptr_) {
return; portal_ptr_->Navigate(url);
if (!url.ProtocolIsInHTTPFamily()) {
GetDocument().AddConsoleMessage(ConsoleMessage::Create(
mojom::ConsoleMessageSource::kRendering,
mojom::ConsoleMessageLevel::kWarning,
"Portals only allow navigation to protocols in the HTTP family."));
return;
} }
portal_ptr_->Navigate(url);
} }
void HTMLPortalElement::ConsumePortal() { void HTMLPortalElement::ConsumePortal() {
......
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