[Pkg-javascript-commits] [sockjs-client] 238/434: Abstract similar onunload and onbeforeunload tests

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:16 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository sockjs-client.

commit 872e87e747758d55a6c23d4e1eecf77737fb6242
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Thu Dec 1 14:07:08 2011 +0000

    Abstract similar onunload and onbeforeunload tests
---
 tests/html/src/domtests.coffee | 41 ++++++++++++++++-------------------------
 1 file changed, 16 insertions(+), 25 deletions(-)

diff --git a/tests/html/src/domtests.coffee b/tests/html/src/domtests.coffee
index 1a377ac..fee21ce 100644
--- a/tests/html/src/domtests.coffee
+++ b/tests/html/src/domtests.coffee
@@ -12,21 +12,13 @@ newIframe = ->
     hook.iobj = u.createIframe('/iframe.html?a=' + Math.random() + '#' + hook.id, err)
     return hook
 
-if navigator.userAgent.indexOf('Konqueror') isnt -1
-    test "onunload [unsupported by client]", ->
-        ok(true)
-else
-    asyncTest 'onunload', ->
+onunload_test_factory = (code) ->
+    return ->
         expect(2)
         hook = newIframe()
         hook.open = ->
             ok(true, 'open hook called by an iframe')
-            hook.callback("""
-                    var u = SockJS.getUtils();
-                    u.attachEvent('unload', function(){
-                        hook.done();
-                    });
-                """)
+            hook.callback(code)
             f = -> hook.iobj.cleanup()
             setTimeout(f, 1)
         hook.done = ->
@@ -34,28 +26,27 @@ else
             hook.del()
             start()
 
+if navigator.userAgent.indexOf('Konqueror') isnt -1
+    test "onunload [unsupported by client]", ->
+        ok(true)
+else
+    asyncTest('onunload', onunload_test_factory("""
+                    var u = SockJS.getUtils();
+                    u.attachEvent('unload', function(){
+                        hook.done();
+                    });
+                """))
+
 if navigator.userAgent.indexOf('Konqueror') isnt -1 or $.browser.opera
     test "onbeforeunload [unsupported by client]", ->
         ok(true)
 else
-    asyncTest 'onbeforeunload', ->
-        expect(2)
-        hook = newIframe()
-        hook.open = ->
-            ok(true, 'open hook called by an iframe')
-            hook.callback("""
+    asyncTest('onbeforeunload', onunload_test_factory("""
                     var u = SockJS.getUtils();
                     u.attachEvent('beforeunload', function(){
                         hook.done();
-                  return ;
                     });
-                """)
-            f = -> hook.iobj.cleanup()
-            setTimeout(f, 1)
-        hook.done = ->
-            ok(true, 'done hook called by an iframe')
-            hook.del()
-            start()
+                """))
 
 if not SockJS.getIframeTransport().enabled()
     test "onmessage [unsupported by client]", ->

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list