[Pkg-javascript-commits] [sockjs-client] 237/434: #28 Test onbeforeunload event
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 33e500791ed525846929b49f0ccc07162d7b7786
Author: Marek Majkowski <majek04 at gmail.com>
Date: Thu Dec 1 14:01:25 2011 +0000
#28 Test onbeforeunload event
---
lib/dom.js | 9 +++++++--
tests/html/src/domtests.coffee | 23 +++++++++++++++++++++++
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/lib/dom.js b/lib/dom.js
index 988a872..bb6bf63 100644
--- a/lib/dom.js
+++ b/lib/dom.js
@@ -194,8 +194,13 @@ utils.createIframe = function (iframe_url, error_callback) {
// onunload event. Setting .src must happen before the
// removeChild step.
iframe.src = "about:blank";
- iframe.parentNode.removeChild(iframe);
- iframe = null;
+ // This timeout makes chrome fire onbeforeunload event
+ // within iframe. Without the timeout it goes straight to
+ // onunload.
+ setTimeout(function() {
+ iframe.parentNode.removeChild(iframe);
+ iframe = null;
+ }, 10);
utils.detachEvent('unload', cleanup);
}
};
diff --git a/tests/html/src/domtests.coffee b/tests/html/src/domtests.coffee
index 2b25f0c..1a377ac 100644
--- a/tests/html/src/domtests.coffee
+++ b/tests/html/src/domtests.coffee
@@ -34,6 +34,29 @@ else
hook.del()
start()
+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("""
+ 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]", ->
ok(true)
--
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