New issue
Advanced search Search tips

Issue 617931 link

Starred by 76 users

Issue metadata

Status: Fixed
Owner: ----
Closed: Jan 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocked on:
issue 773874
issue 775703

Blocking:
issue 775911



Sign in to add a comment

Save and restore browser sessions

Project Member Reported by alexclarke@chromium.org, Jun 7 2016

Issue description

One common task done by testing frameworks is to manipulate the browser into a known state prior to running a test (e.g. wiping the cache, setting cookies and installing service workers).  This can take several seconds and has to be repeated for every test adding significant overhead.

If headless chrome was able to save and restore session state, this would significantly improve this story.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Jun 9 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/25c2c0123425d8ab3c9c02998d02d7accd1c42e2

commit 25c2c0123425d8ab3c9c02998d02d7accd1c42e2
Author: skyostil <skyostil@chromium.org>
Date: Thu Jun 09 12:54:12 2016

headless: Introduce a browser context

A headless browser context can be used to isolate different WebContents
from one another. Each context has a separate cache, cookies, local
storage and other profile-related data.

This patch also adds a way to create a HeadlessWebContents using a
specific browser context instead of the default one. This can be used to
isolate tabs from one another.

Design doc: https://docs.google.com/document/d/1XAKvrxtSEoe65vNghSWC5S3kJ--z2Zpt2UWW1Fi8GiM/edit?pref=2&pli=1#heading=h.7r3ycehq63g2

BUG= 546953 , 617931 

Review-Url: https://codereview.chromium.org/2043603004
Cr-Commit-Position: refs/heads/master@{#398853}

[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/BUILD.gn
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/app/headless_shell.cc
[rename] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_browser_context_impl.cc
[rename] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_browser_context_impl.h
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_browser_impl.cc
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_browser_impl.h
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_browser_main_parts.cc
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_browser_main_parts.h
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_devtools.cc
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_devtools.h
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_url_request_context_getter.cc
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_web_contents_impl.cc
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_web_contents_impl.h
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/headless_browser_browsertest.cc
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/headless_web_contents_browsertest.cc
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/public/headless_browser.cc
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/public/headless_browser.h
[add] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/public/headless_browser_context.h
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/public/headless_web_contents.h
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/test/headless_browser_test.cc
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/test/headless_browser_test.h

Project Member

Comment 2 by bugdroid1@chromium.org, Jun 15 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/25c2c0123425d8ab3c9c02998d02d7accd1c42e2

commit 25c2c0123425d8ab3c9c02998d02d7accd1c42e2
Author: skyostil <skyostil@chromium.org>
Date: Thu Jun 09 12:54:12 2016

headless: Introduce a browser context

A headless browser context can be used to isolate different WebContents
from one another. Each context has a separate cache, cookies, local
storage and other profile-related data.

This patch also adds a way to create a HeadlessWebContents using a
specific browser context instead of the default one. This can be used to
isolate tabs from one another.

Design doc: https://docs.google.com/document/d/1XAKvrxtSEoe65vNghSWC5S3kJ--z2Zpt2UWW1Fi8GiM/edit?pref=2&pli=1#heading=h.7r3ycehq63g2

BUG= 546953 , 617931 

Review-Url: https://codereview.chromium.org/2043603004
Cr-Commit-Position: refs/heads/master@{#398853}

[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/BUILD.gn
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/app/headless_shell.cc
[rename] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_browser_context_impl.cc
[rename] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_browser_context_impl.h
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_browser_impl.cc
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_browser_impl.h
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_browser_main_parts.cc
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_browser_main_parts.h
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_devtools.cc
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_devtools.h
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_url_request_context_getter.cc
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_web_contents_impl.cc
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/browser/headless_web_contents_impl.h
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/headless_browser_browsertest.cc
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/lib/headless_web_contents_browsertest.cc
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/public/headless_browser.cc
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/public/headless_browser.h
[add] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/public/headless_browser_context.h
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/public/headless_web_contents.h
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/test/headless_browser_test.cc
[modify] https://crrev.com/25c2c0123425d8ab3c9c02998d02d7accd1c42e2/headless/test/headless_browser_test.h

Components: UI>Browser>Sessions
Owner: skyos...@chromium.org
Status: Started (was: Untriaged)
Sami, assigning to you - is this complete?
Cc: skyos...@chromium.org
Owner: ----
Status: Available (was: Started)
No, we only let you create and destroy contexts -- there's no mechanism to de/serialize them at the moment. I think I'll leave this available for now since I don't think anyone is waiting for this urgently.
Components: Internals>Headless
Cc: pbomm...@chromium.org
 Issue 737184  has been merged into this issue.
 Issue 747394  has been merged into this issue.
 Issue 722431  has been merged into this issue.

Comment 10 by say...@saylas.ru, Jul 21 2017

As headless chrome has been released and there are pretty lot of bugs opened with this issue recently, may be it's possible now to take further steps to apply patch?

Comment 11 by say...@saylas.ru, Jul 21 2017

By the way another issue is that I'm trying to start Chrome in --headless with defined --user-data-dir switch.

As far as I can understand from the sources, although headless Chrome by default should start in incognito mode, it's disabled when the user-data-dir flag exists:

// Run a browser context in an incognito mode. Enabled by default.
  bool incognito_mode;

if (command_line.HasSwitch(switches::kUserDataDir)) {
    builder.SetUserDataDir(
        command_line.GetSwitchValuePath(switches::kUserDataDir));
    builder.SetIncognitoMode(false);
  }

But it seems that regardless to that flag no profile data is written to the directory (but the directory is created), very similar to how it behaves in incognito mode.

I suppose that this behavior is not the expected one.

#10: I don't think anyone is currently looking into this. We'll prioritize according to starring. We welcome any support from the community in case someone would like to take a stab at this :)

#11: Using --user-data-dir with the incognito profile is not supported as the incognito profile is stored only temporarily in-memory. The issue that no data is saved even though --user-data-dir is specified is mentioned in #5.
I think that data from --user-data-dir isn't being read either 

Comment 14 Deleted

@skyostil@chromium.org any plans for the mechanism to de/serialize browser contexts ?

Comment 16 by tapio...@gmail.com, Sep 29 2017

It would be really usefull to enable --user-data-dir with --headless
Blockedon: 773874
Blocking: 775703
Blocking: 775911
Blocking: -775703
Blockedon: 775703
why dont use both user-data-dir and headless?
Any news about the issue?

I really want to start using headless with "intl.accept_languages" preference 
https://bugs.chromium.org/p/chromium/issues/detail?id=775911

Comment 24 by ale...@kopytko.ru, Dec 18 2017

Was this fixed in the fix for the issue below?

https://bugs.chromium.org/p/chromium/issues/detail?id=775703
The below fixed allowed supporting saving/restoring Local storage and Cookie store. 

I think that the main thing lacking here would be better support for the PrefStore, although maybe this needs to be taken in a case by case basis since some things in the PrefStore are not supported or make sense in Headless.

Also, if people want to comment on what they are missing from saving/restoring sessions that would help us see what's more important to support first

Comment 26 Deleted

No, it hasn't been fixed in this issue 
https://bugs.chromium.org/p/chromium/issues/detail?id=775703

I tried to use it yesterday, but without any result
Chrome Version 63.0.3239.84
Chromedriver 2.33
Change should be in 64.0.3254.0
Status: Fixed (was: Available)
Now that the profile directory layout in headless mode matches the one used by regular Chrome, you can migrate profiles between the two (or between different headless profiles). We might want to add DevTools commands for serializing and deserializing profiles in the future, but for now the on-disk storage should be good enough.

Sign in to add a comment