Add spec for sanbox attribute of iframe.
This commit is contained in:
parent
e3d67a304f
commit
df86c9dac1
2 changed files with 26 additions and 0 deletions
|
@ -1,6 +1,9 @@
|
|||
assert = require 'assert'
|
||||
path = require 'path'
|
||||
|
||||
describe 'chromium feature', ->
|
||||
fixtures = path.resolve __dirname, 'fixtures'
|
||||
|
||||
describe 'heap snapshot', ->
|
||||
it 'does not crash', ->
|
||||
process.atomBinding('v8_util').takeHeapSnapshot()
|
||||
|
@ -21,3 +24,18 @@ describe 'chromium feature', ->
|
|||
b = window.open 'about:blank', 'test', 'show=no'
|
||||
assert.equal b.constructor.name, 'BrowserWindow'
|
||||
b.destroy()
|
||||
|
||||
describe 'iframe with sandbox attribute', ->
|
||||
it 'can not modify parent', (done) ->
|
||||
page = path.join fixtures, 'pages', 'change-parent.html'
|
||||
global.changedByIframe = false
|
||||
|
||||
iframe = $('<iframe sandbox="allow-scripts">')
|
||||
iframe.hide()
|
||||
iframe.attr 'src', "file://#{page}"
|
||||
iframe.appendTo 'body'
|
||||
isChanged = ->
|
||||
iframe.remove()
|
||||
assert.equal global.changedByIframe, false
|
||||
done()
|
||||
setTimeout isChanged, 30
|
||||
|
|
8
spec/fixtures/pages/change-parent.html
vendored
Normal file
8
spec/fixtures/pages/change-parent.html
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
console.log('ready2')
|
||||
window.parent.changedByIframe = true;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue