Commit 3c0f2556 authored by Andrey Kosyakov's avatar Andrey Kosyakov Committed by Commit Bot

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/+/2129344Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756375}
parent 5baf224f
......@@ -245,7 +245,7 @@ class DevToolsSanityTest : public InProcessBrowserTest {
}
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);
}
......@@ -1499,6 +1499,11 @@ IN_PROC_BROWSER_TEST_F(DevToolsExtensionTest,
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.
IN_PROC_BROWSER_TEST_F(DevToolsSanityTest,
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