aboutsummaryrefslogtreecommitdiffstats
path: root/test/data/testinit.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/data/testinit.js')
-rw-r--r--test/data/testinit.js46
1 files changed, 36 insertions, 10 deletions
diff --git a/test/data/testinit.js b/test/data/testinit.js
index bff6b8dff..6050eec4c 100644
--- a/test/data/testinit.js
+++ b/test/data/testinit.js
@@ -58,7 +58,21 @@ function t( a, b, c ) {
deepEqual(f, q.apply( q, c ), a + " (" + b + ")");
}
-function createDashboardXML() {
+function createComplexHTML() {
+ return 'html text<br/> \
+ <script type="text/javascript">/* <![CDATA[ */ \
+ testFoo = "foo"; jQuery("#foo").html("foo"); \
+ ok( true, "inline script executed" ); \
+ /* ]]> */</script> \
+ <script src="' + service("echo", {
+ content: 'var testBar = "bar"; \
+ jQuery("#ap").html("bar"); \
+ ok( true, "remote script executed");'
+ }) + '"></script> \
+ blabla';
+}
+
+function createDashboardXML( noParse ) {
var string = '<?xml version="1.0" encoding="UTF-8"?> \
<dashboard> \
<locations class="foo"> \
@@ -71,10 +85,10 @@ function createDashboardXML() {
</locations> \
</dashboard>';
- return jQuery.parseXML(string);
+ return noParse ? string : jQuery.parseXML(string);
}
-function createWithFriesXML() {
+function createWithFriesXML( noParse ) {
var string = '<?xml version="1.0" encoding="UTF-8"?> \
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" \
xmlns:xsd="http://www.w3.org/2001/XMLSchema" \
@@ -99,9 +113,9 @@ function createWithFriesXML() {
</response> \
</jsconf> \
</soap:Body> \
- </soap:Envelope>';
+ </soap:Envelope>'.replace( /\{\{\s*externalHost\s*\}\}/g, externalHost );
- return jQuery.parseXML( string.replace( /\{\{\s*externalHost\s*\}\}/g, externalHost ) );
+ return noParse ? string : jQuery.parseXML( string );
}
function createXMLFragment() {
@@ -133,16 +147,27 @@ fireNative = document.createEvent ?
/**
* Add random number to url to stop caching
*
- * @example url("data/test.html")
- * @result "data/test.html?10538358428943"
+ * @example url("data/iframe.html")
+ * @result "data/iframe.html?10538358428943"
*
- * @example url("data/test.php?foo=bar")
- * @result "data/test.php?foo=bar&10538358345554"
+ * @example url("data/ajax/echo?foo=bar")
+ * @result "data/ajax/echo?foo=bar&10538358345554"
*/
function url( value ) {
return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random() * 100000, 10);
}
+function service( value, data ) {
+ var fragment = url( "data/ajax/" + ( value || "" ) );
+ if ( data ) {
+ if ( typeof data !== "string" ) {
+ data = jQuery.param( data );
+ }
+ fragment += "&" + data;
+ }
+ return fragment;
+}
+
// Ajax testing helper
function ajaxTest( title, expect, options ) {
var requestOptions;
@@ -167,8 +192,9 @@ function ajaxTest( title, expect, options ) {
delete ajaxTest.abort;
if ( options.teardown ) {
options.teardown();
+ } else {
+ start();
}
- start();
}
},
requests = jQuery.map( requestOptions, function( options ) {