Commit 54f4c4a5 authored by Andrey Kosyakov's avatar Andrey Kosyakov Committed by Commit Bot

chrome.debugger: allow attaching to pages having frames with empty URLs

Originally regressed by https://chromium-review.googlesource.com/c/chromium/src/+/2412799

Bug: 1143221
Change-Id: I8323b97ecf556d6ad27d1b34d1357479bb208843
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2511749
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823436}
parent d676fda0
......@@ -92,6 +92,10 @@ bool ExtensionMayAttachToURL(const Extension& extension,
const GURL& url,
Profile* profile,
std::string* error) {
// Allow the extension to attach to about:blank and empty URLs.
if (url.is_empty() || url == "about:")
return true;
if (url == content::kUnreachableWebDataURL)
return true;
......@@ -401,9 +405,6 @@ bool ExtensionDevToolsClientHost::MayAttachToURL(const GURL& url,
bool is_webui) {
if (is_webui)
return false;
// Allow the extension to attach to about:blank.
if (url.is_empty() || url == "about:")
return true;
std::string error;
if (!ExtensionMayAttachToURL(*extension_, url, profile_, &error))
return false;
......
......@@ -451,6 +451,10 @@ IN_PROC_BROWSER_TEST_F(DebuggerExtensionApiTest,
<< message_;
}
IN_PROC_BROWSER_TEST_F(DebuggerExtensionApiTest, AttachToEmptyUrls) {
ASSERT_TRUE(RunExtensionTest("debugger_attach_to_empty_urls")) << message_;
}
class SitePerProcessDebuggerExtensionApiTest : public DebuggerExtensionApiTest {
public:
void SetUpCommandLine(base::CommandLine* command_line) override {
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
const protocolVersion = '1.3';
chrome.test.getConfig(config => chrome.test.runTests([
async function testDebuggerAttachToFramesWithEmptyUrls() {
const {openTab} = await import('/_test_resources/test_util/tabs_util.js');
const pagePath =
'extensions/api_test/debugger_attach_to_empty_urls/page.html';
const topURL = `http://a.com:${config.testServer.port}/${pagePath}`;
const tab = await openTab(topURL);
const debuggee = {tabId: tab.id};
await new Promise(resolve =>
chrome.debugger.attach(debuggee, protocolVersion, resolve));
chrome.test.assertNoLastError();
chrome.debugger.detach(debuggee, chrome.test.succeed);
}
]));
{
"name": "Debugger Empty URL Access Test",
"manifest_version": 2,
"version": "0.1",
"permissions": ["debugger", "tabs"],
"background": {
"scripts": ["background.js"]
}
}
<html>
<iframe></iframe>
<iframe src=""></iframe>
<iframe src="javascript:"></iframe>
<iframe src="about:blank"></iframe>
</html>
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