15 lines
623 B
JavaScript
15 lines
623 B
JavaScript
console.warn("Demo warning: this page intentionally includes diagnosable issues.");
|
|
|
|
const longTaskButton = document.querySelector("#long-task");
|
|
const taskResult = document.querySelector("#task-result");
|
|
|
|
longTaskButton.addEventListener("click", () => {
|
|
const start = performance.now();
|
|
while (performance.now() - start < 650) {
|
|
Math.sqrt(Math.random() * Number.MAX_SAFE_INTEGER);
|
|
}
|
|
const duration = Math.round(performance.now() - start);
|
|
taskResult.textContent = `已触发约 ${duration}ms 的主线程长任务。`;
|
|
console.error("Demo error: long task was triggered for DevTools MCP inspection.");
|
|
});
|