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
3774ee49
Commit
3774ee49
authored
Oct 11, 2013
by
Richard Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No ticket: Fix subproject iframe tests
(cherry picked from commit
13d58a9b
)
parent
64bdf414
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
9 deletions
+18
-9
.jshintrc
test/.jshintrc
+1
-0
testinit.js
test/data/testinit.js
+10
-5
testrunner.js
test/data/testrunner.js
+7
-4
No files found.
test/.jshintrc
View file @
3774ee49
...
@@ -60,6 +60,7 @@
...
@@ -60,6 +60,7 @@
"originaljQuery": true,
"originaljQuery": true,
"$": true,
"$": true,
"original$": true,
"original$": true,
"baseURL": true,
"externalHost": true
"externalHost": true
}
}
}
}
test/data/testinit.js
View file @
3774ee49
/*jshint multistr:true, quotmark:false */
/*jshint multistr:true, quotmark:false */
var
fireNative
,
originaljQuery
,
original$
,
var
fireNative
,
originaljQuery
,
original$
,
baseURL
=
""
,
supportjQuery
=
this
.
jQuery
,
supportjQuery
=
this
.
jQuery
,
// see RFC 2606
// see RFC 2606
externalHost
=
"example.com"
;
externalHost
=
"example.com"
;
...
@@ -130,7 +131,8 @@ fireNative = document.createEvent ?
...
@@ -130,7 +131,8 @@ fireNative = document.createEvent ?
* @result "data/test.php?foo=bar&10538358345554"
* @result "data/test.php?foo=bar&10538358345554"
*/
*/
function
url
(
value
)
{
function
url
(
value
)
{
return
value
+
(
/
\?
/
.
test
(
value
)
?
"&"
:
"?"
)
+
new
Date
().
getTime
()
+
""
+
parseInt
(
Math
.
random
()
*
100000
,
10
);
return
baseURL
+
value
+
(
/
\?
/
.
test
(
value
)
?
"&"
:
"?"
)
+
new
Date
().
getTime
()
+
""
+
parseInt
(
Math
.
random
()
*
100000
,
10
);
}
}
// Ajax testing helper
// Ajax testing helper
...
@@ -236,6 +238,9 @@ this.testIframeWithCallback = function( title, fileName, func ) {
...
@@ -236,6 +238,9 @@ this.testIframeWithCallback = function( title, fileName, func ) {
test
(
title
,
function
()
{
test
(
title
,
function
()
{
var
iframe
;
var
iframe
;
// Expect one assertion, but allow overrides
expect
(
1
);
stop
();
stop
();
window
.
iframeCallback
=
function
()
{
window
.
iframeCallback
=
function
()
{
var
self
=
this
,
var
self
=
this
,
...
@@ -248,12 +253,12 @@ this.testIframeWithCallback = function( title, fileName, func ) {
...
@@ -248,12 +253,12 @@ this.testIframeWithCallback = function( title, fileName, func ) {
start
();
start
();
},
0
);
},
0
);
};
};
iframe
=
jQuery
(
"<div/>"
).
append
(
iframe
=
jQuery
(
"<div/>"
).
css
({
position
:
"absolute"
,
width
:
"500px"
,
left
:
"-600px"
})
jQuery
(
"<iframe/>"
).
attr
(
"src"
,
url
(
"./data/"
+
fileName
)
)
.
append
(
jQuery
(
"<iframe/>"
).
attr
(
"src"
,
url
(
"./data/"
+
fileName
)
)
)
).
appendTo
(
"body
"
);
.
appendTo
(
"#qunit-fixture
"
);
});
});
};
};
this
.
iframeCallback
=
undefined
;
window
.
iframeCallback
=
undefined
;
// Tests are always loaded async
// Tests are always loaded async
QUnit
.
config
.
autostart
=
false
;
QUnit
.
config
.
autostart
=
false
;
...
...
test/data/testrunner.js
View file @
3774ee49
...
@@ -238,7 +238,7 @@ window.Globals = (function() {
...
@@ -238,7 +238,7 @@ window.Globals = (function() {
* @param {String} url Test folder location
* @param {String} url Test folder location
* @param {RegExp} risTests To filter script sources
* @param {RegExp} risTests To filter script sources
*/
*/
function
testSubproject
(
label
,
url
,
risTests
,
complete
)
{
function
testSubproject
(
label
,
subProjectURL
,
risTests
,
complete
)
{
var
sub
,
fixture
,
fixtureHTML
,
var
sub
,
fixture
,
fixtureHTML
,
fixtureReplaced
=
false
;
fixtureReplaced
=
false
;
...
@@ -280,11 +280,11 @@ function testSubproject( label, url, risTests, complete ) {
...
@@ -280,11 +280,11 @@ function testSubproject( label, url, risTests, complete ) {
// 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
supportjQuery
.
ajax
(
url
,
{
supportjQuery
.
ajax
(
subProjectURL
,
{
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: "
+
subProjectURL
+
" ("
+
status
+
")"
);
},
},
success
:
function
(
data
,
status
,
jqXHR
)
{
success
:
function
(
data
,
status
,
jqXHR
)
{
var
sources
=
[],
var
sources
=
[],
...
@@ -312,7 +312,7 @@ function testSubproject( label, url, risTests, complete ) {
...
@@ -312,7 +312,7 @@ function testSubproject( label, url, risTests, complete ) {
(
function
loadDep
()
{
(
function
loadDep
()
{
var
dep
=
sources
.
shift
();
var
dep
=
sources
.
shift
();
if
(
dep
)
{
if
(
dep
)
{
require
(
[
url
+
dep
],
loadDep
);
require
(
[
subProjectURL
+
dep
],
loadDep
);
}
else
if
(
complete
)
{
}
else
if
(
complete
)
{
complete
();
complete
();
}
}
...
@@ -338,6 +338,9 @@ function testSubproject( label, url, risTests, complete ) {
...
@@ -338,6 +338,9 @@ function testSubproject( label, url, risTests, complete ) {
return
;
return
;
}
}
// Update helper function behavior
baseURL
=
subProjectURL
;
// Replace the current fixture, including content outside of #qunit-fixture
// Replace the current fixture, including content outside of #qunit-fixture
var
oldFixture
=
supportjQuery
(
"#qunit-fixture"
);
var
oldFixture
=
supportjQuery
(
"#qunit-fixture"
);
while
(
oldFixture
.
length
&&
!
oldFixture
.
prevAll
(
"[id='qunit']"
).
length
)
{
while
(
oldFixture
.
length
&&
!
oldFixture
.
prevAll
(
"[id='qunit']"
).
length
)
{
...
...
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