Browse Source

spec: webview should work without script tag in page

Cheng Zhao 9 years ago
parent
commit
bb70defcb8
3 changed files with 22 additions and 1 deletions
  1. 7 0
      spec/fixtures/pages/ping.html
  2. 5 0
      spec/fixtures/pages/webview-no-script.html
  3. 10 1
      spec/webview-spec.js

+ 7 - 0
spec/fixtures/pages/ping.html

@@ -0,0 +1,7 @@
+<html>
+<body>
+<script type="text/javascript" charset="utf-8">
+  require('electron').ipcRenderer.send('pong')
+</script>
+</body>
+</html>

+ 5 - 0
spec/fixtures/pages/webview-no-script.html

@@ -0,0 +1,5 @@
+<html>
+<body>
+<webview nodeintegration src="ping.html"/>
+</body>
+</html>

+ 10 - 1
spec/webview-spec.js

@@ -2,7 +2,7 @@ const assert = require('assert')
 const path = require('path')
 const http = require('http')
 const url = require('url')
-const {app, session} = require('electron').remote
+const {app, session, ipcMain, BrowserWindow} = require('electron').remote
 
 describe('<webview> tag', function () {
   this.timeout(10000)
@@ -20,6 +20,15 @@ describe('<webview> tag', function () {
     }
   })
 
+  it('works without script tag in page', function (done) {
+    let w = new BrowserWindow({show: false})
+    ipcMain.once('pong', function () {
+      w.destroy()
+      done()
+    })
+    w.loadURL('file://' + fixtures + '/pages/webview-no-script.html')
+  })
+
   describe('src attribute', function () {
     it('specifies the page to load', function (done) {
       webview.addEventListener('console-message', function (e) {