Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow customizing browser data location (#33554)
* feat: redirect Electron/Chromium cache location * fix: network services should also use browserData * test: browserData * chore: no need to explicitly create dir * feat: browserData => sessionData * test: check existings of specific items * docs: add background on userData and sessionData Co-authored-by: emmanuel.kimmerlin@thomsonreuters.com <emmanuel.kimmerlin@thomsonreuters.com>
- Loading branch information
Showing
12 changed files
with
128 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const http = require('http'); | ||
const { app, ipcMain, BrowserWindow } = require('electron'); | ||
|
||
if (process.argv.length > 3) { | ||
app.setPath(process.argv[2], process.argv[3]); | ||
} | ||
|
||
const html = ` | ||
<script> | ||
async function main() { | ||
localStorage.setItem('myCat', 'Tom') | ||
const db = indexedDB.open('db-name', 1) | ||
await new Promise(resolve => db.onsuccess = resolve) | ||
await navigator.serviceWorker.register('sw.js', {scope: './'}) | ||
} | ||
main().then(() => { | ||
require('electron').ipcRenderer.send('success') | ||
}) | ||
</script> | ||
`; | ||
|
||
const js = 'console.log("From service worker")'; | ||
|
||
app.once('ready', () => { | ||
ipcMain.on('success', () => { | ||
app.quit(); | ||
}); | ||
|
||
const server = http.createServer((request, response) => { | ||
if (request.url === '/') { | ||
response.writeHead(200, { 'Content-Type': 'text/html' }); | ||
response.end(html); | ||
} else if (request.url === '/sw.js') { | ||
response.writeHead(200, { 'Content-Type': 'text/javascript' }); | ||
response.end(js); | ||
} | ||
}).listen(0, '127.0.0.1', () => { | ||
const serverUrl = 'http://127.0.0.1:' + server.address().port; | ||
const mainWindow = new BrowserWindow({ show: false, webPreferences: { webSecurity: true, nodeIntegration: true, contextIsolation: false } }); | ||
mainWindow.loadURL(serverUrl); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "electron-test-set-path", | ||
"main": "main.js" | ||
} |