]> khamidou — GitHub mirrors - electron.git/commitdiff
Update specs to match the documents.
authorCheng Zhao <zcbenz@gmail.com>
Mon, 2 Sep 2013 08:54:54 +0000 (16:54 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 2 Sep 2013 08:54:54 +0000 (16:54 +0800)
spec/api/window.coffee
spec/fixtures/api/close-beforeunload-empty-string.html [new file with mode: 0644]

index 4226817c596f43a6efa4aee400bd8a45e7af2e89..a291af59487618d5c35d01fe5a495c9940af8840 100644 (file)
@@ -74,6 +74,12 @@ describe 'window module', ->
         done()
       w.loadUrl 'file://' + path.join(fixtures, 'api', 'close-beforeunload-true.html')
 
+    it 'returning non-empty string would not prevent close', (done) ->
+      w = new BrowserWindow(show: false)
+      w.on 'closed', ->
+        done()
+      w.loadUrl 'file://' + path.join(fixtures, 'api', 'close-beforeunload-string.html')
+
     it 'returning false would prevent close', (done) ->
       w = new BrowserWindow(show: false)
       w.on 'onbeforeunload', ->
@@ -81,9 +87,9 @@ describe 'window module', ->
         done()
       w.loadUrl 'file://' + path.join(fixtures, 'api', 'close-beforeunload-false.html')
 
-    it 'returning non-empty string would prevent close', (done) ->
+    it 'returning empty string would prevent close', (done) ->
       w = new BrowserWindow(show: false)
       w.on 'onbeforeunload', ->
         w.destroy()
         done()
-      w.loadUrl 'file://' + path.join(fixtures, 'api', 'close-beforeunload-string.html')
+      w.loadUrl 'file://' + path.join(fixtures, 'api', 'close-beforeunload-empty-string.html')
diff --git a/spec/fixtures/api/close-beforeunload-empty-string.html b/spec/fixtures/api/close-beforeunload-empty-string.html
new file mode 100644 (file)
index 0000000..0027c55
--- /dev/null
@@ -0,0 +1,13 @@
+<html>
+<body>
+<script type="text/javascript" charset="utf-8">
+  window.onbeforeunload = function() {
+    setTimeout(function() {
+      require('remote').getCurrentWindow().emit('onbeforeunload');
+    }, 0);
+    return '';
+  }
+  window.close();
+</script>
+</body>
+</html>