Merge branch 'master' into native-window-open
This commit is contained in:
commit
7ac93045b7
157 changed files with 2239 additions and 1058 deletions
11
spec/fixtures/api/allocate-memory.html
vendored
Normal file
11
spec/fixtures/api/allocate-memory.html
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
window.bigBuffer = new Uint8Array(1024 * 1024 * 64)
|
||||
window.bigBuffer.fill(5, 50, 1024 * 1024)
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
17
spec/fixtures/api/beforeunload-false-prevent3.html
vendored
Normal file
17
spec/fixtures/api/beforeunload-false-prevent3.html
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<html>
|
||||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
// Only prevent unload on the first three window closes
|
||||
var unloadPreventedCount = 0;
|
||||
window.onbeforeunload = function() {
|
||||
setTimeout(function() {
|
||||
require('electron').remote.getCurrentWindow().emit('onbeforeunload');
|
||||
}, 0);
|
||||
if (unloadPreventedCount < 3) {
|
||||
unloadPreventedCount++;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
27
spec/fixtures/api/sandbox.html
vendored
27
spec/fixtures/api/sandbox.html
vendored
|
@ -1,5 +1,18 @@
|
|||
<html>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
function timeout(ms) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, ms)
|
||||
})
|
||||
}
|
||||
async function invokeGc () {
|
||||
// it seems calling window.gc once does not guarantee garbage will be
|
||||
// collected, so we repeat 10 times with interval of 100 ms
|
||||
for (let i = 0; i < 10; i++) {
|
||||
window.gc()
|
||||
await timeout(100)
|
||||
}
|
||||
}
|
||||
if (window.opener) {
|
||||
window.callback = () => {
|
||||
opener.require('electron').ipcRenderer.send('answer', document.body.innerHTML)
|
||||
|
@ -7,6 +20,20 @@
|
|||
} else {
|
||||
const {ipcRenderer} = require('electron')
|
||||
const tests = {
|
||||
'allocate-memory': async () => {
|
||||
await invokeGc()
|
||||
const {privateBytes: bytesBeforeOpen} = process.getProcessMemoryInfo()
|
||||
let w = open('./allocate-memory.html')
|
||||
await invokeGc()
|
||||
const {privateBytes: bytesAfterOpen} = process.getProcessMemoryInfo()
|
||||
w.close()
|
||||
w = null
|
||||
await invokeGc()
|
||||
const {privateBytes: bytesAfterClose} = process.getProcessMemoryInfo()
|
||||
ipcRenderer.send('answer', {
|
||||
bytesBeforeOpen, bytesAfterOpen, bytesAfterClose
|
||||
})
|
||||
},
|
||||
'window-events': () => {
|
||||
document.title = 'changed'
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue