-
Notifications
You must be signed in to change notification settings - Fork 15k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable code cache for custom protocols
- Loading branch information
Showing
15 changed files
with
526 additions
and
6 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
395 changes: 395 additions & 0 deletions
395
patches/chromium/feat_allow_code_cache_in_custom_schemes.patch
Large diffs are not rendered by default.
Oops, something went wrong.
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,9 @@ | ||
<html> | ||
<body> | ||
<!-- Use mocha which has a large enough js file --> | ||
<script src="mocha.js"></script> | ||
<script> | ||
mocha.setup('bdd'); | ||
</script> | ||
</body> | ||
</html> |
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,38 @@ | ||
const path = require('node:path'); | ||
const { once } = require('node:events'); | ||
const { pathToFileURL } = require('node:url'); | ||
const { BrowserWindow, app, protocol, net, session } = require('electron'); | ||
|
||
if (process.argv.length < 4) { | ||
console.error('Must pass allow_code_cache code_cache_dir'); | ||
process.exit(1); | ||
} | ||
|
||
protocol.registerSchemesAsPrivileged([ | ||
{ | ||
scheme: 'atom', | ||
privileges: { | ||
standard: true, | ||
codeCache: process.argv[2] === 'true' | ||
} | ||
} | ||
]); | ||
|
||
app.once('ready', async () => { | ||
const codeCachePath = process.argv[3]; | ||
session.defaultSession.setCodeCachePath(codeCachePath); | ||
|
||
protocol.handle('atom', (request) => { | ||
let { pathname } = new URL(request.url); | ||
if (pathname === '/mocha.js') { pathname = path.resolve(__dirname, '../../../node_modules/mocha/mocha.js'); } else { pathname = path.join(__dirname, pathname); } | ||
return net.fetch(pathToFileURL(pathname).toString()); | ||
}); | ||
|
||
const win = new BrowserWindow({ show: false }); | ||
win.loadURL('atom://host/main.html'); | ||
await once(win.webContents, 'did-finish-load'); | ||
// Reload to generate code cache. | ||
win.reload(); | ||
await once(win.webContents, 'did-finish-load'); | ||
app.exit(); | ||
}); |
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-refresh-page", | ||
"main": "main.js" | ||
} |