I am using Chrome Debug Protocol in Node.js, and the program accepts user's input as code and run it in Chrome through Chrome Debug Protocol, just like the snippet below:
const Chrome = require('chrome-remote-interface')
Chrome(async (client) => {
const {
Page,
Runtime
} = client
try {
await Promise.all([
Page.enable(),
Runtime.enable()
])
Runtime.evaluate({ expression: `while (1) {}` })
} catch (e) {
console.log(e)
}
})
But if the code has infinite loop like while (1) {}, the Chrome's tab will stay still forever. Is there any way to exit the infinite loop (or just simply stop the running JavaScript) programmatically instead of killing the process?
via Jerry
No comments:
Post a Comment