Add spec for window.open from <webview>
This commit is contained in:
parent
bbc3a71c9f
commit
a184b6afb3
2 changed files with 39 additions and 1 deletions
|
@ -1,8 +1,8 @@
|
|||
|
||||
const assert = require('assert')
|
||||
const http = require('http')
|
||||
const path = require('path')
|
||||
const ws = require('ws')
|
||||
const url = require('url')
|
||||
const remote = require('electron').remote
|
||||
|
||||
const BrowserWindow = remote.require('electron').BrowserWindow
|
||||
|
@ -327,6 +327,25 @@ describe('chromium feature', function () {
|
|||
window.addEventListener('message', listener)
|
||||
b = window.open('file://' + fixtures + '/pages/window-opener-postMessage.html', '', 'show=no')
|
||||
})
|
||||
|
||||
it('works for windows opened from a <webview>', function (done) {
|
||||
const webview = new WebView()
|
||||
webview.addEventListener('console-message', function (e) {
|
||||
webview.remove()
|
||||
assert.equal(e.message, 'message')
|
||||
done()
|
||||
})
|
||||
webview.allowpopups = true
|
||||
webview.src = url.format({
|
||||
pathname: `${fixtures}/pages/webview-opener-postMessage.html`,
|
||||
protocol: 'file',
|
||||
query: {
|
||||
p: `${fixtures}/pages/window-opener-postMessage.html`
|
||||
},
|
||||
slashes: true
|
||||
})
|
||||
document.body.appendChild(webview)
|
||||
})
|
||||
})
|
||||
|
||||
describe('creating a Uint8Array under browser side', function () {
|
||||
|
|
19
spec/fixtures/pages/webview-opener-postMessage.html
vendored
Normal file
19
spec/fixtures/pages/webview-opener-postMessage.html
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script>
|
||||
var windowUrl = decodeURIComponent(window.location.search.substring(3))
|
||||
var opened = window.open(windowUrl, '', 'show=no')
|
||||
window.addEventListener('message', function (event) {
|
||||
try {
|
||||
opened.close()
|
||||
} finally {
|
||||
console.log(event.data)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue