Reputation: 4164
Does anyone know of a way to get each separate Chrome Window
to run a different background page instance
?
Currently, my problem is that I need to open two chrome windows and have each background page be its own separate instance. This "mimics" the act of two separate users using the extension on their own computer. Doing this will allow me to test the extension as two different people
yet on one computer
. Right now, when I open two Chrome Windows, it uses the one background page instance (as I suppose it should).
I guess any acceptable method would be great, whether that is some form of multiple Chrome sign-ins
or installing different instances
of chrome. The best solution however would be code based, in the realm of the actual Chrome Extension API, if it allows.
Thanks!
Upvotes: 2
Views: 4670
Reputation: 4164
After some time I solved my problem fairly easily. It requires you to have two Google accounts
. So if you do not have two accounts and do not want two accounts, it may be best to use Rob W's answer
on this post...
Steps:
Users
heading, click add new user
background pages
.Upvotes: 1
Reputation: 348992
The only way to have two instances of a background page is to enable split incognito behaviour, and open an incognito window (Ctrl + Shift + N).
To enable split incognito mode, add the following to your manifest file:
"split": "incognito"
If you really want to simulate two or more users, use different data directories, by starting Chrome with the --user-data-dir
flag. For example:
chromium --user-data-dir=/tmp/whatever/
Upvotes: 3
Reputation: 1749
Maybe you could instantiate some "background page object" in the one background page for each open window? Put all your functionality in that class and create some array with all the instances in it.
Just some brainstorming, hope it gets you somewhere.
Upvotes: 0