aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2014-03-03 22:43:51 -0500
committerDave Methvin <dave.methvin@gmail.com>2014-03-04 21:50:41 -0500
commit93fdfa2d8c641744a4be84cc4bc4d54b83a909df (patch)
tree15af0f79b71b5e4772322b353fe81af3539d72ab /test
parent48837b92b03a5cb0f37fe49963d5e34a658bf214 (diff)
downloadjquery-93fdfa2d8c641744a4be84cc4bc4d54b83a909df.tar.gz
jquery-93fdfa2d8c641744a4be84cc4bc4d54b83a909df.zip
Event: Allow triggerHandler(beforeunload)
Fixes #14791 (cherry picked from commit 06adf7c95d93507908181995a9ea15fe2729595a) Conflicts: src/event.js
Diffstat (limited to 'test')
-rw-r--r--test/data/event/triggerunload.html18
-rw-r--r--test/unit/event.js5
2 files changed, 23 insertions, 0 deletions
diff --git a/test/data/event/triggerunload.html b/test/data/event/triggerunload.html
new file mode 100644
index 000000000..a7879c772
--- /dev/null
+++ b/test/data/event/triggerunload.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<html>
+ <script src="../../jquery.js"></script>
+ <script>
+ var called = false,
+ error = false;
+
+ window.onerror = function() { error = true; };
+
+ jQuery( window ).on( "beforeunload", function( event ) {
+ called = true;
+ return "maybe";
+ }).on( "load", function( event ) {
+ $( window ).triggerHandler( "beforeunload" );
+ window.parent.iframeCallback( called && !error );
+ });
+ </script>
+</html>
diff --git a/test/unit/event.js b/test/unit/event.js
index 2a9cd22f3..0cd181252 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -2522,6 +2522,11 @@ testIframeWithCallback( "Focusing iframe element", "event/focusElem.html", funct
ok( isOk, "Focused an element in an iframe" );
});
+testIframeWithCallback( "triggerHandler(onbeforeunload)", "event/triggerunload.html", function( isOk ) {
+ expect( 1 );
+ ok( isOk, "Triggered onbeforeunload without an error" );
+});
+
// need PHP here to make the incepted IFRAME hang
if ( hasPHP ) {
testIframeWithCallback( "jQuery.ready synchronous load with long loading subresources", "event/syncReady.html", function( isOk ) {