Commit f8d89eaf authored by estark's avatar estark Committed by Commit bot

Do not prompt for reload when security panel is opened on an interstitial

Because interstitials are not real navigations, the security panel
sidebar doesn't work properly for an interstitial, and also doesn't
provide that much more useful information than what's shown in the
Overview view. For this reason, we were already hiding the origins
sidebar when you navigate to an interstitial while the security panel is
open. This CL extends that behavior to when you open DevTools while an
interstitial is already showing.

As a drive-by, this CL also fixes a bug where requests that finished after
the interstitial was shown would still show up in the sidebar.

Also note that this CL only partially addresses the linked bug. This CL
removes the confusing/useless prompt to reload, but doesn't fix the fact
that refreshing on an interstitial does weird things (sends you back to
the previous page). The latter weirdness has been split into
https://crbug.com/669316.

BUG=637299
TEST=Navigate to https://expired.badssl.com. Open the DevTools security
panel. Observe that there is no prompt to reload in the sidebar.

Review-Url: https://codereview.chromium.org/2522733002
Cr-Commit-Position: refs/heads/master@{#434887}
parent c39c6e66
...@@ -1356,6 +1356,23 @@ IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) { ...@@ -1356,6 +1356,23 @@ IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) {
EXPECT_TRUE(notifications_.empty()); EXPECT_TRUE(notifications_.empty());
} }
// Tests that an interstitialShown event is sent when an interstitial is showing
// on attach.
IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, InterstitialShownOnAttach) {
TestInterstitialDelegate* delegate = new TestInterstitialDelegate;
WebContentsImpl* web_contents =
static_cast<WebContentsImpl*>(shell()->web_contents());
GURL interstitial_url("https://example.test");
InterstitialPageImpl* interstitial = new InterstitialPageImpl(
web_contents, static_cast<RenderWidgetHostDelegate*>(web_contents), true,
interstitial_url, delegate);
interstitial->Show();
WaitForInterstitialAttach(web_contents);
Attach();
SendCommand("Page.enable", nullptr, false);
WaitForNotification("Page.interstitialShown", true);
}
class SitePerProcessDevToolsProtocolTest : public DevToolsProtocolTest { class SitePerProcessDevToolsProtocolTest : public DevToolsProtocolTest {
public: public:
void SetUpCommandLine(base::CommandLine* command_line) override { void SetUpCommandLine(base::CommandLine* command_line) override {
......
...@@ -198,6 +198,8 @@ void PageHandler::DidDetachInterstitialPage() { ...@@ -198,6 +198,8 @@ void PageHandler::DidDetachInterstitialPage() {
Response PageHandler::Enable() { Response PageHandler::Enable() {
enabled_ = true; enabled_ = true;
if (GetWebContents() && GetWebContents()->ShowingInterstitialPage())
client_->InterstitialShown(InterstitialShownParams::Create());
return Response::FallThrough(); return Response::FallThrough();
} }
......
...@@ -19,6 +19,10 @@ function test() ...@@ -19,6 +19,10 @@ function test()
// Test that the sidebar is hidden when an interstitial is shown. https://crbug.com/559150 // Test that the sidebar is hidden when an interstitial is shown. https://crbug.com/559150
InspectorTest.mainTarget.model(SDK.ResourceTreeModel).dispatchEventToListeners(SDK.ResourceTreeModel.Events.InterstitialShown); InspectorTest.mainTarget.model(SDK.ResourceTreeModel).dispatchEventToListeners(SDK.ResourceTreeModel.Events.InterstitialShown);
// Simulate a request finishing after the interstitial is shown, to make sure that doesn't show up in the sidebar.
var request3 = new SDK.NetworkRequest(InspectorTest.mainTarget, 0, "https://bar.test/foo.jpg", "https://bar.test", 0, 0, null);
request3.setSecurityState(Protocol.Security.SecurityState.Unknown);
InspectorTest.dispatchRequestFinished(request3);
InspectorTest.addResult("After interstitial is shown:"); InspectorTest.addResult("After interstitial is shown:");
InspectorTest.dumpDeepInnerHTML(Security.SecurityPanel._instance()._sidebarTree.element); InspectorTest.dumpDeepInnerHTML(Security.SecurityPanel._instance()._sidebarTree.element);
......
...@@ -55,6 +55,7 @@ SDK.ResourceTreeModel = class extends SDK.SDKModel { ...@@ -55,6 +55,7 @@ SDK.ResourceTreeModel = class extends SDK.SDKModel {
this._pendingReloadOptions = null; this._pendingReloadOptions = null;
this._reloadSuspensionCount = 0; this._reloadSuspensionCount = 0;
this._isInterstitialShowing = false;
} }
/** /**
...@@ -115,6 +116,13 @@ SDK.ResourceTreeModel = class extends SDK.SDKModel { ...@@ -115,6 +116,13 @@ SDK.ResourceTreeModel = class extends SDK.SDKModel {
return this._cachedResourcesProcessed; return this._cachedResourcesProcessed;
} }
/**
* @return {boolean}
*/
isInterstitialShowing() {
return this._isInterstitialShowing;
}
/** /**
* @param {!SDK.ResourceTreeFrame} frame * @param {!SDK.ResourceTreeFrame} frame
* @param {boolean=} aboutToNavigate * @param {boolean=} aboutToNavigate
...@@ -859,6 +867,7 @@ SDK.PageDispatcher = class { ...@@ -859,6 +867,7 @@ SDK.PageDispatcher = class {
* @override * @override
*/ */
interstitialShown() { interstitialShown() {
this._resourceTreeModel._isInterstitialShowing = true;
this._resourceTreeModel.dispatchEventToListeners(SDK.ResourceTreeModel.Events.InterstitialShown); this._resourceTreeModel.dispatchEventToListeners(SDK.ResourceTreeModel.Events.InterstitialShown);
} }
...@@ -866,6 +875,7 @@ SDK.PageDispatcher = class { ...@@ -866,6 +875,7 @@ SDK.PageDispatcher = class {
* @override * @override
*/ */
interstitialHidden() { interstitialHidden() {
this._resourceTreeModel._isInterstitialShowing = false;
this._resourceTreeModel.dispatchEventToListeners(SDK.ResourceTreeModel.Events.InterstitialHidden); this._resourceTreeModel.dispatchEventToListeners(SDK.ResourceTreeModel.Events.InterstitialHidden);
} }
......
...@@ -291,6 +291,9 @@ Security.SecurityPanel = class extends UI.PanelWithSidebar { ...@@ -291,6 +291,9 @@ Security.SecurityPanel = class extends UI.PanelWithSidebar {
resourceTreeModel.addEventListener( resourceTreeModel.addEventListener(
SDK.ResourceTreeModel.Events.InterstitialHidden, this._onInterstitialHidden, this), SDK.ResourceTreeModel.Events.InterstitialHidden, this._onInterstitialHidden, this),
]); ]);
if (resourceTreeModel.isInterstitialShowing())
this._onInterstitialShown();
} }
var networkManager = SDK.NetworkManager.fromTarget(target); var networkManager = SDK.NetworkManager.fromTarget(target);
......
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