|
52 | 52 | #include "mozilla/dom/ipc/StructuredCloneData.h" |
53 | 53 | #include "mozilla/dom/DOMStringList.h" |
54 | 54 | #include "mozilla/jsipc/CrossProcessObjectWrappers.h" |
| 55 | +#include "mozilla/recordreplay/ParentIPC.h" |
55 | 56 | #include "nsPrintfCString.h" |
56 | 57 | #include "nsXULAppAPI.h" |
57 | 58 | #include "nsQueryObject.h" |
@@ -593,11 +594,35 @@ class MMListenerRemover { |
593 | 594 | RefPtr<nsFrameMessageManager> mMM; |
594 | 595 | }; |
595 | 596 |
|
| 597 | +// When recording or replaying, return whether a message should be received in |
| 598 | +// the middleman process instead of the recording/replaying process. |
| 599 | +static bool DirectMessageToMiddleman(const nsAString& aMessage) { |
| 600 | + // Middleman processes run developer tools server code and need to receive |
| 601 | + // debugger related messages. The session store flush message needs to be |
| 602 | + // received in order to cleanly shutdown the process. |
| 603 | + return (StringBeginsWith(aMessage, NS_LITERAL_STRING("debug:")) && |
| 604 | + recordreplay::parent::DebuggerRunsInMiddleman()) || |
| 605 | + aMessage.EqualsLiteral("SessionStore:flush"); |
| 606 | +} |
| 607 | + |
596 | 608 | void nsFrameMessageManager::ReceiveMessage( |
597 | 609 | nsISupports* aTarget, nsFrameLoader* aTargetFrameLoader, bool aTargetClosed, |
598 | 610 | const nsAString& aMessage, bool aIsSync, StructuredCloneData* aCloneData, |
599 | 611 | mozilla::jsipc::CpowHolder* aCpows, nsIPrincipal* aPrincipal, |
600 | 612 | nsTArray<StructuredCloneData>* aRetVal, ErrorResult& aError) { |
| 613 | + // If we are recording or replaying, we will end up here in both the |
| 614 | + // middleman process and the recording/replaying process. Ignore the message |
| 615 | + // in one of the processes, so that it is only received in one place. |
| 616 | + if (recordreplay::IsRecordingOrReplaying()) { |
| 617 | + if (DirectMessageToMiddleman(aMessage)) { |
| 618 | + return; |
| 619 | + } |
| 620 | + } else if (recordreplay::IsMiddleman()) { |
| 621 | + if (!DirectMessageToMiddleman(aMessage)) { |
| 622 | + return; |
| 623 | + } |
| 624 | + } |
| 625 | + |
601 | 626 | MOZ_ASSERT(aTarget); |
602 | 627 |
|
603 | 628 | nsAutoTObserverArray<nsMessageListenerInfo, 1>* listeners = |
|
0 commit comments