spec: "new-window" event of <webview>
This commit is contained in:
parent
fefeb39757
commit
9c92f2e692
3 changed files with 37 additions and 0 deletions
13
spec/fixtures/pages/target-name.html
vendored
Normal file
13
spec/fixtures/pages/target-name.html
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
<html>
|
||||
<body>
|
||||
<a id="a", href="http://host" target="target">link</a>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
var event = new MouseEvent('click', {
|
||||
'view': window,
|
||||
'bubbles': true,
|
||||
'cancelable': true
|
||||
});
|
||||
document.getElementById('a').dispatchEvent(event);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
7
spec/fixtures/pages/window-open.html
vendored
Normal file
7
spec/fixtures/pages/window-open.html
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
<html>
|
||||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
window.open('http://host', 'host');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -46,3 +46,20 @@ describe '<webview> tag', ->
|
|||
webview.setAttribute 'nodeintegration', 'on'
|
||||
webview.src = "file://#{fixtures}/pages/d.html"
|
||||
document.body.appendChild webview
|
||||
|
||||
describe 'new-window event', ->
|
||||
it 'emits when window.open is called', (done) ->
|
||||
webview.addEventListener 'new-window', (e) ->
|
||||
assert.equal e.url, 'http://host'
|
||||
assert.equal e.frameName, 'host'
|
||||
done()
|
||||
webview.src = "file://#{fixtures}/pages/window-open.html"
|
||||
document.body.appendChild webview
|
||||
|
||||
it 'emits when link with target is called', (done) ->
|
||||
webview.addEventListener 'new-window', (e) ->
|
||||
assert.equal e.url, 'http://host/'
|
||||
assert.equal e.frameName, 'target'
|
||||
done()
|
||||
webview.src = "file://#{fixtures}/pages/target-name.html"
|
||||
document.body.appendChild webview
|
||||
|
|
Loading…
Reference in a new issue