spec: Add test for allowpopups attribute

This commit is contained in:
Cheng Zhao 2015-09-22 21:17:50 +08:00
Родитель 9cbdde2eba
Коммит f06f8ae73b
2 изменённых файлов: 32 добавлений и 0 удалений

12
spec/fixtures/pages/window-open-hide.html поставляемый Normal file
Просмотреть файл

@ -0,0 +1,12 @@
<html>
<body>
<script type="text/javascript" charset="utf-8">
var w = window.open('http://host', '', 'show=no');
if (w == null)
console.log('null');
else
console.log('window');
</script>
</body>
</html>

Просмотреть файл

@ -201,6 +201,26 @@ describe '<webview> tag', ->
webview.src = "file://#{fixtures}/pages/partition/one.html"
document.body.appendChild webview
describe 'allowpopups attribute', ->
it 'can not open new window when not set', (done) ->
listener = (e) ->
assert.equal e.message, 'null'
webview.removeEventListener 'console-message', listener
done()
webview.addEventListener 'console-message', listener
webview.src = "file://#{fixtures}/pages/window-open-hide.html"
document.body.appendChild webview
it 'can open new window when set', (done) ->
listener = (e) ->
assert.equal e.message, 'window'
webview.removeEventListener 'console-message', listener
done()
webview.addEventListener 'console-message', listener
webview.setAttribute 'allowpopups', 'on'
webview.src = "file://#{fixtures}/pages/window-open-hide.html"
document.body.appendChild webview
describe 'new-window event', ->
it 'emits when window.open is called', (done) ->
webview.addEventListener 'new-window', (e) ->