Save and restore browser sessions |
|||||||||||
Issue descriptionOne 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.
,
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
,
Aug 9 2016
,
Jan 19 2017
Sami, assigning to you - is this complete?
,
Jan 19 2017
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.
,
May 15 2017
,
Jul 4 2017
,
Jul 21 2017
Issue 747394 has been merged into this issue.
,
Jul 21 2017
Issue 722431 has been merged into this issue.
,
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?
,
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.
,
Jul 21 2017
#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.
,
Jul 21 2017
I think that data from --user-data-dir isn't being read either
,
Aug 27 2017
@skyostil@chromium.org any plans for the mechanism to de/serialize browser contexts ?
,
Sep 29 2017
It would be really usefull to enable --user-data-dir with --headless
,
Oct 15 2017
,
Oct 17 2017
,
Oct 24 2017
,
Oct 30 2017
,
Oct 30 2017
,
Nov 1 2017
why dont use both user-data-dir and headless?
,
Dec 17 2017
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
,
Dec 18 2017
Was this fixed in the fix for the issue below? https://bugs.chromium.org/p/chromium/issues/detail?id=775703
,
Dec 18 2017
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
,
Dec 18 2017
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
,
Dec 18 2017
Change should be in 64.0.3254.0
,
Jan 8 2018
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 |
|||||||||||
Comment 1 by bugdroid1@chromium.org
, Jun 9 2016