refactor: use IPC helpers in window-setup (#17948)

This commit is contained in:
Milan Burda
2019-07-09 01:43:49 +02:00
committed by Alexey Kuzmin
parent c3ae476deb
commit 419ce494e9
7 changed files with 72 additions and 93 deletions

View File

@@ -618,9 +618,9 @@ describe('chromium feature', () => {
w.close()
})
it('does nothing when origin of current window does not match opener', (done) => {
it('fails when origin of current window does not match opener', (done) => {
listener = (event) => {
expect(event.data).to.equal('')
expect(event.data).to.equal(null)
done()
}
window.addEventListener('message', listener)
@@ -666,10 +666,10 @@ describe('chromium feature', () => {
if (webview != null) webview.remove()
})
it('does nothing when origin of webview src URL does not match opener', (done) => {
it('fails when origin of webview src URL does not match opener', (done) => {
webview = new WebView()
webview.addEventListener('console-message', (e) => {
expect(e.message).to.equal('')
expect(e.message).to.equal('null')
done()
})
webview.setAttribute('allowpopups', 'on')

View File

@@ -1,7 +1,11 @@
<html>
<body>
<script type="text/javascript" charset="utf-8">
window.opener.postMessage(window.opener.location.href, '*')
try {
window.opener.postMessage(window.opener.location.href, '*')
} catch {
window.opener.postMessage(null, '*')
}
</script>
</body>
</html>