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
696c5530
Commit
696c5530
authored
Oct 21, 2012
by
Oleg
Committed by
Dave Methvin
Oct 22, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix failing tests for beforeunload in Safari 5.0. Close gh-1002.
parent
2decd051
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
12 deletions
+28
-12
event.js
test/unit/event.js
+28
-12
No files found.
test/unit/event.js
View file @
696c5530
...
@@ -1372,20 +1372,30 @@ test("Submit event can be stopped (#11049)", function() {
...
@@ -1372,20 +1372,30 @@ test("Submit event can be stopped (#11049)", function() {
// Test beforeunload event only if it supported (i.e. not Opera)
// Test beforeunload event only if it supported (i.e. not Opera)
if
(
window
.
onbeforeunload
===
null
)
{
if
(
window
.
onbeforeunload
===
null
)
{
asyncTest
(
"on(beforeunload)"
,
4
,
function
()
{
asyncTest
(
"on(beforeunload)"
,
4
,
function
()
{
var
doc
,
var
win
,
forIE6
=
0
,
forIE6
=
0
,
fired
=
false
,
iframe
=
jQuery
(
"<iframe src='data/iframe.html' />"
);
iframe
=
jQuery
(
"<iframe src='data/iframe.html' />"
);
iframe
.
appendTo
(
"#qunit-fixture"
).
one
(
"load"
,
function
()
{
iframe
.
appendTo
(
"#qunit-fixture"
).
one
(
"load"
,
function
()
{
doc
=
iframe
[
0
].
contentWindow
||
iframe
[
0
]
.
contentDocument
;
win
=
this
.
contentWindow
||
this
.
contentDocument
;
jQuery
(
doc
).
on
(
"beforeunload"
,
function
()
{
jQuery
(
win
).
on
(
"beforeunload"
,
function
()
{
fired
=
true
;
ok
(
true
,
"beforeunload event is fired"
);
ok
(
true
,
"beforeunload event is fired"
);
});
});
strictEqual
(
doc
.
onbeforeunload
,
null
,
"onbeforeunload property on window object still equals null"
);
strictEqual
(
win
.
onbeforeunload
,
null
,
"onbeforeunload property on window object still equals null"
);
jQuery
(
doc
).
on
(
"beforeunload"
,
function
()
{
// In old Safari beforeunload event will not fire on iframes
jQuery
(
win
).
on
(
"unload"
,
function
()
{
if
(
!
fired
)
{
ok
(
true
,
"This is suppose to be true only in old Safari"
);
checker
();
}
});
jQuery
(
win
).
on
(
"beforeunload"
,
function
()
{
// On iframe in IE6 beforeunload event will not fire if event is binded through window object,
// On iframe in IE6 beforeunload event will not fire if event is binded through window object,
// nevertheless, test should continue
// nevertheless, test should continue
...
@@ -1396,7 +1406,7 @@ if ( window.onbeforeunload === null ) {
...
@@ -1396,7 +1406,7 @@ if ( window.onbeforeunload === null ) {
});
});
});
});
doc
.
onbeforeunload
=
function
()
{
win
.
onbeforeunload
=
function
()
{
if
(
!
forIE6
)
{
if
(
!
forIE6
)
{
forIE6
++
;
forIE6
++
;
checker
();
checker
();
...
@@ -1408,21 +1418,27 @@ if ( window.onbeforeunload === null ) {
...
@@ -1408,21 +1418,27 @@ if ( window.onbeforeunload === null ) {
iframe
=
jQuery
(
"<iframe src='data/iframe.html' />"
);
iframe
=
jQuery
(
"<iframe src='data/iframe.html' />"
);
iframe
.
appendTo
(
"#qunit-fixture"
).
one
(
"load"
,
function
()
{
iframe
.
appendTo
(
"#qunit-fixture"
).
one
(
"load"
,
function
()
{
doc
=
iframe
[
0
].
contentWindow
||
iframe
[
0
].
contentDocument
;
win
=
iframe
[
0
].
contentWindow
||
iframe
[
0
].
contentDocument
;
jQuery
(
doc
).
on
(
"beforeunload"
,
function
()
{
jQuery
(
win
).
on
(
"beforeunload"
,
function
()
{
strictEqual
(
doc
.
onbeforeunload
,
null
,
"Event handler is fired, even when onbeforeunload property on window is nulled"
);
strictEqual
(
win
.
onbeforeunload
,
null
,
"Event handler is fired, even when onbeforeunload property on window is nulled"
);
start
();
start
();
});
});
doc
.
onbeforeunload
=
null
;
jQuery
(
win
).
on
(
"unload"
,
function
()
{
if
(
!
fired
)
{
jQuery
(
win
).
trigger
(
"beforeunload"
);
}
})
win
.
onbeforeunload
=
null
;
doc
.
location
.
reload
();
win
.
location
.
reload
();
});
});
}
}
doc
.
location
.
reload
();
win
.
location
.
reload
();
});
});
});
});
}
}
...
...
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