]> khamidou — GitHub mirrors - electron.git/commitdiff
spec: "new-window" event of <webview>
authorCheng Zhao <zcbenz@gmail.com>
Mon, 27 Oct 2014 11:26:45 +0000 (19:26 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 27 Oct 2014 11:26:45 +0000 (19:26 +0800)
spec/fixtures/pages/target-name.html [new file with mode: 0644]
spec/fixtures/pages/window-open.html [new file with mode: 0644]
spec/webview-spec.coffee

diff --git a/spec/fixtures/pages/target-name.html b/spec/fixtures/pages/target-name.html
new file mode 100644 (file)
index 0000000..0dc760d
--- /dev/null
@@ -0,0 +1,13 @@
+<html>
+<body>
+<a id="a", href="http://host" target="target">link</a>
+<script type="text/javascript" charset="utf-8">
+  var event = new MouseEvent('click', {
+    'view': window,
+    'bubbles': true,
+    'cancelable': true
+  });
+  document.getElementById('a').dispatchEvent(event);
+</script>
+</body>
+</html>
diff --git a/spec/fixtures/pages/window-open.html b/spec/fixtures/pages/window-open.html
new file mode 100644 (file)
index 0000000..94a7202
--- /dev/null
@@ -0,0 +1,7 @@
+<html>
+<body>
+<script type="text/javascript" charset="utf-8">
+  window.open('http://host', 'host');
+</script>
+</body>
+</html>
index fa533c5777d82c06abdb2f4fc63fb720c60c3d6c..09c7709c08be460ed540b57a8f34cadaa9f932c8 100644 (file)
@@ -46,3 +46,20 @@ describe '<webview> tag', ->
       webview.setAttribute 'nodeintegration', 'on'
       webview.src = "file://#{fixtures}/pages/d.html"
       document.body.appendChild webview
+
+  describe 'new-window event', ->
+    it 'emits when window.open is called', (done) ->
+      webview.addEventListener 'new-window', (e) ->
+        assert.equal e.url, 'http://host'
+        assert.equal e.frameName, 'host'
+        done()
+      webview.src = "file://#{fixtures}/pages/window-open.html"
+      document.body.appendChild webview
+
+    it 'emits when link with target is called', (done) ->
+      webview.addEventListener 'new-window', (e) ->
+        assert.equal e.url, 'http://host/'
+        assert.equal e.frameName, 'target'
+        done()
+      webview.src = "file://#{fixtures}/pages/target-name.html"
+      document.body.appendChild webview