spec: Native modules should work after navigation in webview

This commit is contained in:
Cheng Zhao 2015-04-26 15:49:26 +08:00
parent 36c4b1705d
commit 3ff2959f0c
2 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,9 @@
<html>
<body>
<script type="text/javascript" charset="utf-8">
var path = require('path');
console.log(typeof require(path.join(__dirname, '..', '..', 'node_modules', 'runas')));
</script>
</body>
</html>

View file

@ -47,6 +47,19 @@ describe '<webview> tag', ->
webview.src = "file://#{fixtures}/pages/d.html"
document.body.appendChild webview
it 'loads native modules when navigation happens', (done) ->
listener = (e) ->
webview.removeEventListener 'did-finish-load', listener
listener2 = (e) ->
assert.equal e.message, 'function'
done()
webview.addEventListener 'console-message', listener2
webview.src = "file://#{fixtures}/pages/native-module.html"
webview.addEventListener 'did-finish-load', listener
webview.setAttribute 'nodeintegration', 'on'
webview.src = "file://#{fixtures}/pages/native-module.html"
document.body.appendChild webview
describe 'preload attribute', ->
it 'loads the script before other scripts in window', (done) ->
listener = (e) ->