Commit 0f93d79a authored by Andrey Kosyakov's avatar Andrey Kosyakov Committed by Commit Bot

Reland "DevTools: add tests for extensions on DOM UI pages"

This reverts commit 82b85893.

Reason for revert: let's give this test another change. it seems to reliable pass for me locally and I think the original failure was rather due to a front-end race fixed here: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2242769

Original change's description:
> Revert "DevTools: add tests for extensions on DOM UI pages"
> 
> This reverts commit 3c0f2556.
> 
> Reason for revert: test is extremely flaky
> 
> Per https://analysis.chromium.org/p/chromium/flake-portal/flakes/occurrences?key=ag9zfmZpbmRpdC1mb3ItbWVyUgsSBUZsYWtlIkdjaHJvbWl1bUBicm93c2VyX3Rlc3RzQERldlRvb2xzRXh0ZW5zaW9uVGVzdC5UZXN0RXZhbHVhdGVPbkNocm9tZVNjaGVtZQw this flakily fails about 10 times an hour.
> 
> Original change's description:
> > DevTools: add tests for extensions on DOM UI pages
> > 
> > This is the chrome-side counterpart of
> > https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2128732
> > 
> > Bug: 1059577, 795595
> > Change-Id: Iec2ee772a42b4c7bc2249627c0839f7506f0cd1d
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2129344
> > Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
> > Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
> > Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#756375}
> 
> TBR=dgozman@chromium.org,rdevlin.cronin@chromium.org,caseq@chromium.org,bmeurer@chromium.org
> 
> # Not skipping CQ checks because original CL landed > 1 day ago.
> 
> Bug: 1059577, 795595
> Change-Id: I2919088167b064086b315d8c3a64df569d95c844
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2188512
> Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
> Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#766575}

TBR=dgozman@chromium.org,mek@chromium.org,rdevlin.cronin@chromium.org,caseq@chromium.org,bmeurer@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1059577
Bug: 795595
Change-Id: Ibd719500160685664de90415d718b88b4621b52e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2382487Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802868}
parent 1d35af81
...@@ -245,7 +245,7 @@ class DevToolsSanityTest : public InProcessBrowserTest { ...@@ -245,7 +245,7 @@ class DevToolsSanityTest : public InProcessBrowserTest {
} }
void LoadTestPage(const std::string& test_page) { void LoadTestPage(const std::string& test_page) {
GURL url = spawned_test_server()->GetURL(test_page); GURL url(spawned_test_server()->GetURL("").Resolve(test_page));
ui_test_utils::NavigateToURL(browser(), url); ui_test_utils::NavigateToURL(browser(), url);
} }
...@@ -1531,6 +1531,11 @@ IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, ...@@ -1531,6 +1531,11 @@ IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest,
RunTest("testConsoleContextNames", kPageWithContentScript); RunTest("testConsoleContextNames", kPageWithContentScript);
} }
IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest, TestEvaluateOnChromeScheme) {
LoadExtension("chrome_scheme");
RunTest("waitForTestResultsAsMessage", std::string());
}
// Tests that scripts are not duplicated after Scripts Panel switch. // Tests that scripts are not duplicated after Scripts Panel switch.
IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, IN_PROC_BROWSER_TEST_F(DevToolsSanityTest,
TestNoScriptDuplicatesOnPanelSwitch) { TestNoScriptDuplicatesOnPanelSwitch) {
......
<html>
<head>
<script src="devtools.js"></script>
</head>
</html>
// 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.
function output(msg) {
top.postMessage({testOutput: msg}, '*');
}
async function test() {
const newPageURL = 'chrome://version/';
const inspectedTabId = chrome.devtools.inspectedWindow.tabId;
chrome.tabs.update(inspectedTabId, {url: newPageURL});
await new Promise(resolve => chrome.tabs.onUpdated.addListener(
(tabId, changedProps) => {
if (inspectedTabId !== tabId || changedProps.url !== newPageURL)
return;
resolve();
}
));
// There may be a number of inherent races between the page and the DevTools
// during the navigation. Let's do a number of eval in a hope of catching some
// of them.
const evalCount = 1000;
let callbackCount = 0;
const evaluateCallback = (result, exception) => {
if (!exception || !exception.isError) {
output(`FAIL: ${result || exception.value}`);
return;
}
if (exception.code !== 'E_FAILED') {
output(`FAIL: ${exception.code}`);
return;
}
if (++callbackCount === evalCount)
output('PASS');
};
for (let i = 0; i < evalCount; ++i) {
chrome.devtools.inspectedWindow.eval('location.href', {}, evaluateCallback);
}
}
test();
{
"description": "Devtools Test extension",
"name": "Devtools Test extension",
"version": "0.1",
"manifest_version": 2,
"devtools_page": "devtools.html",
"permissions": ["tabs"]
}
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