Chrome headless - Process showing a "--service-request-channel-token". What is it? - google-chrome

Running some tests using Chrome Headless, I noticed an increase of sub-processes launched by Chrome, that contains a "--service-request-channel-token" parameter, followed by a different number (some kind of uuid).
Here's an example:
/opt/google/chrome/chrome --type=renderer --disable-background-timer-throttling --use-gl=swiftshader-webgl --field-trial-handle=13269729711699588785,2304692341994267143,131072 --disable-databases --disable-gpu-compositing --lang=en-US --headless --enable-crash-reporter --num-raster-threads=4 --enable-main-frame-before-activation --service-request-channel-token=1076358315904091895 --renderer-client-id=12373 --shared-files=v8_context_snapshot_data:100,v8_natives_data:101
I tried to search about this parameter but was unlucky.

Related

How to set proerties for Chrome.exe - Need to replace the shortcut argument

I created a shortcut for Chrome.exe and passed the arguments --disable-web-security --user-data-dir="C:/Chrome dev session"
However the arguments works fine when clicking the shortcuts and able to see the security got disabled.
However i want this change to be permanent....no matter how many shortcuts pointing to the chrome, the arguments should get executed automatically
Does argument can be set in any chrome property files ?
Please advise
Thanks
One Solution is touching the registry. However don't want to touch it and looking for a solution without touching registry
Example,
Firefox to run with the parameters "-p username" when I run "firefox.exe"
https://superuser.com/questions/12230/how-to-set-default-parameters-for-an-application
Run regedit and take a look at the key:
`My Computer\HKEY_CLASSES_ROOT\FirefoxHTML\shell\open\command`
Put -p username into the command string at the appropriate place.
Thanks.

enable Chrome flags from the command line

I want to enable a flag (enable-token-binding) while launching chrome.
I can do that using chrome://flags page. but for running tests I need to do it from command line.
I tried
chrome --enable-features=token-binding
chrome --enable-token-binding
None of them worked.
go to chrome://version
Find the command line arguments:
Command Line /Applications/Google Chrome.app/Contents/MacOS/Google Chrome --enable-audio-service-sandbox --flag-switches-begin --enable-features=CookiesWithoutSameSiteMustBeSecure,SameSiteByDefaultCookies --flag-switches-end --enable-audio-service-sandbox
Run the above command with all the arguments and your chrome instance would have all the settings preset.
Try --flag-switches-begin --enable-token-binding --flag-switches-end.
The patter is --flag-switches start and ends capping the flags. Then the names of the flags provided as the parameters within with -- prefixed to them.
Token Binding was removed in Chrome release 70
see https://www.chromestatus.com/feature/5097603234529280
mayankSinha's answer works for the flags he mentions. Note the changed naming convention though: "lower case split by -" convention gets changed to CamelCase.
i.e. same-site-by-default-cookies (as shown in chrome://flags) becomes SameSiteByDefaultCookies

Unable to enable-experimental-web-platform-features by command line for chrome

I am not able to enable-experimental-web-platform-features flag by command line. I am using different user profile which is not the default one of chrome.
I am doing this by following:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
--user-data-dir=D:/dev/chrome/profiles/sahi0 --enable-experimental-web-platform-features --incognito
From a comment by the OP:
Turns out it was working, but it was not replicated in chrome flags. So I was under impression that it's not working at all.
One cannot evaluate whether these items are working by looking only at chrome://flags; one needs to test actual functionality in practice.

Autohotkey: Identify Google Chrome vs Google Chromium

I can't seem to figure this out
On autohotkey, there's documentation on how to identify a window / program running.
Google Chrome and Google Chromium both use the same ahk_class and the same .exe name of chrome.exe
How does one use something like winTitle or winGet to distinguish the difference? I tried looking into PID values but they don't seem to be consistent.
EDIT via WinSpy++
Using winspy++, I ran a simple experiment. 2 Chromium Windows and 2 Chrome Windows so I can have a control group. Differences:
INSTANCE HANDLE: Chrome shows 0F2C0000, Chromium shows A2820000
Process ID: Chrome shows 00003528 (13608), Chromium shows 00001B74 (7028)
Thread ID: Chrome shows 00003524 (13604), Chromium 00000220 (544)
In this case you have two possibilities to distinguish between the two programs:
(1) Using SetTitleMatchMode 2 and the part of the title that all windows of this program have in common:
SetTitleMatchMode 2
If WinExist("- Chromium")
WinActivate
(2) Using "ahk_exe Path":
If WinExist("ahk_exe full_path_of_the_executable_chrome.exe")
WinActivate
To get the full path of the active window process use this:
F1::
WinGet, Path, ProcessPath, A
MsgBox, %Path%
return
Using Windows Spy (came with autohotkey). Is not the same as winspy++
To access Windows Spy found here:
Differences are found in WinTitle

Using --js-flags in Google Chrome to get --trace output

I've looked through various sources online and done a number of Google searches, but I can't seem to find any specific instructions as to how to work with the V8 --trace-* flags in Google Chrome. I've seen a few "You can do this as well in Chrome", but I haven't been able to find what I'm looking for, which is output like this: (snippets are near the near bottom of the post) Optomizing for V8.
I found reference that the data is logged to a file: Profiling Chromium with V8 and I've found that the file is likely named v8.log: (Lost that link) but I haven't found any clues as to how to generate that file, or where it is located. It didn't appear to be in the chrome directory or the user directory.
Apparently I need to enable .map files for chrome.dll as well, but I wasn't able to find anything to help me with that.
The reason I would prefer to use Chrome's V8 for this as opposed to building V8 and using a shell is because the JavaScript I would like to test makes use of DOM, which I do not believe would be included in the V8 shell. However if it is, that would be great to know, then I can rewrite the code to work sans-html file and test. But my guess is that V8 by itself is sans-DOM access, like node.js
So to sum things up;
Running Google Chrome Canary on Windows 7 ultimate x64
Shortcut target is "C:\Users\ArkahnX\AppData\Local\Google\Chrome SxS\Application\chrome.exe" --no-sandbox --js-flags="--trace-opt --trace-bailout --trace-deop" --user-data-dir=C:\chromeDebugProfile
Looking for whether this type of output can be logged from chrome
If so, where would the log be?
If not, what sort of output should I expect, and again, where could I find it?
Thank you for any assistance!
Amending with how I got the answer to work for me
Using the below answer, I installed python to it's default directory, and modified the script so it had the full path to chrome. From there I set file type associations to .py files to python and executed the script. Now every time I open Chrome Canary it will run that python script (at least until I restart my pc, then I'll have to run that script again)
The result is exactly what I was looking for!
On Windows stdout output is suppressed by the fact that chrome.exe is a GUI application. You need to flip Subsystem field in the PE header from IMAGE_SUBSYSTEM_WINDOWS_GUI to WINDOWS_SUBSYSTEM_WINDOWS_CUI to see what V8 outputs to stdout.
You can do it with the following (somewhat hackish) Python script:
import mmap
import ctypes
GUI = 2
CUI = 3
with open("chrome.exe", "r+b") as f:
map = mmap.mmap(f.fileno(), 1024, None, mmap.ACCESS_WRITE)
e_lfanew = (ctypes.c_uint.from_buffer(map, 30 * 2).value)
subsystem = ctypes.c_ushort.from_buffer(map, e_lfanew + 4 + 20 + (17 * 4))
if subsystem.value == GUI:
subsystem.value = CUI
print "patched: gui -> cui"
elif subsystem.value == CUI:
subsystem.value = GUI
print "patched: cui -> gui"
else:
print "unknown subsystem: %x" % (subsystem.value)
Close all Chrome instances and execute this script. When you restart chrome.exe you should see console window appear and you should be able to redirect stdout via >.
If your not keen on hacking the PE entry of chrome then there is alternative for windows.
Because the chrome app doesn't create a console stdout on windows all tracing in v8 (also d8 compiler) is sent to the OutputDebugString instead.
The OutputDebugString writes to a shared memory object that can be read by any other application.
Microsoft has a tool called DebugView which monitors and if required also stream to a log file.
DebugView is free and downloadable from microsoft: http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx