blob: 86809b9d1c555435223cba391fc3aaea735ce891 [file] [log] [blame]
<html>
<head>
<title>Headless remote debugging</title>
<style>
</style>
<script>
const fetchjson = (url) => fetch(url).then(r => r.json());
function loadData() {
const getList = fetchjson("/json/list");
const getVersion = fetchjson('/json/version');
Promise.all([getList, getVersion]).then(parseResults);
}
function parseResults([listData, versionData]){
const version = versionData['WebKit-Version'];
const hash = version.match(/\s\(@(\b[0-9a-f]{5,40}\b)/)[1];
listData.forEach(item => appendItem(item, hash));
}
function appendItem(item, hash) {
let link;
if (item.devtoolsFrontendUrl) {
link = document.createElement("a");
var devtoolsFrontendUrl = item.devtoolsFrontendUrl.replace(/^\/devtools\//,'');
link.href = `https://chrome-devtools-frontend.appspot.com/serve_file/@${hash}/${devtoolsFrontendUrl}&remoteFrontend=true`;
link.title = item.title;
} else {
link = document.createElement("div");
link.title = "The tab already has active debugging session";
}
var text = document.createElement("div");
if (item.title)
text.textContent = item.title;
else
text.textContent = "(untitled tab)";
if (item.faviconUrl)
text.style.cssText = "background-image:url(" + item.faviconUrl + ")";
link.appendChild(text);
var p = document.createElement("p");
p.appendChild(link);
document.getElementById("items").appendChild(p);
}
</script>
</head>
<body onload='loadData()'>
<div id='caption'>Inspectable WebContents</div>
<div id='items'></div>
</body>
</html>