beforeunload: {
postDispatch: function( event ) {
- // Even when returnValue equals to undefined Firefox will still show alert
- if ( event.result !== undefined ) {
+ // Support: Firefox 20+
+ // Firefox doesn't alert if the returnValue field is not set.
+ if ( event.result !== undefined && event.originalEvent ) {
event.originalEvent.returnValue = event.result;
}
}
--- /dev/null
+<!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>
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 ) {