spec: "disablewebsecurity" attribute
This commit is contained in:
parent
947e6aca9b
commit
40ab21d9df
2 changed files with 30 additions and 0 deletions
BIN
spec/fixtures/assets/logo.png
vendored
Normal file
BIN
spec/fixtures/assets/logo.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
|
@ -70,6 +70,36 @@ describe '<webview> tag', ->
|
|||
webview.src = "file://#{fixtures}/pages/referrer.html"
|
||||
document.body.appendChild webview
|
||||
|
||||
describe 'disablewebsecurity attribute', ->
|
||||
it 'does not disable web security when not set', (done) ->
|
||||
src = "
|
||||
<script src='file://#{__dirname}/static/jquery-2.0.3.min.js'></script>
|
||||
<script>console.log('ok');</script>
|
||||
"
|
||||
encoded = btoa(unescape(encodeURIComponent(src)))
|
||||
listener = (e) ->
|
||||
assert /Not allowed to load local resource/.test(e.message)
|
||||
webview.removeEventListener 'console-message', listener
|
||||
done()
|
||||
webview.addEventListener 'console-message', listener
|
||||
webview.src = "data:text/html;base64,#{encoded}"
|
||||
document.body.appendChild webview
|
||||
|
||||
it 'disables web security when set', (done) ->
|
||||
src = "
|
||||
<script src='file://#{__dirname}/static/jquery-2.0.3.min.js'></script>
|
||||
<script>console.log('ok');</script>
|
||||
"
|
||||
encoded = btoa(unescape(encodeURIComponent(src)))
|
||||
listener = (e) ->
|
||||
assert.equal e.message, 'ok'
|
||||
webview.removeEventListener 'console-message', listener
|
||||
done()
|
||||
webview.addEventListener 'console-message', listener
|
||||
webview.setAttribute 'disablewebsecurity', ''
|
||||
webview.src = "data:text/html;base64,#{encoded}"
|
||||
document.body.appendChild webview
|
||||
|
||||
describe 'new-window event', ->
|
||||
it 'emits when window.open is called', (done) ->
|
||||
webview.addEventListener 'new-window', (e) ->
|
||||
|
|
Loading…
Reference in a new issue