Add a test to verify the webview close event
authorPaul Betts <paul@paulbetts.org>
Wed, 8 Jul 2015 21:34:44 +0000 (14:34 -0700)
committerPaul Betts <paul@paulbetts.org>
Wed, 8 Jul 2015 21:34:44 +0000 (14:34 -0700)
spec/fixtures/pages/close.html [new file with mode: 0644]
spec/webview-spec.coffee

diff --git a/spec/fixtures/pages/close.html b/spec/fixtures/pages/close.html
new file mode 100644 (file)
index 0000000..9696eac
--- /dev/null
@@ -0,0 +1,9 @@
+<html>
+<link rel="icon" type="image/png" href="/favicon.png"/>
+<link rel="icon" type="image/png" href="http://test.com/favicon.png"/>
+<body>
+<script type="text/javascript" charset="utf-8">
+       window.close();
+</script>
+</body>
+</html>
index a1a1724..451276a 100644 (file)
@@ -191,6 +191,14 @@ describe '<webview> tag', ->
       webview.src = "file://#{fixtures}/pages/a.html"
       document.body.appendChild webview
 
+  describe 'close event', ->
+    it 'should fire when interior page calls window.close', ->
+      webview.addEventListener 'close', ->
+        done()
+
+      webview.src = "file://#{fixtures}/pages/close.html"
+      document.body.appendChild webview
+
   describe '<webview>.reload()', ->
     it 'should emit beforeunload handler', (done) ->
       listener = (e) ->
@@ -217,6 +225,6 @@ describe '<webview> tag', ->
         webview.removeEventListener 'ipc-message', listener
         done()
       webview.addEventListener 'ipc-message', listener
-      webview.setAttribute 'nodeintegration', 'on'      
+      webview.setAttribute 'nodeintegration', 'on'
       webview.src = "file://#{fixtures}/pages/history.html"
       document.body.appendChild webview