Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REGRESSION(256008@main) TestWebKitAPI.IPCTestingAPI.CanIntercept* tes…
…ts fail https://bugs.webkit.org/show_bug.cgi?id=247256 rdar://problem/101749810 Reviewed by Ryosuke Niwa. The commit 256008@main changed the encoding for messages that have async replies: - Before, the reply id was encoded as the first parameter. - After, the reply id was encoded as the last parameter. This broke the JS IPC tester API where message listener code was not adjusted accordingly. This caused the arguments to be decoded incorrectly. Fix the JS IPC tester API. Add a test testing that listener API can be used to obtain the async reply id. * LayoutTests/ipc/message-listener-async-message-reply-id-expected.txt: Added. * LayoutTests/ipc/message-listener-async-message-reply-id.html: Added. Source/WebKit/CMakeLists.txt: * Source/WebKit/DerivedSources-input.xcfilelist: * Source/WebKit/DerivedSources-output.xcfilelist: * Source/WebKit/DerivedSources.make: * Source/WebKit/Shared/IPCTester.cpp: (WebKit::IPCTester::sendAsyncMessageToProxy): * Source/WebKit/Shared/IPCTester.h: * Source/WebKit/Shared/IPCTester.messages.in: * Source/WebKit/Shared/IPCTesterReceiver.cpp: Copied from Source/WebKit/WebProcess/GPU/graphics/ThreadSafeRemoteImageBufferFlusher.cpp. (WebKit::IPCTesterReceiver::asyncMessage): * Source/WebKit/Shared/IPCTesterReceiver.h: Copied from Source/WebKit/WebProcess/GPU/graphics/ThreadSafeRemoteImageBufferFlusher.cpp. * Source/WebKit/Shared/IPCTesterReceiver.messages.in: Copied from Source/WebKit/Shared/IPCTester.messages.in. * Source/WebKit/Sources.txt: * Source/WebKit/WebKit.xcodeproj/project.pbxproj: * Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp: (WebKit::IPCTestingAPI::JSIPC::staticFunctions): (WebKit::IPCTestingAPI::JSIPC::addTesterReceiver): (WebKit::IPCTestingAPI::JSIPC::removeTesterReceiver): (WebKit::IPCTestingAPI::JSMessageListener::jsDescriptionFromDecoder): Canonical link: https://commits.webkit.org/256420@main
- Loading branch information
1 parent
cf442de
commit 7e3be0d
Showing
15 changed files
with
241 additions
and
12 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
LayoutTests/ipc/message-listener-async-message-reply-id-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
PASS Intercepting async messages contains all the expected data. | ||
|
37 changes: 37 additions & 0 deletions
37
LayoutTests/ipc/message-listener-async-message-reply-id.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
<!doctype html><!-- webkit-test-runner [ IPCTestingAPIEnabled=true ] --> | ||
<title>Test that intercepting an async message has access to the listener id.</title> | ||
<script src="../resources/testharness.js"></script> | ||
<script src="../resources/testharnessreport.js"></script> | ||
<body> | ||
<script> | ||
|
||
promise_test(async t => { | ||
if (!window.IPC) | ||
return; | ||
const testerID = 447; | ||
const processTarget = 'UI'; // Currently only UI is supported for addTesterReceiver. | ||
IPC.addTesterReceiver(processTarget); | ||
try { | ||
let messages = []; | ||
IPC.addIncomingMessageListener(processTarget, (message) => { | ||
if (message.name != IPC.messages.IPCTesterReceiver_AsyncMessage.name) | ||
return; | ||
messages.push(message); | ||
}); | ||
IPC.sendMessage(processTarget, 0, IPC.messages.IPCTester_SendAsyncMessageToReceiver.name, [ | ||
{ type: 'uint32_t', value: 89 }, | ||
]); | ||
await t.step_wait(() => { return messages.length > 0 }, "Waiting until async message is intercepted"); | ||
assert_equals(messages.length, 1, `for ${ processTarget }`); | ||
assert_equals(messages[0].arguments.length, 1, `for ${ processTarget }`) | ||
assert_equals(messages[0].arguments[0].type, "uint32_t", `for ${ processTarget }`); | ||
assert_equals(messages[0].arguments[0].value, 90, `for ${ processTarget }`); | ||
assert_equals(typeof messages[0].listenerID, "number", `for ${ processTarget }`); | ||
assert_greater_than(messages[0].listenerID, 0, `for ${ processTarget }`); | ||
} finally { | ||
IPC.removeTesterReceiver(processTarget); | ||
} | ||
}, "Intercepting async messages contains all the expected data."); | ||
</script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (C) 2022 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "config.h" | ||
#include "IPCTesterReceiver.h" | ||
|
||
#if ENABLE(IPC_TESTING_API) | ||
|
||
namespace WebKit { | ||
|
||
void IPCTesterReceiver::asyncMessage(uint32_t arg0, CompletionHandler<void(uint32_t)>&& completionHandler) | ||
{ | ||
completionHandler(arg0 + 1u); | ||
} | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (C) 2022 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#if ENABLE(IPC_TESTING_API) | ||
|
||
#include "MessageReceiver.h" | ||
|
||
namespace IPC { | ||
class Connection; | ||
} | ||
|
||
namespace WebKit { | ||
|
||
// Proxy interface to test IPC activities related to receiving messages. | ||
class IPCTesterReceiver final : public IPC::MessageReceiver { | ||
public: | ||
IPCTesterReceiver() = default; | ||
~IPCTesterReceiver() = default; | ||
|
||
// IPC::MessageReceiver | ||
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final; | ||
private: | ||
// Messages | ||
void asyncMessage(uint32_t, CompletionHandler<void(uint32_t)>&&); | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (C) 2022 Apple Inc. All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions | ||
# are met: | ||
# 1. Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND | ||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR | ||
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
#if ENABLE(IPC_TESTING_API) | ||
|
||
messages -> IPCTesterReceiver NotRefCounted { | ||
void AsyncMessage(uint32_t arg1) -> (uint32_t reply) Asynchronous | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.