We are setting kiosk-type workstations with chromium browser running in incognito mode. There is a need to have redux-devtools extension for development purposes.
We managed in install it using scripts. Basically uploaded bundles and manifest.json to
/usr/share/chromium-browser/extensions
In non-incognito mode it works. And there is a way to enable it in incognito move using UI (settings for the extension).
But the thing is that we have no access for this interaction and we have to do it somehow programmatically. Looks like its not some browser setting but extension's one. Is there any way to do it using bash or smth. similar?
There is no direct way to do it. But I've manage to do this in no so obvious way. I made it work by directly modifying preferences file. To make it work all chrome instances should be closed. Also instead of installing extension just unpack it somewhere you know. So here is how to start chrome
`chrome --incognito --load-extension=<path/to/unpacked/extension>`
This will start chrome with extension installed meaning that some preference entries will be created. Now we need to modify value that responsible for allowing extension in incognito mode. For this I wrote a small python3 script:
extension_incognito_enabled.py
import json
import os
import sys
google_chrome_preferences ="/home/j2ko/.config/google-chrome/Default/Preferences"
incognito_value = (False, True)[sys.argv[1] == "true"]
print("Closing all chrome instances")
os.system('killall chrome')
#As we load extension using --load-extension flag we can use path to it
field_to_compare="path"
field_value_to_compare_with="/home/j2ko/Downloads/isAllowedAccess"
jsonPreferences =""
with open(google_chrome_preferences, "r+") as jsonFile:
jsonPreferences = json.load(jsonFile)
settings = jsonPreferences["extensions"]["settings"]
for extension_name in settings:
extension_setting = settings[extension_name]
if extension_setting[field_to_compare] == field_value_to_compare_with:
extension_setting["incognito"] = incognito_value
print("Successfully modified file. Now incognito mode value is ", incognito_value)
break
with open(google_chrome_preferences, "w+") as jsonFile:
json.dump(jsonPreferences, jsonFile)
I've tested it using isAllowedAccess. So to suit your needs you need to modify script and provide proper values for field_value_to_compare_with (which actually equals to --load-extension value) and provide correct google_chrome_preferences value.
You can use script as :
extension_incognito_enabled.py true # to enable
extension_incognito_enabled.py false # to disable
If you only have python2 simply remove print lines and it should work as well.
I'm dabbing into switching over our acceptance tests to the Capybara/Apparition driver. I want to add specific Chrome browser preferences for the download path.
I can't find any documentation on this, and by the look of things I can't use a Chrome options object like I would with Capybara, Selenium and chromedriver, such as:
#options = Selenium::WebDriver::Chrome::Options.new
def specific_chrome_options
preferences = {
prompt_for_download: false,
default_directory: FilesDownloadHelper::PATH # custom profile needed to test file downloads
}
#options.add_preference(:download, preferences)
I've tried to set this with a '--user-data-dir' args and preferences file created during run, but it doesn't seem like it is picking it up.
Perhaps the driver is still in a beta state for these kind of things?
With apparition downloads should go to whatever directory Capybara.save_path is set to.
I added the preference ExtensionInstallSources (as per: http://www.chromium.org/administrators/policy-list-3#ExtensionInstallSources ), it still is not allowing me to install my "app.crx" from my URL. I added it as follows:
File: /home/myuser/.config/google-chrome/Default/Preferences
"extensions": {
"ExtensionInstallSources": [ "http://myurl.com/*" ],
...elided...
Yet, when I go to the url http://myurl.com/myapp/app.crx it tells me it cannot install from that url. How do I fix this?
MORE INFO:
It appears that Preferences file is not the correct one to edit. I downloaded an example on from here: http://dl.google.com/dl/edgedl/chrome/policy/policy_templates.zip as specified here: http://support.google.com/chrome/a/bin/answer.py?hl=en&answer=187945
That provides a "chrome.json" file but does not specify where to install this. I tried installing it in the .config/chrome/Default folder but that doesn't work.
My chrome.js file is:
// Policy template for Linux.
// Uncomment the policies you wish to activate and change their values to
// something useful for your case. The provided values are for reference only
// and do not provide meaningful defaults!
{
"ExtensionInstallSources": ["http://myurl.lamp/*"]
}
It still does not work!
2ND UPDATE:
I put the setting in /etc/opt/chrome/policies/managed/test_policy.json as specified here: http://www.chromium.org/administrators/linux-quick-start and it still does not work!
3RD UPDATE:
I checked chrome://policy and it shows the permission is there! It still won't let me install crx's from the URL though! It shows the value for ExtensionInstallSources is:
http://myurl.lamp/*,http://localhost/*,http://192.168.1.109/*,*://myurl.lamp/*,file:///*
But none of those work!
I just tried this using chrome unstable (35.0.1908.4) in a test ubuntu virtual machine and it worked fine. Did you restart chrome after changing the policy file?
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
I'm working in a project which involves using IndexedDB.
As I'm begining to know this technology, I need to be able to delete an indexedDB by hand so I can start over.
I found the way to do it in Firefox, but I can't find the way for Google Chrome.
I tried deleting the content of this folder (I'm using Mac):
{home}/Library/Application Support/Google/Chrome/Default/IndexedDB
but it seems Chrome stil have the DB anywhere so I can't start over.
I've had success running the following in Chrome:
indexedDB.deleteDatabase('DB NAME')
In theory, all you need to do to delete an IndexedDB in Chrome is:
In Chrome, go to Options > Under the Hood > Content Settings > All cookies and Site Data > find the domain where you created the IndexedDB
Hit either the "X" or click "Indexed Database" > Remove
In Windows, the file is located here:
%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\IndexedDB
On Mac, do the following:
In Chrome, go to "Settings" (or "Preferences" under the Chrome menu)
Click "show advanced settings" (at the bottom of the page)
Go to "Privacy" > "Content Settings" > "All cookies and Site Data" > find the domain where you created the IndexedDB
Hit either the "X" or click "Indexed Database" > Remove
On Mac, the folder is located here:
/Users/[USERNAME]/Library/Application Support/Google/Chrome/Default/IndexedDB/
On Linux, the folder is located at:
/home/[USERNAME]/.config/google-chrome/Default/IndexedDB/
Alternarive is to do it in the developers console, using this command:
indexedDB.deleteDatabase("databaseName")
In Chrome webkit you can use webkitGetDatabaseNames which returns all database names
With this code, you can delete all local indexedDB:
window.indexedDB.webkitGetDatabaseNames().onsuccess = function(sender,args)
{
var r = sender.target.result;
for(var i in r)
indexedDB.deleteDatabase(r[i]);
};
To remove all Chrome IndexedDB databases run the following in OSX terminal emulator.
rm -rf ${HOME}/Library/Application\ Support/Google/Chrome/Default/IndexedDB/*
Now restart your browser and that's it.
Because I need to purge IndexedDB databases very often, I have set up an alias in my ~./bash_profile.
alias purge-idb="rm -rf ${HOME}/Library/Application\ Support/Google/Chrome/Default/IndexedDB/*"
Chrome -> Inspector Window -> Application -> look at left hand menu -> Storage -> IndexedDB
You have to be on your application's page though. Also I think Safari expires IDB data after 7 days or something.
write this code segment in console
window.indexedDB.deleteDatabase(<your db name>)
To delete an IndexedDB from the OS X version of Chrome:
1) In Preferences, show Advanced Settings then click the "Content Settings" button under the "Privacy" section.
2) In the "Content Settings" popup, click the "All Cookies and Site Data" button under the "Cookies" section.
3) In the "Cookies and site data" popup, use the "Search Cookies" textbox to look up the domain that is the source of the IndexedDB.
4) Click on the domain entry in the list.
5) Click on the "indexed database" tag listed under the domain.
6) Click on the "Remove" button in the drop down detail for the indexed database.
Chrome Developer tools now have an option to delete all databases for an app, under "Application/Clear Storage".
In Debian GNU/Linux directory
/home/[username]/.config/google-chrome/Default/IndexedDB/chrome-xxx.indexeddb.leveldb/
contains regular files (for example):
000003.log, CURRENT, LOCK, LOG, MANIFEST-000002
It's not possible to delete IndexedDB database (as opposed to stores and indexes) programmatically.
As for manual workarounds, this post details the location of the database on Windows systems for Firefox and Chrome.
Update: Thanks to developer Joshua Bell, Chrome implements an off-spec (but insanely useful) deleteDatabase method on the window.indexedDB object. Here's the crbug that landed this patch. Moreover, in newer versions of IE, you can delete databases via a settings panel.
This is maybe overkill for your specific question, but I kept ending up here in my struggle to delete my idb.
My solution in the end was based on mozilla's documentation, but required that I first close the database.
For me, in Javascript, the code looked like this:
my_db_instance.close(function(e){console.log(e)});
var DBDeleteRequest = indexedDB.deleteDatabase("my_db_name");
// When i had the base open, the closure was blocked, so i left this here
DBDeleteRequest.onblocked = function(event) {
console.log("Blocked");
};
DBDeleteRequest.onerror = function(event) {
console.log("Error deleting database.");
console.log(event);
};
DBDeleteRequest.onsuccess = function(event) {
console.log("Database deleted successfully");
};
In order to complete #Judson's answer, based on #fullstacklife's comment; for deleting IndexedDB in chrome using javascript you should:
let currentIDB = indexedDB.open("DB_NAME", DB_VERSION_INTEGER);
currentIDB.onblocked = function(){
//
};
currentIDB.onerror = function(){
//
};
currentIDB.onsuccess = function(){
var idb = currentIDB.result;
idb.close();
indexedDB.deleteDatabase("DB_NAME");
};
To delete IndexedDB in Chrome on Android:
Settings
Site settings
Data stored
Search needed site and press
Delete stored data
(You cannot delete IndexedDB via Settings -> Privacy and security section, what is quite misleading...)
Alternatively, use your web application in a new incognito window, and close it when you're done: database deleted.
In chrome OSX- /Users/user/Library/Application Support/Google/Chrome/Default/IndexedDB
Firefox OSX - Users/user/Library/Application Support/Firefox/Profiles/4zaemxcn.default/indexedDB
You just need to make visible the library folder. All of the files are stored in folders(which are called as domain name) and the files use hash, but you can figure out the name of database from it.
You can delete data from IDB because it is a client side database and all of the data is stored locally.
In windows, you can manually delete the whole IndexedDB databases by locating the IndexedDB directory for the browser and deleting it
For Chrome:
C:\Users\user-name\AppData\Local\Google\Chrome\User Data\Profile 1\IndexedDB
You can delete every folder which clears up the indexedDB. You can start over now.
I needed to get rid of an indexedDB in Chrome. So I search for this lousy thing called "email assistant" on my computer using MasterSeeker. Found the thing in a bunch folders that were indexedDB in Chrome. It seemed too easy that I just delete those files. I looked up how, and ended up here. I went to chrome settings with my Windows 10 PC. I just gave it a shot at trying to clear the browsing data. Presto - all those files disappeared from indexedDB, including that dreaded "email assistant" crapola. Now when I look in the indexedDB folder all I see that has reappeared is https_mail.google.com_0.indexeddb.leveldb - which looks like a safe non-irritating thing.
//By for loop
const deleteAllDBs=async()=>{
const existingDBs=await indexedDB.databases()
for (let i = 0; i < existingDBs.length; i++) {
indexedDB.deleteDatabase(existingDBs[i].name)
}
}
//By forEach loop
const dbs = await window.indexedDB.databases()
dbs.forEach(db => { window.indexedDB.deleteDatabase(db.name) })
Since most of the answers not mentioned how to find the db names:
Open the site you want db to be cleared.
Press F12 in Chrome, select console regime.
Type indexedDB.databases().then(res => console.log(res)) to learn database names used by this website (open the result with interactive console, find the name).
Finally, as mentioned above, execute in the console indexedDB.deleteDatabase('<your database name>').