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
d6c84c5b
Commit
d6c84c5b
authored
Oct 15, 2012
by
Rick Waldron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Breakout JSONP domain-related tests
parent
cc172a86
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
142 additions
and
86 deletions
+142
-86
ajax.js
test/unit/ajax.js
+142
-86
No files found.
test/unit/ajax.js
View file @
d6c84c5b
...
@@ -1110,7 +1110,7 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
...
@@ -1110,7 +1110,7 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
}
}
equal
(
i
,
1
,
"Test to make sure only one 'no-cache' parameter is there"
);
equal
(
i
,
1
,
"Test to make sure only one 'no-cache' parameter is there"
);
ok
(
oldOne
!=
"tobereplaced555"
,
"Test to be sure parameter (if it was there) was replaced"
);
ok
(
oldOne
!=
"tobereplaced555"
,
"Test to be sure parameter (if it was there) was replaced"
);
if
(
++
count
==
6
)
{
if
(
++
count
==
=
6
)
{
start
();
start
();
}
}
});
});
...
@@ -1449,53 +1449,20 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
...
@@ -1449,53 +1449,20 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
});
});
});
});
jQuery
.
each
(
[
"Same Domain"
,
"Cross Domain"
],
function
(
crossDomain
,
label
)
{
jQuery
.
each
(
[
"Same Domain"
,
"Cross Domain"
],
function
(
crossDomain
,
label
)
{
test
(
"jQuery.ajax() - JSONP, "
+
label
,
function
()
{
expect
(
24
);
asyncTest
(
"jQuery.ajax() - JSONP, Query String (?n)"
+
label
,
function
()
{
expect
(
4
);
var
count
=
0
;
var
count
=
0
;
function
plus
()
{
function
plus
()
{
if
(
++
count
==
20
)
{
if
(
++
count
==
=
4
)
{
start
();
start
();
}
}
}
}
stop
();
jQuery
.
ajax
({
url
:
"data/jsonp.php"
,
dataType
:
"jsonp"
,
crossDomain
:
crossDomain
,
success
:
function
(
data
)
{
ok
(
data
.
data
,
"JSON results returned (GET, no callback)"
);
plus
();
},
error
:
function
(
data
)
{
ok
(
false
,
"Ajax error JSON (GET, no callback)"
);
plus
();
}
});
jQuery
.
ajax
({
url
:
"data/jsonp.php"
,
dataType
:
"jsonp"
,
crossDomain
:
crossDomain
,
success
:
function
(
data
)
{
ok
(
data
.
data
,
(
this
.
alreadyDone
?
"this re-used"
:
"first request"
)
+
": JSON results returned (GET, no callback)"
);
if
(
!
this
.
alreadyDone
)
{
this
.
alreadyDone
=
true
;
jQuery
.
ajax
(
this
);
}
else
{
plus
();
}
},
error
:
function
(
data
)
{
ok
(
false
,
"Ajax error JSON (GET, no callback)"
);
plus
();
}
});
jQuery
.
ajax
({
jQuery
.
ajax
({
url
:
"data/jsonp.php?callback=?"
,
url
:
"data/jsonp.php?callback=?"
,
dataType
:
"jsonp"
,
dataType
:
"jsonp"
,
...
@@ -1510,21 +1477,6 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
...
@@ -1510,21 +1477,6 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
}
}
});
});
jQuery
.
ajax
({
url
:
"data/jsonp.php"
,
dataType
:
"jsonp"
,
crossDomain
:
crossDomain
,
data
:
"callback=?"
,
success
:
function
(
data
)
{
ok
(
data
.
data
,
"JSON results returned (GET, data callback)"
);
plus
();
},
error
:
function
(
data
)
{
ok
(
false
,
"Ajax error JSON (GET, data callback)"
);
plus
();
}
});
jQuery
.
ajax
({
jQuery
.
ajax
({
url
:
"data/jsonp.php?callback=??"
,
url
:
"data/jsonp.php?callback=??"
,
dataType
:
"jsonp"
,
dataType
:
"jsonp"
,
...
@@ -1539,21 +1491,6 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
...
@@ -1539,21 +1491,6 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
}
}
});
});
jQuery
.
ajax
({
url
:
"data/jsonp.php"
,
dataType
:
"jsonp"
,
crossDomain
:
crossDomain
,
data
:
"callback=??"
,
success
:
function
(
data
)
{
ok
(
data
.
data
,
"JSON results returned (GET, data context-free callback)"
);
plus
();
},
error
:
function
(
data
)
{
ok
(
false
,
"Ajax error JSON (GET, data context-free callback)"
);
plus
();
}
});
jQuery
.
ajax
({
jQuery
.
ajax
({
url
:
"data/jsonp.php/??"
,
url
:
"data/jsonp.php/??"
,
dataType
:
"jsonp"
,
dataType
:
"jsonp"
,
...
@@ -1581,6 +1518,17 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
...
@@ -1581,6 +1518,17 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
plus
();
plus
();
}
}
});
});
});
asyncTest
(
"jQuery.ajax() - JSONP, Explicit jsonp/Callback param "
+
label
,
function
()
{
expect
(
9
);
var
count
=
0
;
function
plus
()
{
if
(
++
count
===
4
)
{
start
();
}
}
jQuery
.
ajax
({
jQuery
.
ajax
({
url
:
"data/jsonp.php"
,
url
:
"data/jsonp.php"
,
...
@@ -1650,6 +1598,80 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
...
@@ -1650,6 +1598,80 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
}
}
});
});
jQuery
.
ajax
({
url
:
"data/jsonp.php?callback=XXX"
,
dataType
:
"jsonp"
,
jsonp
:
false
,
jsonpCallback
:
"XXX"
,
crossDomain
:
crossDomain
,
beforeSend
:
function
()
{
ok
(
/^data
\/
jsonp.php
\?
callback=XXX&_=
\d
+$/
.
test
(
this
.
url
),
"The URL wasn't messed with (GET, custom callback name with no url manipulation)"
);
plus
();
},
success
:
function
(
data
)
{
ok
(
data
[
"data"
],
"JSON results returned (GET, custom callback name with no url manipulation)"
);
plus
();
},
error
:
function
(
data
)
{
ok
(
false
,
"Ajax error JSON (GET, custom callback name with no url manipulation)"
);
plus
();
}
});
});
asyncTest
(
"jQuery.ajax() - JSONP, Callback in data, "
+
label
,
function
()
{
expect
(
2
);
var
count
=
0
;
function
plus
()
{
if
(
++
count
===
2
)
{
start
();
}
}
jQuery
.
ajax
({
url
:
"data/jsonp.php"
,
dataType
:
"jsonp"
,
crossDomain
:
crossDomain
,
data
:
"callback=?"
,
success
:
function
(
data
)
{
ok
(
data
.
data
,
"JSON results returned (GET, data callback)"
);
plus
();
},
error
:
function
(
data
)
{
ok
(
false
,
"Ajax error JSON (GET, data callback)"
);
plus
();
}
});
jQuery
.
ajax
({
url
:
"data/jsonp.php"
,
dataType
:
"jsonp"
,
crossDomain
:
crossDomain
,
data
:
"callback=??"
,
success
:
function
(
data
)
{
ok
(
data
.
data
,
"JSON results returned (GET, data context-free callback)"
);
plus
();
},
error
:
function
(
data
)
{
ok
(
false
,
"Ajax error JSON (GET, data context-free callback)"
);
plus
();
}
});
});
asyncTest
(
"jQuery.ajax() - JSONP, POST, "
+
label
,
function
()
{
expect
(
3
);
var
count
=
0
;
function
plus
()
{
if
(
++
count
===
3
)
{
start
();
}
}
jQuery
.
ajax
({
jQuery
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
"data/jsonp.php"
,
url
:
"data/jsonp.php"
,
...
@@ -1696,40 +1718,73 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
...
@@ -1696,40 +1718,73 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
plus
();
plus
();
}
}
});
});
});
asyncTest
(
"jQuery.ajax() - JSONP, "
+
label
,
function
()
{
expect
(
3
);
var
count
=
0
;
function
plus
()
{
if
(
++
count
===
2
)
{
start
();
}
}
//#7578
jQuery
.
ajax
({
jQuery
.
ajax
({
url
:
"data/jsonp.php"
,
url
:
"data/jsonp.php"
,
dataType
:
"jsonp"
,
dataType
:
"jsonp"
,
crossDomain
:
crossDomain
,
crossDomain
:
crossDomain
,
beforeSend
:
function
()
{
success
:
function
(
data
)
{
strictEqual
(
this
.
cache
,
false
,
"cache must be false on JSON request"
);
ok
(
data
.
data
,
"JSON results returned (GET, no callback)"
);
plus
();
},
error
:
function
(
data
)
{
ok
(
false
,
"Ajax error JSON (GET, no callback)"
);
plus
();
plus
();
return
false
;
}
}
});
});
jQuery
.
ajax
({
jQuery
.
ajax
({
url
:
"data/jsonp.php
?callback=XXX
"
,
url
:
"data/jsonp.php"
,
dataType
:
"jsonp"
,
dataType
:
"jsonp"
,
jsonp
:
false
,
jsonpCallback
:
"XXX"
,
crossDomain
:
crossDomain
,
crossDomain
:
crossDomain
,
beforeSend
:
function
()
{
ok
(
/^data
\/
jsonp.php
\?
callback=XXX&_=
\d
+$/
.
test
(
this
.
url
),
"The URL wasn't messed with (GET, custom callback name with no url manipulation)"
);
plus
();
},
success
:
function
(
data
)
{
success
:
function
(
data
)
{
ok
(
data
[
"data"
],
"JSON results returned (GET, custom callback name with no url manipulation)"
);
ok
(
data
.
data
,
(
this
.
alreadyDone
?
"this re-used"
:
"first request"
)
+
": JSON results returned (GET, no callback)"
);
plus
();
if
(
!
this
.
alreadyDone
)
{
this
.
alreadyDone
=
true
;
// NOTE: "this" will create another request identical
// to the CALLING request
jQuery
.
ajax
(
this
);
}
else
{
plus
();
}
},
},
error
:
function
(
data
)
{
error
:
function
(
data
)
{
ok
(
false
,
"Ajax error JSON (GET,
custom callback name with no url manipulation
)"
);
ok
(
false
,
"Ajax error JSON (GET,
no callback
)"
);
plus
();
plus
();
}
}
});
});
});
asyncTest
(
"jQuery.ajax() - #7578, "
+
label
,
function
()
{
expect
(
1
);
jQuery
.
ajax
({
url
:
"data/jsonp.php"
,
dataType
:
"jsonp"
,
crossDomain
:
crossDomain
,
beforeSend
:
function
()
{
strictEqual
(
this
.
cache
,
false
,
"cache must be false on JSON request"
);
start
();
return
false
;
}
});
});
asyncTest
(
"jQuery.ajax() - #8205, "
+
label
,
function
()
{
expect
(
2
);
//#8205
jQuery
.
ajax
({
jQuery
.
ajax
({
url
:
"data/jsonp.php"
,
url
:
"data/jsonp.php"
,
dataType
:
"jsonp"
,
dataType
:
"jsonp"
,
...
@@ -1749,8 +1804,9 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
...
@@ -1749,8 +1804,9 @@ if ( jQuery.ajax && ( !isLocal || hasPHP ) ) {
return
false
;
return
false
;
}
}
});
});
}).
always
(
plus
);
}).
always
(
function
()
{
start
();
});
});
});
});
});
...
...
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