Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
06adf7c9
Commit
06adf7c9
authored
Mar 04, 2014
by
Dave Methvin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Event: Allow triggerHandler(beforeunload)
Fixes #14791
parent
3a68c114
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
1 deletion
+24
-1
event.js
src/event.js
+1
-1
triggerunload.html
test/data/event/triggerunload.html
+18
-0
event.js
test/unit/event.js
+5
-0
No files found.
src/event.js
View file @
06adf7c9
...
@@ -583,7 +583,7 @@ jQuery.event = {
...
@@ -583,7 +583,7 @@ jQuery.event = {
// Support: Firefox 20+
// Support: Firefox 20+
// Firefox doesn't alert if the returnValue field is not set.
// Firefox doesn't alert if the returnValue field is not set.
if
(
event
.
result
!==
undefined
)
{
if
(
event
.
result
!==
undefined
&&
event
.
originalEvent
)
{
event
.
originalEvent
.
returnValue
=
event
.
result
;
event
.
originalEvent
.
returnValue
=
event
.
result
;
}
}
}
}
...
...
test/data/event/triggerunload.html
0 → 100644
View file @
06adf7c9
<!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>
test/unit/event.js
View file @
06adf7c9
...
@@ -2434,6 +2434,11 @@ testIframeWithCallback( "Focusing iframe element", "event/focusElem.html", funct
...
@@ -2434,6 +2434,11 @@ testIframeWithCallback( "Focusing iframe element", "event/focusElem.html", funct
ok
(
isOk
,
"Focused an element in an iframe"
);
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
// need PHP here to make the incepted IFRAME hang
if
(
hasPHP
)
{
if
(
hasPHP
)
{
testIframeWithCallback
(
"jQuery.ready synchronous load with long loading subresources"
,
"event/syncReady.html"
,
function
(
isOk
)
{
testIframeWithCallback
(
"jQuery.ready synchronous load with long loading subresources"
,
"event/syncReady.html"
,
function
(
isOk
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment