Diff
Modified: trunk/LayoutTests/ChangeLog (293319 => 293320)
--- trunk/LayoutTests/ChangeLog 2022-04-25 09:20:22 UTC (rev 293319)
+++ trunk/LayoutTests/ChangeLog 2022-04-25 11:47:39 UTC (rev 293320)
@@ -1,3 +1,13 @@
+2022-04-25 Kimmo Kinnunen <kkinnu...@apple.com>
+
+ REGRESSION (249585@main): TestWebKitAPI.IPCTestingAPI.CanReceiveIPCSemaphore is timing out
+ https://bugs.webkit.org/show_bug.cgi?id=239507
+
+ Reviewed by Wenson Hsieh.
+
+ * ipc/send-semaphore-expected.txt: Added.
+ * ipc/send-semaphore.html: Added.
+
2022-04-24 Youenn Fablet <you...@apple.com>
TextTrackLoader should use SameOrigin mode by default
Added: trunk/LayoutTests/ipc/send-semaphore-expected.txt (0 => 293320)
--- trunk/LayoutTests/ipc/send-semaphore-expected.txt (rev 0)
+++ trunk/LayoutTests/ipc/send-semaphore-expected.txt 2022-04-25 11:47:39 UTC (rev 293320)
@@ -0,0 +1,4 @@
+
+PASS Sending and receiving a semaphore works
+PASS Sending and then receiving the same semaphore works
+
Added: trunk/LayoutTests/ipc/send-semaphore.html (0 => 293320)
--- trunk/LayoutTests/ipc/send-semaphore.html (rev 0)
+++ trunk/LayoutTests/ipc/send-semaphore.html 2022-04-25 11:47:39 UTC (rev 293320)
@@ -0,0 +1,64 @@
+<!doctype html><!-- webkit-test-runner [ IPCTestingAPIEnabled=true ] -->
+<title>Test that IPC system can send and receive semaphores.</title>
+<script src=""
+<script src=""
+<body>
+<script>
+// NOTE: At the time we don't account for spurious wake-ups in IPC::Semaphore.
+const defaultTimeout = 5000;
+promise_test(async t => {
+ if (!window.IPC)
+ return;
+ const bufferSize = 100;
+ const streamTesterID = 447;
+ for (const processTarget of IPC.processTargets) {
+ const semaphore = IPC.createSemaphore();
+ assert_equals(semaphore.waitFor(100), false);
+
+ IPC.sendMessage(processTarget, 0, IPC.messages.IPCTester_SendSemaphoreBackAndSignalProtocol.name, [
+ { type: 'Semaphore', value: semaphore },
+ ]);
+ const reply = IPC.waitForMessage(processTarget, 0, IPC.messages.IPCTester_SendSemaphoreBackAndSignalProtocol.name, defaultTimeout);
+ assert_equals(reply[0].type, "Semaphore", `for ${ processTarget }`);
+ const replySemaphore = reply[0].value;
+ // Both semaphores can be waited on.
+ assert_equals(semaphore.waitFor(100), false);
+ assert_equals(replySemaphore.waitFor(100), false);
+ // Signal protocol is:
+ // 1) the other side waits for our semaphore
+ // 2) this side waits for the replySemaphore
+ // 3) the other side waits for our semaphore again (to prevent destruction race of replySemaphore).
+ semaphore.signal();
+ assert_equals(replySemaphore.waitFor(1000), true);
+ semaphore.signal(); // Signal for done, so the other end will destroy the semaphore.
+
+ // Check that we did not get confused by the other test during implementation:
+ // Check that semaphore and replySemaphore are distinct objects, and the previous
+ // success was due to the signal protocol.
+ semaphore.signal();
+ assert_equals(replySemaphore.waitFor(100), false);
+ }
+}, "Sending and receiving a semaphore works");
+
+promise_test(async t => {
+ if (!window.IPC)
+ return;
+ const bufferSize = 100;
+ const streamTesterID = 447;
+ for (const processTarget of IPC.processTargets) {
+ const semaphore = IPC.createSemaphore();
+ IPC.sendMessage(processTarget, 0, IPC.messages.IPCTester_SendSameSemaphoreBack.name, [
+ { type: 'Semaphore', value: semaphore },
+ ]);
+ const reply = IPC.waitForMessage(processTarget, 0, IPC.messages.IPCTester_SendSameSemaphoreBack.name, defaultTimeout);
+ assert_equals(reply[0].type, "Semaphore", `for ${ processTarget }`);
+ const replySemaphore = reply[0].value;
+ assert_equals(semaphore.waitFor(100), false);
+ assert_equals(replySemaphore.waitFor(100), false);
+ // The replySemaphore is the same as semaphore, so signaling one is visible in the another.
+ semaphore.signal();
+ assert_equals(replySemaphore.waitFor(100), true);
+ }
+}, "Sending and then receiving the same semaphore works");
+</script>
+</body>
\ No newline at end of file
Modified: trunk/Source/WebKit/ChangeLog (293319 => 293320)
--- trunk/Source/WebKit/ChangeLog 2022-04-25 09:20:22 UTC (rev 293319)
+++ trunk/Source/WebKit/ChangeLog 2022-04-25 11:47:39 UTC (rev 293320)
@@ -1,3 +1,20 @@
+2022-04-25 Kimmo Kinnunen <kkinnu...@apple.com>
+
+ REGRESSION (249585@main): TestWebKitAPI.IPCTestingAPI.CanReceiveIPCSemaphore is timing out
+ https://bugs.webkit.org/show_bug.cgi?id=239507
+
+ Reviewed by Wenson Hsieh.
+
+ Add purpose-built test interfaces for testing sending IPC::Semaphore via the IPC.
+
+ Test: ipc/send-semaphore.html
+
+ * Shared/IPCTester.cpp:
+ (WebKit::IPCTester::sendSameSemaphoreBack):
+ (WebKit::IPCTester::sendSemaphoreBackAndSignalProtocol):
+ * Shared/IPCTester.h:
+ * Shared/IPCTester.messages.in:
+
2022-04-24 Youenn Fablet <you...@apple.com>
Make NetworkResourceLoader.m_parameters non const
Modified: trunk/Source/WebKit/Shared/IPCTester.cpp (293319 => 293320)
--- trunk/Source/WebKit/Shared/IPCTester.cpp 2022-04-25 09:20:22 UTC (rev 293319)
+++ trunk/Source/WebKit/Shared/IPCTester.cpp 2022-04-25 11:47:39 UTC (rev 293320)
@@ -30,6 +30,7 @@
#include "Connection.h"
#include "Decoder.h"
#include "IPCStreamTester.h"
+#include "IPCTesterMessages.h"
#include <atomic>
#include <dlfcn.h>
@@ -145,6 +146,28 @@
completionHandler();
}
+void IPCTester::sendSameSemaphoreBack(IPC::Connection& connection, IPC::Semaphore&& semaphore)
+{
+ connection.send(Messages::IPCTester::SendSameSemaphoreBack(semaphore), 0);
+}
+
+void IPCTester::sendSemaphoreBackAndSignalProtocol(IPC::Connection& connection, IPC::Semaphore&& semaphore)
+{
+ IPC::Semaphore newSemaphore;
+ connection.send(Messages::IPCTester::SendSemaphoreBackAndSignalProtocol(newSemaphore), 0);
+ if (!semaphore.waitFor(10_s)) {
+ ASSERT_IS_TESTING_IPC();
+ return;
+ }
+ newSemaphore.signal();
+ // Wait for protocol commit. Otherwise newSemaphore will be destroyed, and the waiter on the other side
+ // will fail to wait.
+ if (!semaphore.waitFor(10_s)) {
+ ASSERT_IS_TESTING_IPC();
+ return;
+ }
+}
+
void IPCTester::stopIfNeeded()
{
if (m_testQueue) {
Modified: trunk/Source/WebKit/Shared/IPCTester.h (293319 => 293320)
--- trunk/Source/WebKit/Shared/IPCTester.h 2022-04-25 09:20:22 UTC (rev 293319)
+++ trunk/Source/WebKit/Shared/IPCTester.h 2022-04-25 11:47:39 UTC (rev 293320)
@@ -69,6 +69,8 @@
void stopMessageTesting(CompletionHandler<void()>);
void createStreamTester(IPC::Connection&, IPCStreamTesterIdentifier, IPC::StreamConnectionBuffer&&);
void releaseStreamTester(IPCStreamTesterIdentifier, CompletionHandler<void()>&&);
+ void sendSameSemaphoreBack(IPC::Connection&, IPC::Semaphore&&);
+ void sendSemaphoreBackAndSignalProtocol(IPC::Connection&, IPC::Semaphore&&);
void stopIfNeeded();
Modified: trunk/Source/WebKit/Shared/IPCTester.messages.in (293319 => 293320)
--- trunk/Source/WebKit/Shared/IPCTester.messages.in 2022-04-25 09:20:22 UTC (rev 293319)
+++ trunk/Source/WebKit/Shared/IPCTester.messages.in 2022-04-25 11:47:39 UTC (rev 293320)
@@ -27,6 +27,9 @@
StopMessageTesting() -> () Synchronous
CreateStreamTester(WebKit::IPCStreamTesterIdentifier identifier, IPC::StreamConnectionBuffer stream) WantsConnection
ReleaseStreamTester(WebKit::IPCStreamTesterIdentifier identifier) -> () Synchronous
+
+ SendSameSemaphoreBack(IPC::Semaphore semaphore) WantsConnection
+ SendSemaphoreBackAndSignalProtocol(IPC::Semaphore semaphore) WantsConnection
}
#endif
Modified: trunk/Tools/ChangeLog (293319 => 293320)
--- trunk/Tools/ChangeLog 2022-04-25 09:20:22 UTC (rev 293319)
+++ trunk/Tools/ChangeLog 2022-04-25 11:47:39 UTC (rev 293320)
@@ -1,3 +1,22 @@
+2022-04-25 Kimmo Kinnunen <kkinnu...@apple.com>
+
+ REGRESSION (249585@main): TestWebKitAPI.IPCTestingAPI.CanReceiveIPCSemaphore is timing out
+ https://bugs.webkit.org/show_bug.cgi?id=239507
+
+ Reviewed by Wenson Hsieh.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm:
+ Move CanReceiveIPCSemaphore and CanSendIPCSemaphore test logic
+ to LayoutTests/ipc/send-semaphore.html
+ The tests were using audio and canvas implementation detail
+ messages to test that IPC system can send IPC::Semaphore via IPC.
+ Canvas implementation details changed and the test started
+ to fail.
+
+ The new tests use IPC messages that are purpose-built to test this
+ feature. The new tests also actually test that the sent semaphores
+ work.
+
2022-04-16 Philippe Normand <ph...@igalia.com>
[git] Allow pre-commit hook to feed from staged ChangeLogs
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm (293319 => 293320)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm 2022-04-25 09:20:22 UTC (rev 293319)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm 2022-04-25 11:47:39 UTC (rev 293320)
@@ -286,47 +286,8 @@
EXPECT_FALSE([webView stringByEvaluatingJavaScript:@"result.arguments[0].value"].boolValue);
}
-TEST(IPCTestingAPI, CanReceiveIPCSemaphore)
-{
- auto webView = createWebViewWithIPCTestingAPI();
-
- auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]);
- [webView setUIDelegate:delegate.get()];
-
- done = false;
- auto html = @"<!DOCTYPE html>"
- "<script>"
- "const bufferSize = 1 << 16;"
- "const streamConnection = IPC.createStreamClientConnection('GPU', bufferSize);"
- "IPC.sendMessage('GPU', 0, IPC.messages.GPUConnectionToWebProcess_CreateRenderingBackend.name, ["
- " { type: 'RemoteRenderingBackendCreationParameters', 'identifier': 123, 'pageProxyID': IPC.webPageProxyID, 'pageID': IPC.pageID },"
- " { type: 'StreamConnectionBuffer', value: streamConnection.streamBuffer() },"
- "]);"
- "const arguments = IPC.waitForMessage('GPU', 123, IPC.messages.RemoteRenderingBackendProxy_DidCreateWakeUpSemaphoreForDisplayListStream.name, 100);"
- "alert(arguments.length + ':' + arguments[0].type + ':' + arguments[0].value.waitFor(100));"
- "</script>";
- [webView synchronouslyLoadHTMLString:html];
- TestWebKitAPI::Util::run(&done);
-
- EXPECT_STREQ([alertMessage UTF8String], "1:Semaphore:false");
-}
-
#endif // ENABLE(GPU_PROCESS)
-TEST(IPCTestingAPI, CanCreateIPCSemaphore)
-{
- auto webView = createWebViewWithIPCTestingAPI();
-
- auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]);
- [webView setUIDelegate:delegate.get()];
-
- done = false;
- [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html><script>alert(IPC.createSemaphore().waitFor(100));</script>"];
- TestWebKitAPI::Util::run(&done);
-
- EXPECT_FALSE([alertMessage boolValue]);
-}
-
TEST(IPCTestingAPI, CanCreateSharedMemory)
{
auto webView = createWebViewWithIPCTestingAPI();
@@ -346,36 +307,6 @@
EXPECT_STREQ([webView stringByEvaluatingJavaScript:@"Array.from(new Int8Array(sharedMemory.readBytes())).toString()"].UTF8String, "1,2,101,102,103,32,0,0");
}
-TEST(IPCTestingAPI, CanSendSemaphore)
-{
- auto webView = createWebViewWithIPCTestingAPI();
-
- auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]);
- [webView setUIDelegate:delegate.get()];
-
- auto* html = @R"HTML(<!DOCTYPE html>
-<body>
-<script>
-const audioContext = new AudioContext;
-const destination = audioContext.createMediaStreamDestination();
-const semaphore = IPC.createSemaphore();
-const result = IPC.sendSyncMessage('GPU', 0, IPC.messages.RemoteAudioDestinationManager_CreateAudioDestination.name, 100,
- [{type: 'String', value: 'some device'},
- {type: 'uint32_t', value: destination.numberOfInputs},
- {type: 'uint32_t', value: destination.channelCount},
- {type: 'float', value: audioContext.sampleRate}, {type: 'float', value: audioContext.sampleRate},
- {type: 'Semaphore', value: semaphore}]);
-alert(result.arguments[0].type);
-</script>
-</body>)HTML";
-
- done = false;
- [webView synchronouslyLoadHTMLString:html];
- TestWebKitAPI::Util::run(&done);
-
- EXPECT_STREQ([alertMessage UTF8String], "uint64_t");
-}
-
#if PLATFORM(COCOA)
TEST(IPCTestingAPI, CanSendSharedMemory)
{