blob: 60f972de7c1b8b62736c8c452ed4fbd7b2aa02fb [file] [log] [blame]
<!doctype html><!-- webkit-test-runner [ IPCTestingAPIEnabled=true ] -->
<title>Test that stream sync message crash is noticed immediately</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<body>
<script>
setup({ single_test: true });
if (window.IPC) { // For compiles with !ENABLE(IPC_TESTING_API)
const defaultTimeout = 10;
const bufferSize = 100;
const streamTesterID = 4557;
for (const processTarget of IPC.processTargets) {
if (processTarget == "UI")
continue; // Crashing UI is not supported.
const streamConnection = IPC.createStreamClientConnection(processTarget, bufferSize);
IPC.sendMessage(processTarget, 0, IPC.messages.IPCTester_CreateStreamTester.name, [
{ type: 'uint64_t', value: streamTesterID },
{ type: 'StreamConnectionBuffer', value: streamConnection.streamBuffer() },
]);
const arguments = IPC.waitForMessage(processTarget, streamTesterID, IPC.messages.IPCStreamTesterProxy_WasCreated.name, defaultTimeout);
streamConnection.setSemaphores(arguments[0].value, arguments[1].value);
// Test starts here.
const result = streamConnection.sendIPCStreamTesterSyncCrashOnZero(streamTesterID, 78, defaultTimeout);
assert_equals(result, 78, `sync messages work for ${ processTarget }`);
const start = Date.now();
assert_throws_js(TypeError,
() => { streamConnection.sendIPCStreamTesterSyncCrashOnZero(streamTesterID, 0, defaultTimeout); },
`crashing sync message must return failure for ${ processTarget }`);
assert_less_than(Date.now() - start, 500, `crashing sync message must complete in 500ms for ${ processTarget }`);
console.log(`ttt: ${Date.now() - start}`);
}
}
done();
</script>
</body>