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
14e1501b
Commit
14e1501b
authored
Nov 01, 2012
by
Richard Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix testing of no-ajax custom builds
parent
03a07628
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
14 deletions
+28
-14
jquery-1.8.2.ajax_xhr.min.js
test/data/jquery-1.8.2.ajax_xhr.min.js
+2
-0
testinit.js
test/data/testinit.js
+6
-4
testrunner.js
test/data/testrunner.js
+15
-10
index.html
test/index.html
+3
-0
support.js
test/unit/support.js
+2
-0
No files found.
test/data/jquery-1.8.2.ajax_xhr.min.js
0 → 100644
View file @
14e1501b
This diff is collapsed.
Click to expand it.
test/data/testinit.js
View file @
14e1501b
/*jshint multistr:true */
/*jshint multistr:true */
var
jQuery
=
this
.
jQuery
||
"jQuery"
,
// For testing .noConflict()
var
originaljQuery
=
this
.
jQuery
||
"jQuery"
,
$
=
this
.
$
||
"$"
,
original$
=
this
.
$
||
"$"
,
originaljQuery
=
jQuery
,
original$
=
$
,
hasPHP
=
true
,
hasPHP
=
true
,
// Disable Ajax tests to reduce network strain
// Disable Ajax tests to reduce network strain
// Re-enabled (at least the variable should be declared)
// Re-enabled (at least the variable should be declared)
isLocal
=
window
.
location
.
protocol
===
"file:"
,
isLocal
=
window
.
location
.
protocol
===
"file:"
,
amdDefined
;
amdDefined
;
// For testing .noConflict()
this
.
jQuery
=
originaljQuery
;
this
.
$
=
original$
;
/**
/**
* Set up a mock AMD define function for testing AMD registration.
* Set up a mock AMD define function for testing AMD registration.
*/
*/
...
...
test/data/testrunner.js
View file @
14e1501b
...
@@ -22,6 +22,7 @@ function testSubproject( label, url, risTests ) {
...
@@ -22,6 +22,7 @@ function testSubproject( label, url, risTests ) {
module
(
label
);
module
(
label
);
// Duckpunch QUnit
// Duckpunch QUnit
// TODO restore parent fixture on teardown to support reordering
module
=
QUnit
.
module
=
function
(
name
)
{
module
=
QUnit
.
module
=
function
(
name
)
{
var
args
=
arguments
;
var
args
=
arguments
;
...
@@ -41,7 +42,7 @@ function testSubproject( label, url, risTests ) {
...
@@ -41,7 +42,7 @@ function testSubproject( label, url, risTests ) {
// Find test function and wrap to require subproject fixture
// Find test function and wrap to require subproject fixture
for
(
;
i
>=
0
;
i
--
)
{
for
(
;
i
>=
0
;
i
--
)
{
if
(
jQuery
.
isFunction
(
args
[
i
]
)
)
{
if
(
original
jQuery
.
isFunction
(
args
[
i
]
)
)
{
args
[
i
]
=
requireFixture
(
args
[
i
]
);
args
[
i
]
=
requireFixture
(
args
[
i
]
);
break
;
break
;
}
}
...
@@ -52,14 +53,14 @@ function testSubproject( label, url, risTests ) {
...
@@ -52,14 +53,14 @@ function testSubproject( label, url, risTests ) {
// Load tests and fixture from subproject
// Load tests and fixture from subproject
// Test order matters, so we must be synchronous and throw an error on load failure
// Test order matters, so we must be synchronous and throw an error on load failure
jQuery
.
ajax
(
url
,
{
original
jQuery
.
ajax
(
url
,
{
async
:
false
,
async
:
false
,
dataType
:
"html"
,
dataType
:
"html"
,
error
:
function
(
jqXHR
,
status
)
{
error
:
function
(
jqXHR
,
status
)
{
throw
new
Error
(
"Could not load: "
+
url
+
" ("
+
status
+
")"
);
throw
new
Error
(
"Could not load: "
+
url
+
" ("
+
status
+
")"
);
},
},
success
:
function
(
data
,
status
,
jqXHR
)
{
success
:
function
(
data
,
status
,
jqXHR
)
{
var
page
=
jQuery
.
parseHTML
(
var
page
=
original
jQuery
.
parseHTML
(
// replace html/head with dummy elements so they are represented in the DOM
// replace html/head with dummy elements so they are represented in the DOM
(
data
||
""
).
replace
(
/<
\/?((
!DOCTYPE|html|head
)\b
.*
?)
>/gi
,
"[$1]"
),
(
data
||
""
).
replace
(
/<
\/?((
!DOCTYPE|html|head
)\b
.*
?)
>/gi
,
"[$1]"
),
document
,
document
,
...
@@ -69,15 +70,15 @@ function testSubproject( label, url, risTests ) {
...
@@ -69,15 +70,15 @@ function testSubproject( label, url, risTests ) {
if
(
!
page
||
!
page
.
length
)
{
if
(
!
page
||
!
page
.
length
)
{
this
.
error
(
jqXHR
,
"no data"
);
this
.
error
(
jqXHR
,
"no data"
);
}
}
page
=
jQuery
(
page
);
page
=
original
jQuery
(
page
);
// Include subproject tests
// Include subproject tests
page
.
filter
(
"script[src]"
).
add
(
page
.
find
(
"script[src]"
)
).
each
(
function
()
{
page
.
filter
(
"script[src]"
).
add
(
page
.
find
(
"script[src]"
)
).
each
(
function
()
{
var
src
=
jQuery
(
this
).
attr
(
"src"
),
var
src
=
original
jQuery
(
this
).
attr
(
"src"
),
html
=
"<script src='"
+
url
+
src
+
"'></script>"
;
html
=
"<script src='"
+
url
+
src
+
"'></script>"
;
if
(
risTests
.
test
(
src
)
)
{
if
(
risTests
.
test
(
src
)
)
{
if
(
jQuery
.
isReady
)
{
if
(
original
jQuery
.
isReady
)
{
jQuery
(
"head"
).
first
().
append
(
html
);
original
jQuery
(
"head"
).
first
().
append
(
html
);
}
else
{
}
else
{
document
.
write
(
html
);
document
.
write
(
html
);
}
}
...
@@ -105,7 +106,7 @@ function testSubproject( label, url, risTests ) {
...
@@ -105,7 +106,7 @@ function testSubproject( label, url, risTests ) {
}
}
// Replace the current fixture, including content outside of #qunit-fixture
// Replace the current fixture, including content outside of #qunit-fixture
var
oldFixture
=
jQuery
(
"#qunit-fixture"
);
var
oldFixture
=
original
jQuery
(
"#qunit-fixture"
);
while
(
oldFixture
.
length
&&
!
oldFixture
.
prevAll
(
"[id^='qunit-']"
).
length
)
{
while
(
oldFixture
.
length
&&
!
oldFixture
.
prevAll
(
"[id^='qunit-']"
).
length
)
{
oldFixture
=
oldFixture
.
parent
();
oldFixture
=
oldFixture
.
parent
();
}
}
...
@@ -115,7 +116,7 @@ function testSubproject( label, url, risTests ) {
...
@@ -115,7 +116,7 @@ function testSubproject( label, url, risTests ) {
// WARNING: UNDOCUMENTED INTERFACE
// WARNING: UNDOCUMENTED INTERFACE
QUnit
.
config
.
fixture
=
fixtureHTML
;
QUnit
.
config
.
fixture
=
fixtureHTML
;
QUnit
.
reset
();
QUnit
.
reset
();
if
(
jQuery
(
"#qunit-fixture"
).
html
()
!==
fixtureHTML
)
{
if
(
original
jQuery
(
"#qunit-fixture"
).
html
()
!==
fixtureHTML
)
{
ok
(
false
,
"Copied subproject fixture"
);
ok
(
false
,
"Copied subproject fixture"
);
return
;
return
;
}
}
...
@@ -285,7 +286,11 @@ function testSubproject( label, url, risTests ) {
...
@@ -285,7 +286,11 @@ function testSubproject( label, url, risTests ) {
// Reset internal jQuery state
// Reset internal jQuery state
jQuery
.
event
.
global
=
{};
jQuery
.
event
.
global
=
{};
jQuery
.
ajaxSettings
=
jQuery
.
extend
(
{},
ajaxSettings
);
if
(
ajaxSettings
)
{
jQuery
.
ajaxSettings
=
jQuery
.
extend
(
{},
ajaxSettings
);
}
else
{
delete
jQuery
.
ajaxSettings
;
}
// Let QUnit reset the fixture
// Let QUnit reset the fixture
reset
.
apply
(
this
,
arguments
);
reset
.
apply
(
this
,
arguments
);
...
...
test/index.html
View file @
14e1501b
...
@@ -8,6 +8,9 @@
...
@@ -8,6 +8,9 @@
<link
rel=
"Stylesheet"
media=
"screen"
href=
"data/testsuite.css"
/>
<link
rel=
"Stylesheet"
media=
"screen"
href=
"data/testsuite.css"
/>
<!-- Includes -->
<!-- Includes -->
<!-- Allows us to fetch submodule tests when using a no-ajax build -->
<script
src=
"data/jquery-1.8.2.ajax_xhr.min.js"
></script>
<script
src=
"data/testinit.js"
></script>
<script
src=
"data/testinit.js"
></script>
<script
src=
"qunit/qunit/qunit.js"
></script>
<script
src=
"qunit/qunit/qunit.js"
></script>
...
...
test/unit/support.js
View file @
14e1501b
...
@@ -257,6 +257,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
...
@@ -257,6 +257,8 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
for
(
var
i
in
expected
)
{
for
(
var
i
in
expected
)
{
if
(
jQuery
.
ajax
||
i
!==
"ajax"
&&
i
!==
"cors"
)
{
if
(
jQuery
.
ajax
||
i
!==
"ajax"
&&
i
!==
"cors"
)
{
equal
(
jQuery
.
support
[
i
],
expected
[
i
],
"jQuery.support['"
+
i
+
"']: "
+
jQuery
.
support
[
i
]
+
", expected['"
+
i
+
"']: "
+
expected
[
i
]);
equal
(
jQuery
.
support
[
i
],
expected
[
i
],
"jQuery.support['"
+
i
+
"']: "
+
jQuery
.
support
[
i
]
+
", expected['"
+
i
+
"']: "
+
expected
[
i
]);
}
else
{
ok
(
true
,
"no ajax; skipping jQuery.support['"
+
i
+
"']"
);
}
}
}
}
});
});
...
...
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