aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2016-07-29 15:50:07 -0400
committerDave Methvin <dave.methvin@gmail.com>2016-08-08 12:13:22 -0400
commitcd4ad00478fd02dc04043e9eafc70b2e73e05c87 (patch)
treedf8dc7d9fd6c9b1a2d3246c7b90e347d3b57dc70 /test
parent9526557e677abd237f8b299108b454a8532e7d5a (diff)
downloadjquery-cd4ad00478fd02dc04043e9eafc70b2e73e05c87.tar.gz
jquery-cd4ad00478fd02dc04043e9eafc70b2e73e05c87.zip
Ajax: Don't mangle the URL when removing the anti-cache param
Fixes gh-3229 Closes gh-3253
Diffstat (limited to 'test')
-rw-r--r--test/unit/ajax.js28
1 files changed, 19 insertions, 9 deletions
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index 5e24c3049..5a3bd32d2 100644
--- a/test/unit/ajax.js
+++ b/test/unit/ajax.js
@@ -828,8 +828,9 @@ QUnit.module( "ajax", {
} ), "generic" );
} );
- ajaxTest( "jQuery.ajax() - cache", 12, function( assert ) {
- var re = /_=(.*?)(&|$)/g;
+ ajaxTest( "jQuery.ajax() - cache", 28, function( assert ) {
+ var re = /_=(.*?)(&|$)/g,
+ rootUrl = "data/text.php";
function request( url, title ) {
return {
@@ -837,6 +838,11 @@ QUnit.module( "ajax", {
cache: false,
beforeSend: function() {
var parameter, tmp;
+
+ // URL sanity check
+ assert.equal( this.url.indexOf( rootUrl ), 0, "root url not mangled: " + this.url );
+ assert.equal( /\&.*\?/.test( this.url ), false, "parameter delimiters in order" );
+
while ( ( tmp = re.exec( this.url ) ) ) {
assert.strictEqual( parameter, undefined, title + ": only one 'no-cache' parameter" );
parameter = tmp[ 1 ];
@@ -850,27 +856,31 @@ QUnit.module( "ajax", {
return [
request(
- "data/text.php",
- "no parameter"
+ rootUrl,
+ "no query"
+ ),
+ request(
+ rootUrl + "?",
+ "empty query"
),
request(
- "data/text.php?pizza=true",
+ rootUrl + "?pizza=true",
"1 parameter"
),
request(
- "data/text.php?_=tobereplaced555",
+ rootUrl + "?_=tobereplaced555",
"_= parameter"
),
request(
- "data/text.php?pizza=true&_=tobereplaced555",
+ rootUrl + "?pizza=true&_=tobereplaced555",
"1 parameter and _="
),
request(
- "data/text.php?_=tobereplaced555&tv=false",
+ rootUrl + "?_=tobereplaced555&tv=false",
"_= and 1 parameter"
),
request(
- "data/text.php?name=David&_=tobereplaced555&washere=true",
+ rootUrl + "?name=David&_=tobereplaced555&washere=true",
"2 parameters surrounding _="
)
];