0

In Chrome there is a Strict Site Isolation setting that can be manually enabled in chrome://flags/#enable-site-per-process page. I'm trying to enable this flag when testing Chrome using WebDriver C# bindings but it's not getting enabled.

The switch is listed in https://peter.sh/experiments/chromium-command-line-switches/ so I've tried to add it as an argument in ChromeOptions but this doesn't have any effect.

ChromeOptions options = new ChromeOptions();
options.AddArgument("--site-per-process");
IWebDriver driver = new ChromeDriver(@"c:\browserdrivers",options);
driver.Navigate().GoToUrl("www.google.com");
driver.Quit();

I've also tried setting it as a preference based on the settings listed in https://chromium.googlesource.com/chromium/src/+/master/chrome/common/pref_names.cc

options.AddUserProfilePreference("site_isolation.site_per_processs", true);

but this didn't work either.

Does anyone know how this can be turned on?

user3198015
  • 121
  • 1
  • 2
  • 7

2 Answers2

0

We are deploying this change with a PS script to edit the Local State file on Windows at %AppDataLocal%\Google\Chrome\User Data

The script is a bit basic but will get the job done for us. It is better to use the GPO option but that only works with Chrome 63 and newer unfortunately.


$USRPROF = Get-Childitem env:APPDATA | %{ $_.Value }
$ChromeLocalState = (Get-item $USRPROF).parent.FullName + "\Local\Google\Chrome\User Data\Local State"

#original (Get-Content $ChromeLocalState) | Foreach-Object {$_ -replace '{"browser":{"last_redirect_origin"', '{"browser":{"enabled_labs_experiments":["enable-site-per-process"],"last_redirect_origin"'} | Set-Content $ChromeLocalState

#add site-per-process setting. Ok if it doubles the same nested statement. Chrome will parse it out.
(Get-Content $ChromeLocalState) | Foreach-Object {$_ -replace 'last_redirect_origin', 'enabled_labs_experiments":["enable-site-per-process"],"last_redirect_origin'} | Set-Content $ChromeLocalState
Fiddles
  • 2,790
  • 1
  • 32
  • 35
-1

Based on Fiddles code this version addresses a couple of issues I found in testing. Must be run as the logged in user. See the notes at the end.

The "Local State" json file holds the per-user setting for the 'enable-site-per-process' configuration item that enables this experimental setting

Using the Local system environmental variable to get the users C:\Users\UserID\Appdata\Local folder

$USRPROF = Get-Childitem env:LOCALAPPDATA 

Under that folder is the '\Google\Chrome\User Data' folder which contains the 'Local State' file we need to modify

$ChromeLocalState =  -Join($USRPROF.Value.ToString(),'\','Google\Chrome\User Data\Local State')

Stop Chrome

Stop-Process -Name chrome -Force -ErrorAction SilentlyContinue

add site-per-process setting. Ok if it doubles the same nested statement. Chrome will parse it out.

(Get-Content $ChromeLocalState) | Foreach-Object {$_ -replace 'last_redirect_origin', 'enabled_labs_experiments":["enable-site-per-process"],"last_redirect_origin'} | Set-Content $ChromeLocalState

Find which version of Chrome is installed and launch it

Switch($TRUE) {

{Test-Path 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'} {Start-Processs -FilePath 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe' }

{Test-Path 'C:\Program Files\Google\Chrome\Application\chrome.exe'}       {Start-Processs -FilePath 'C:\Program Files\Google\Chrome\Application\chrome.exe' }

}

Observations during testing

If chrome is running when this script has launched the value in the 'Local State' File is made but does not take effect. If Chrome is then closed, the 'Local State' File is overwritten with information in memory and the setting is Removed!!

So to have the best chance of this working the script has been modified to 1. Stop Chrome 2. Change the setting 3. Relaunch Chrome

Relaunching chrome is optional, the user will be asked to restore open tabs because of the non-standard termination of Chrome.

Further observation is that the local state file is constantly being modified even while chrome is in the background This is another reason to stop chrome first.

wp78de
  • 18,207
  • 7
  • 43
  • 71
DeployGuy
  • 31
  • 2