haikuwebkit/LayoutTests/inspector/worker/dom-debugger-event-after-te...

66 lines
1.9 KiB
HTML
Raw Permalink Normal View History

WebKit.WebContent process crashes when web developer tools are opened in Safari https://bugs.webkit.org/show_bug.cgi?id=210794 <rdar://problem/62214651> Reviewed by Brian Burg. Source/JavaScriptCore: * inspector/InjectedScriptManager.cpp: (Inspector::InjectedScriptManager::injectedScriptFor): Don't crash if a `TerminatedExecutionError` is thrown. * inspector/InjectedScriptBase.cpp: (Inspector::InjectedScriptBase::makeCall): Report the actual error message. Check that the result has a value before attempting to make a `JSON::Value` out of it. Source/WebCore: Test: inspector/worker/dom-debugger-event-after-terminate-crash.html * inspector/agents/InspectorDOMDebuggerAgent.cpp: (WebCore::InspectorDOMDebuggerAgent::willHandleEvent): Don't `ASSERT(injectedScript.hasNoValue())` as it's possible for the event to be fired after `Worker.prototype.terminate`, in which case `InjectedScriptManager::injectedScriptFor` will now return an `InjectedScript` that would fail that `ASSERT`. Source/WebInspectorUI: * UserInterface/Views/QuickConsole.js: (WI.QuickConsole.prototype._handleFrameExecutionContextsCleared): (WI.QuickConsole.prototype._handleTargetRemoved): If a `Worker` is removed and is not the active execution context, still check to see if the execution context picker should be hidden, such as if there is only one other execution context (e.g. the main page execution context). Previously, the execution context picker would only be hidden in this case if the `Worker` was the active execution context. LayoutTests: * inspector/worker/resources/worker-echo.js: Added. * inspector/worker/dom-debugger-event-after-terminate-crash.html: Added. * inspector/worker/dom-debugger-event-after-terminate-crash-expected.txt: Added. Canonical link: https://commits.webkit.org/224147@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260963 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-30 20:46:06 +00:00
<!DOCTYPE html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script>
let testWorker = null;
function createWorker() {
testWorker = new Worker("resources/worker-echo.js");
testWorker.addEventListener("message", (event) => {
let {echo, data} = event.data;
console.assert(echo, data);
TestPage.dispatchEventToFrontend(data);
});
testWorker.postMessage("WorkerCreated");
}
function terminateWorker() {
testWorker.postMessage("WorkerTerminated");
testWorker.terminate();
testWorker = null;
}
function test()
{
InspectorTest.addEventListener("WorkerTerminated", (event) => {
InspectorTest.fail("Should not dispatch any events after a Worker is terminated.");
});
Promise.resolve()
.then(() => {
InspectorTest.log("Creating worker...");
return Promise.all([
InspectorTest.awaitEvent("WorkerCreated"),
InspectorTest.evaluateInPage(`createWorker()`),
]);
})
.then(() => {
InspectorTest.log("Terminating worker...");
return InspectorTest.evaluateInPage(`terminateWorker()`);
})
.then(() => {
InspectorTest.log("Creating worker...");
return Promise.all([
InspectorTest.awaitEvent("WorkerCreated"),
InspectorTest.evaluateInPage(`createWorker()`),
]);
})
.then(() => {
InspectorTest.log("Terminating worker...");
return InspectorTest.evaluateInPage(`terminateWorker()`);
})
.then(() => {
InspectorTest.pass("Should not crash.");
})
.finally(() => {
InspectorTest.completeTest();
});
}
</script>
</head>
<body onload="runTest()">
<p>Test to ensure that any queued messages are not dispatched after terminate is called, which would cause a crash due to the InjectedScript throwing a TerminatedExecutionError when it's evaluated.</p>
</body>
</html>