Skip to content

Commit 857abcf

Browse files
authored
browser(firefox): make pipe work on Windows (#4058)
1 parent a7beaf6 commit 857abcf

File tree

3 files changed

+50
-7
lines changed

3 files changed

+50
-7
lines changed

browser_patches/firefox/BUILD_NUMBER

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1180
2-
Changed: dgozman@gmail.com Fri Oct 2 09:36:06 PDT 2020
1+
1181
2+
Changed: pavel.feldman@gmail.com Mon, Oct 5, 2020 5:57:35 PM

browser_patches/firefox/juggler/pipe/nsRemoteDebuggingPipe.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ namespace {
2525

2626
StaticRefPtr<nsRemoteDebuggingPipe> gPipe;
2727

28-
const int readFD = 3;
29-
const int writeFD = 4;
30-
3128
const size_t kWritePacketSize = 1 << 16;
3229

3330
#if defined(_WIN32)
3431
HANDLE readHandle;
3532
HANDLE writeHandle;
33+
#else
34+
const int readFD = 3;
35+
const int writeFD = 4;
3636
#endif
3737

3838
size_t ReadBytes(void* buffer, size_t size, bool exact_size)
@@ -107,8 +107,12 @@ nsresult nsRemoteDebuggingPipe::Init(nsIRemoteDebuggingPipeClient* aClient) {
107107
MOZ_ALWAYS_SUCCEEDS(NS_NewNamedThread("Pipe Writer", getter_AddRefs(mWriterThread)));
108108

109109
#if defined(_WIN32)
110-
readHandle = reinterpret_cast<HANDLE>(_get_osfhandle(readFD));
111-
writeHandle = reinterpret_cast<HANDLE>(_get_osfhandle(writeFD));
110+
CHAR pipeReadStr[20];
111+
CHAR pipeWriteStr[20];
112+
GetEnvironmentVariable("PW_PIPE_READ", pipeReadStr, 20);
113+
GetEnvironmentVariable("PW_PIPE_WRITE", pipeWriteStr, 20);
114+
readHandle = reinterpret_cast<HANDLE>(atoi(pipeReadStr));
115+
writeHandle = reinterpret_cast<HANDLE>(atoi(pipeWriteStr));
112116
#endif
113117

114118
MOZ_ALWAYS_SUCCEEDS(mReaderThread->Dispatch(NewRunnableMethod(

browser_patches/firefox/patches/bootstrap.diff

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,45 @@ index f042cc1081850ac60e329b70b5569f8b97d4e4dc..65bcff9b41b9471ef1427e3ea330481c
5858
/**
5959
* Return XPCOM wrapper for the internal accessible.
6060
*/
61+
diff --git a/browser/app/winlauncher/LauncherProcessWin.cpp b/browser/app/winlauncher/LauncherProcessWin.cpp
62+
index 7a8b4a621dd4056dfde1f200c62cf629415cc6a4..e600b2cb78a769a460d27104e1dcb805dbd11ed7 100644
63+
--- a/browser/app/winlauncher/LauncherProcessWin.cpp
64+
+++ b/browser/app/winlauncher/LauncherProcessWin.cpp
65+
@@ -21,6 +21,7 @@
66+
#include "mozilla/WinHeaderOnlyUtils.h"
67+
#include "nsWindowsHelpers.h"
68+
69+
+#include <io.h>
70+
#include <windows.h>
71+
#include <processthreadsapi.h>
72+
73+
@@ -322,8 +323,25 @@ Maybe<int> LauncherMain(int& argc, wchar_t* argv[],
74+
HANDLE stdHandles[] = {::GetStdHandle(STD_INPUT_HANDLE),
75+
::GetStdHandle(STD_OUTPUT_HANDLE),
76+
::GetStdHandle(STD_ERROR_HANDLE)};
77+
-
78+
attrs.AddInheritableHandles(stdHandles);
79+
+ // Playwright pipe installation.
80+
+ bool hasJugglerPipe =
81+
+ mozilla::CheckArg(argc, argv, L"juggler-pipe",
82+
+ static_cast<const wchar_t**>(nullptr),
83+
+ mozilla::CheckArgFlag::None) == mozilla::ARG_FOUND;
84+
+ if (hasJugglerPipe && !mozilla::EnvHasValue("PW_PIPE_READ")) {
85+
+ intptr_t stdio3 = _get_osfhandle(3);
86+
+ intptr_t stdio4 = _get_osfhandle(4);
87+
+ CHAR stdio3str[20];
88+
+ CHAR stdio4str[20];
89+
+ itoa(stdio3, stdio3str, 10);
90+
+ itoa(stdio4, stdio4str, 10);
91+
+ SetEnvironmentVariable("PW_PIPE_READ", stdio3str);
92+
+ SetEnvironmentVariable("PW_PIPE_WRITE", stdio4str);
93+
+ HANDLE pipeHandles[] = {reinterpret_cast<HANDLE>(stdio3),
94+
+ reinterpret_cast<HANDLE>(stdio4)};
95+
+ attrs.AddInheritableHandles(pipeHandles);
96+
+ }
97+
98+
DWORD creationFlags = CREATE_SUSPENDED | CREATE_UNICODE_ENVIRONMENT;
99+
61100
diff --git a/browser/installer/allowed-dupes.mn b/browser/installer/allowed-dupes.mn
62101
index 1e583f9fb014129d791d25b64a727021d6848105..6a91ef0bd0796abf99d8fd54ff6aede94aeb0807 100644
63102
--- a/browser/installer/allowed-dupes.mn

0 commit comments

Comments
 (0)