test: remove a bunch of usage of the remote module (#21119)
This commit is contained in:
parent
4f1536479e
commit
26ecf63ab4
22 changed files with 124 additions and 125 deletions
11
spec-main/fixtures/module/delete-buffer.js
Normal file
11
spec-main/fixtures/module/delete-buffer.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
const path = require('path')
|
||||
const { remote } = require('electron')
|
||||
const { Buffer } = window
|
||||
|
||||
delete window.Buffer
|
||||
delete global.Buffer
|
||||
|
||||
// Test that remote.js doesn't use Buffer global
|
||||
remote.require(path.join(__dirname, 'print_name.js')).echo(Buffer.from('bar'))
|
||||
|
||||
window.test = Buffer.from('buffer')
|
5
spec-main/fixtures/module/preload-remote.js
Normal file
5
spec-main/fixtures/module/preload-remote.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
const { ipcRenderer, remote } = require('electron')
|
||||
|
||||
window.onload = function () {
|
||||
ipcRenderer.send('remote', typeof remote)
|
||||
}
|
36
spec-main/fixtures/module/print_name.js
Normal file
36
spec-main/fixtures/module/print_name.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
exports.print = function (obj) {
|
||||
return obj.constructor.name
|
||||
}
|
||||
|
||||
exports.echo = function (obj) {
|
||||
return obj
|
||||
}
|
||||
|
||||
const typedArrays = {
|
||||
Int8Array,
|
||||
Uint8Array,
|
||||
Uint8ClampedArray,
|
||||
Int16Array,
|
||||
Uint16Array,
|
||||
Int32Array,
|
||||
Uint32Array,
|
||||
Float32Array,
|
||||
Float64Array
|
||||
}
|
||||
|
||||
exports.typedArray = function (type, values) {
|
||||
const constructor = typedArrays[type]
|
||||
const array = new constructor(values.length)
|
||||
for (let i = 0; i < values.length; ++i) {
|
||||
array[i] = values[i]
|
||||
}
|
||||
return array
|
||||
}
|
||||
|
||||
exports.getNaN = function () {
|
||||
return NaN
|
||||
}
|
||||
|
||||
exports.getInfinity = function () {
|
||||
return Infinity
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue