ASSERTION FAILED: RunLoop::isMain() in com.apple.WebKit: IPC::Connection::sendSyncMes...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Jun 2017 02:03:29 +0000 (02:03 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Jun 2017 02:03:29 +0000 (02:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=172943
<rdar://problem/31288058>

Reviewed by Alexey Proskuryakov.

Source/WebKit2:

In Connection::sendMessage(), make sure we only ever transform asynchronous messages into synchronous
ones if sendMessage() is called on the main thread. This is necessary because we no longer support
sending synchronous messages from a background thread since r205125.

* Platform/IPC/Connection.cpp:
(IPC::Connection::sendMessage):
(IPC::Connection::sendSyncMessage):

LayoutTests:

Add better test coverage.

* storage/domstorage/sessionstorage/set-item-synchronous-keydown-expected.txt: Added.
* storage/domstorage/sessionstorage/set-item-synchronous-keydown.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217810 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/storage/domstorage/sessionstorage/set-item-synchronous-keydown-expected.txt [new file with mode: 0644]
LayoutTests/storage/domstorage/sessionstorage/set-item-synchronous-keydown.html [new file with mode: 0644]
Source/WebKit2/ChangeLog
Source/WebKit2/Platform/IPC/Connection.cpp

index 3266b5f..9ea82f7 100644 (file)
@@ -1,3 +1,16 @@
+2017-06-05  Chris Dumez  <cdumez@apple.com>
+
+        ASSERTION FAILED: RunLoop::isMain() in com.apple.WebKit: IPC::Connection::sendSyncMessage + 128
+        https://bugs.webkit.org/show_bug.cgi?id=172943
+        <rdar://problem/31288058>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Add better test coverage.
+
+        * storage/domstorage/sessionstorage/set-item-synchronous-keydown-expected.txt: Added.
+        * storage/domstorage/sessionstorage/set-item-synchronous-keydown.html: Added.
+
 2017-06-05  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Improve ES6 Class instances in Heap Snapshot instances view
diff --git a/LayoutTests/storage/domstorage/sessionstorage/set-item-synchronous-keydown-expected.txt b/LayoutTests/storage/domstorage/sessionstorage/set-item-synchronous-keydown-expected.txt
new file mode 100644 (file)
index 0000000..7e18d94
--- /dev/null
@@ -0,0 +1,12 @@
+Tests updating sessionStorage in the keydown handler and makes sure the value is updated synchronously.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS sessionStorage.setItemSynchronousKeydownTestValue is "0"
+Setting setItemSynchronousKeydownTestValue to 1 in keydown handler.
+PASS sessionStorage.setItemSynchronousKeydownTestValue is "1"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/storage/domstorage/sessionstorage/set-item-synchronous-keydown.html b/LayoutTests/storage/domstorage/sessionstorage/set-item-synchronous-keydown.html
new file mode 100644 (file)
index 0000000..20ba3cd
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../../resources/js-test.js"></script>
+<script src="resources/clearSessionStorage.js"></script>
+<input id="testInput" type="text"></input>
+<script>
+description("Tests updating sessionStorage in the keydown handler and makes sure the value is updated synchronously.");
+
+function keydownHandler()
+{
+    debug("Setting setItemSynchronousKeydownTestValue to 1 in keydown handler.");
+    sessionStorage.setItemSynchronousKeydownTestValue = 1;
+}
+
+testInput.focus();
+testInput.onkeydown = keydownHandler;
+sessionStorage.setItemSynchronousKeydownTestValue = 0;
+shouldBeEqualToString("sessionStorage.setItemSynchronousKeydownTestValue", "0");
+
+// keydownHandler() should be called synchronously.
+if (window.eventSender)
+    eventSender.keyDown('a');
+
+shouldBeEqualToString("sessionStorage.setItemSynchronousKeydownTestValue", "1");
+
+sessionStorage.removeItem("setItemSynchronousKeydownTestValue");
+</script>
+</body>
+</html>
index 30b85e1..c758c72 100644 (file)
@@ -1,3 +1,19 @@
+2017-06-05  Chris Dumez  <cdumez@apple.com>
+
+        ASSERTION FAILED: RunLoop::isMain() in com.apple.WebKit: IPC::Connection::sendSyncMessage + 128
+        https://bugs.webkit.org/show_bug.cgi?id=172943
+        <rdar://problem/31288058>
+
+        Reviewed by Alexey Proskuryakov.
+
+        In Connection::sendMessage(), make sure we only ever transform asynchronous messages into synchronous
+        ones if sendMessage() is called on the main thread. This is necessary because we no longer support
+        sending synchronous messages from a background thread since r205125.
+
+        * Platform/IPC/Connection.cpp:
+        (IPC::Connection::sendMessage):
+        (IPC::Connection::sendSyncMessage):
+
 2017-06-05  Joseph Pecoraro  <pecoraro@apple.com>
 
         Revert r217405, this headerpad increase is no longer needed.
index b387b6b..158079e 100644 (file)
@@ -379,7 +379,7 @@ bool Connection::sendMessage(std::unique_ptr<Encoder> encoder, OptionSet<SendOpt
     if (!isValid())
         return false;
 
-    if (m_inDispatchMessageMarkedToUseFullySynchronousModeForTesting && !encoder->isSyncMessage() && !(encoder->messageReceiverName() == "IPC")) {
+    if (RunLoop::isMain() && m_inDispatchMessageMarkedToUseFullySynchronousModeForTesting && !encoder->isSyncMessage() && !(encoder->messageReceiverName() == "IPC")) {
         uint64_t syncRequestID;
         auto wrappedMessage = createSyncMessageEncoder("IPC", "WrappedAsyncMessageForTesting", encoder->destinationID(), syncRequestID);
         wrappedMessage->setFullySynchronousModeForTesting();