From ecd8ddea33dc40ae2a57e4340be03faf2ba2f99b Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 1 Aug 2017 09:52:45 -0700 Subject: Tests: Add support for running unit tests via grunt with karma - Update QUnit to 1.23.1 - Remove unused dl#dl from test/index.html - Remove unused map#imgmap from test/index.html - Ensure all urls to data use baseURI - Add the 'grunt karma:main' task - customContextFile & customDebugFile - Add 'npm run jenkins' script Close gh-3744 Fixes gh-1999 --- test/data/ajax/content-type.php | 5 - test/data/ajax/evalScript.php | 1 - test/data/ajax/method.php | 1 - test/data/ajax/unreleasedXHR.html | 2 +- test/data/atom+xml.php | 4 - test/data/core/dont_return.php | 3 - test/data/core/dynamic_ready.html | 2 +- test/data/csp.include.html | 14 ++ test/data/echoData.php | 1 - test/data/echoQuery.php | 1 - test/data/errorWithJSON.php | 6 - test/data/errorWithText.php | 5 - test/data/etag.php | 24 ---- test/data/event/interactiveReady.html | 2 +- test/data/event/syncReady.html | 2 +- test/data/headers.php | 23 ---- test/data/if_modified_since.php | 20 --- test/data/json.php | 13 -- test/data/jsonp.php | 14 -- test/data/longLoadScript.php | 4 - test/data/mock.php | 244 ++++++++++++++++++++++++++++++++++ test/data/name.php | 24 ---- test/data/nocontent.php | 5 - test/data/params_html.php | 12 -- test/data/qunit-fixture.html | 237 +++++++++++++++++++++++++++++++++ test/data/qunit-fixture.js | 4 + test/data/script.php | 11 -- test/data/statusText.php | 5 - test/data/support/csp-clean.php | 3 - test/data/support/csp-log.php | 3 - test/data/support/csp.php | 19 --- test/data/test.html | 7 - test/data/test.include.html | 7 + test/data/test.php | 7 - test/data/testbar.php | 3 - test/data/testinit.js | 37 ++++-- test/data/text.php | 12 -- test/data/text.txt | 12 ++ test/data/with_fries_over_jsonp.php | 7 - 39 files changed, 547 insertions(+), 259 deletions(-) delete mode 100644 test/data/ajax/content-type.php delete mode 100644 test/data/ajax/evalScript.php delete mode 100644 test/data/ajax/method.php delete mode 100644 test/data/atom+xml.php delete mode 100644 test/data/core/dont_return.php create mode 100644 test/data/csp.include.html delete mode 100644 test/data/echoData.php delete mode 100644 test/data/echoQuery.php delete mode 100644 test/data/errorWithJSON.php delete mode 100644 test/data/errorWithText.php delete mode 100644 test/data/etag.php delete mode 100644 test/data/headers.php delete mode 100644 test/data/if_modified_since.php delete mode 100644 test/data/json.php delete mode 100644 test/data/jsonp.php delete mode 100644 test/data/longLoadScript.php create mode 100644 test/data/mock.php delete mode 100644 test/data/name.php delete mode 100644 test/data/nocontent.php delete mode 100644 test/data/params_html.php create mode 100644 test/data/qunit-fixture.html create mode 100644 test/data/qunit-fixture.js delete mode 100644 test/data/script.php delete mode 100644 test/data/statusText.php delete mode 100644 test/data/support/csp-clean.php delete mode 100644 test/data/support/csp-log.php delete mode 100644 test/data/support/csp.php delete mode 100644 test/data/test.html create mode 100644 test/data/test.include.html delete mode 100644 test/data/test.php delete mode 100644 test/data/testbar.php delete mode 100644 test/data/text.php create mode 100644 test/data/text.txt delete mode 100644 test/data/with_fries_over_jsonp.php (limited to 'test/data') diff --git a/test/data/ajax/content-type.php b/test/data/ajax/content-type.php deleted file mode 100644 index 162e3636d..000000000 --- a/test/data/ajax/content-type.php +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/test/data/ajax/evalScript.php b/test/data/ajax/evalScript.php deleted file mode 100644 index ea9b8c55f..000000000 --- a/test/data/ajax/evalScript.php +++ /dev/null @@ -1 +0,0 @@ -ok( "" === "GET", "request method is " ); \ No newline at end of file diff --git a/test/data/ajax/method.php b/test/data/ajax/method.php deleted file mode 100644 index d76ff964b..000000000 --- a/test/data/ajax/method.php +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/data/ajax/unreleasedXHR.html b/test/data/ajax/unreleasedXHR.html index 3eedaabf8..51c5b9486 100644 --- a/test/data/ajax/unreleasedXHR.html +++ b/test/data/ajax/unreleasedXHR.html @@ -15,7 +15,7 @@ jQuery(function() { }, 200 ); var number = 50; while( number-- ) { - jQuery.ajax("../name.php?wait=10"); + jQuery.ajax("../mock.php?action=wait&wait=10"); } }); diff --git a/test/data/atom+xml.php b/test/data/atom+xml.php deleted file mode 100644 index 944591abf..000000000 --- a/test/data/atom+xml.php +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/test/data/core/dont_return.php b/test/data/core/dont_return.php deleted file mode 100644 index 1eef33692..000000000 --- a/test/data/core/dont_return.php +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/test/data/core/dynamic_ready.html b/test/data/core/dynamic_ready.html index 1db068b95..e8180cd2b 100644 --- a/test/data/core/dynamic_ready.html +++ b/test/data/core/dynamic_ready.html @@ -7,7 +7,7 @@ - + + + + + + +

CSP Test Page

+ + diff --git a/test/data/echoData.php b/test/data/echoData.php deleted file mode 100644 index a37ba515a..000000000 --- a/test/data/echoData.php +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/data/echoQuery.php b/test/data/echoQuery.php deleted file mode 100644 index b72f329c9..000000000 --- a/test/data/echoQuery.php +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/data/errorWithJSON.php b/test/data/errorWithJSON.php deleted file mode 100644 index 62b187ecc..000000000 --- a/test/data/errorWithJSON.php +++ /dev/null @@ -1,6 +0,0 @@ - diff --git a/test/data/event/interactiveReady.html b/test/data/event/interactiveReady.html index 3fb25f907..a80b79467 100644 --- a/test/data/event/interactiveReady.html +++ b/test/data/event/interactiveReady.html @@ -18,7 +18,7 @@ jQuery( function () { oldIE into thinking the dom is ready, but it's not... leaving this check here for future trailblazers to attempt fixing this...--> - +
diff --git a/test/data/event/syncReady.html b/test/data/event/syncReady.html index 61a50e423..5aa510459 100644 --- a/test/data/event/syncReady.html +++ b/test/data/event/syncReady.html @@ -18,7 +18,7 @@ jQuery( document ).ready(function () { oldIE into thinking the dom is ready, but it's not... leaving this check here for future trailblazers to attempt fixing this...--> - +
diff --git a/test/data/headers.php b/test/data/headers.php deleted file mode 100644 index 79c183055..000000000 --- a/test/data/headers.php +++ /dev/null @@ -1,23 +0,0 @@ - $value ) { - - $key = str_replace( "_" , "-" , substr( $key , 0 , 5 ) == "HTTP_" ? substr( $key , 5 ) : $key ); - $headers[ $key ] = $value; - -} - -foreach( explode( "_" , $_GET[ "keys" ] ) as $key ) { - - // Only echo if key exists in the header - if ( isset( $headers[ strtoupper( $key ) ] ) ) { - echo "$key: " . @$headers[ strtoupper( $key ) ] . "\n"; - } - -} diff --git a/test/data/if_modified_since.php b/test/data/if_modified_since.php deleted file mode 100644 index 098b7da85..000000000 --- a/test/data/if_modified_since.php +++ /dev/null @@ -1,20 +0,0 @@ - diff --git a/test/data/json.php b/test/data/json.php deleted file mode 100644 index d6e0f2fc7..000000000 --- a/test/data/json.php +++ /dev/null @@ -1,13 +0,0 @@ - diff --git a/test/data/jsonp.php b/test/data/jsonp.php deleted file mode 100644 index 6c13d72e9..000000000 --- a/test/data/jsonp.php +++ /dev/null @@ -1,14 +0,0 @@ - diff --git a/test/data/longLoadScript.php b/test/data/longLoadScript.php deleted file mode 100644 index ba47168b4..000000000 --- a/test/data/longLoadScript.php +++ /dev/null @@ -1,4 +0,0 @@ - \ No newline at end of file diff --git a/test/data/mock.php b/test/data/mock.php new file mode 100644 index 000000000..692c417e8 --- /dev/null +++ b/test/data/mock.php @@ -0,0 +1,244 @@ +query['contentType']; + header("Content-type: $type"); + echo $req->query['response']; + } + + protected function wait( $req ) { + $wait = (int) $req->query['wait']; + sleep( $wait ); + if ( isset( $req->query['script'] ) ) { + header( 'Content-type: text/javascript' ); + } else { + header( 'Content-type: text/html' ); + echo 'ERROR '; + } + } + + protected function name( $req ) { + if ( $req->query['name'] === 'foo' ) { + echo 'bar'; + } elseif ( $_POST['name'] === 'peter' ) { + echo 'pan'; + } else { + echo 'ERROR'; + } + } + + protected function xml( $req ) { + header( 'Content-type: text/xml' ); + if ( $req->query['cal'] !== '5-2' && $_POST['cal'] !== '5-2' ) { + echo 'ERROR'; + return; + } + echo "5-23\n"; + } + + protected function atom( $req ) { + header( 'Content-type: atom+xml' ); + echo ''; + } + + protected function script( $req ) { + if ( isset( $req->query['header'] ) ) { + if ( $req->query['header'] === 'ecma' ) { + header( 'Content-type: application/ecmascript' ); + } else { + header( 'Content-type: text/javascript' ); + } + } else { + header( 'Content-type: text/html' ); + } + echo 'ok( true, "mock executed" );'; + } + + // Used to be in test.js, but was renamed to testbar.php + // https://github.com/jquery/jquery/commit/d89c278a33#commitcomment-23423165 + protected function testbar( $req ) { + echo 'this.testBar = "bar"; +jQuery("#ap").html("bar"); +ok( true, "mock executed");'; + } + + protected function json( $req ) { + if ( isset( $req->query['header'] ) ) { + header( 'Content-type: application/json' ); + } + + if ( isset( $req->query['array'] ) ) { + echo '[ {"name": "John", "age": 21}, {"name": "Peter", "age": 25 } ]'; + } else { + echo '{ "data": {"lang": "en", "length": 25} }'; + } + } + + protected function jsonp( $req ) { + if ( isset( $req->query['callback'] ) ) { + $callback = $req->query['callback']; + } elseif ( $req->method === 'GET' ) { + // Try REST-like path + preg_match( '/\/([^\/?]+)\?.+$/', $req->url, $m ); + $callback = $m[1]; + } else { + $callback = $_POST['callback']; + } + if ( isset( $req->query['array'] ) ) { + echo $callback . '([ {"name": "John", "age": 21}, {"name": "Peter", "age": 25 } ])'; + } else { + echo $callback . '({ "data": {"lang": "en", "length": 25} })'; + } + } + + protected function xmlOverJsonp( $req ) { + $callback = $_REQUEST['callback']; + $text = json_encode( file_get_contents( __DIR__ . '/with_fries.xml' ) ); + echo "$callback($text)\n"; + } + + protected function error( $req ) { + header( 'HTTP/1.0 400 Bad Request' ); + if ( isset( $req->query['json'] ) ) { + header( 'Content-Type: application/json' ); + echo '{ "code": 40, "message": "Bad Request" }'; + } else { + echo 'plain text message'; + } + } + + protected function headers( $req ) { + header( 'Sample-Header: Hello World' ); + header( 'Empty-Header: ' ); + header( 'Sample-Header2: Hello World 2' ); + + foreach ( explode( '|' , $req->query[ 'keys' ] ) as $key ) { + // Only echo if key exists in the header + if ( isset( $req->headers[ strtoupper( $key ) ] ) ) { + echo "$key: " . $req->headers[ strtoupper( $key ) ] . "\n"; + } + } + + } + + protected function echoData( $req ) { + echo file_get_contents('php://input'); + } + + protected function echoQuery( $req ) { + echo $_SERVER['QUERY_STRING']; + } + + protected function echoMethod( $req ) { + echo $req->method; + } + + protected function echoHtml( $req ) { + header( 'Content-type: text/html' ); + echo '
' . $req->method . '
'; + echo '
' . $_SERVER['QUERY_STRING'] . '
'; + echo '
' . file_get_contents('php://input') . '
'; + } + + protected function etag( $req ) { + $hash = md5( $req->query['ts'] ); + $etag = 'W/"' . $hash . '"'; + + $ifNoneMatch = isset( $req->headers['IF-NONE-MATCH'] ) ? $req->headers['IF-NONE-MATCH'] : ''; + if ($ifNoneMatch === $etag) { + header('HTTP/1.0 304 Not Modified'); + return; + } + + header("Etag: $etag"); + echo "ETag: $etag\n"; + if ( $ifNoneMatch ) { + echo "If-None-Match: $ifNoneMatch\n"; + } + } + + protected function ims( $req ) { + $ts = $req->query['ts']; + + $ims = isset( $req->headers['IF-MODIFIED-SINCE'] ) ? $req->headers['IF-MODIFIED-SINCE'] : ''; + if ($ims === $ts) { + header('HTTP/1.0 304 Not Modified'); + return; + } + + header("Last-Modified: $ts"); + echo "Last-Modified: $ts\n"; + if ( $ims ) { + echo "If-Modified-Since: $ims\n"; + } + } + + protected function status( $req ) { + header( "HTTP/1.0 {$req->query['code']} {$req->query['text']}" ); + } + + protected function testHTML( $req ) { + header( 'Content-type: text/html' ); + $html = file_get_contents( __DIR__ . '/test.include.html' ); + $html = str_replace( '{{baseURL}}', $req->query['baseURL'], $html ); + echo $html; + } + + protected function cspFrame( $req ) { + // This is CSP only for browsers with "Content-Security-Policy" header support + // i.e. no old WebKit or old Firefox + header( "Content-Security-Policy: default-src 'self'; report-uri ./mock.php?action=cspLog" ); + header( 'Content-type: text/html' ); + echo file_get_contents( __DIR__ . '/csp.include.html' ); + } + + protected function cspLog( $req ) { + file_put_contents( $this->cspFile, 'error' ); + } + + protected function cspClean( $req ) { + file_put_contents( $this->cspFile, '' ); + unlink( $this->cspFile ); + } + + public function __construct() { + $this->cspFile = __DIR__ . '/support/csp.log'; + } + + public function respond( stdClass $req ) { + if ( !isset( $req->query['action'] ) || !method_exists( $this, $req->query['action'] ) ) { + header( "HTTP/1.0 400 Bad Request" ); + echo "Invalid action query.\n"; + return; + } + $this->{$req->query['action']}( $req ); + } +} + +// Don't include PHP errors in http response +error_reporting( 0 ); + +// Collect headers +$headers = array(); +foreach ( $_SERVER as $name => $value ) { + if ( substr( $name, 0, 5 ) === 'HTTP_' ) { + $name = str_replace( '_', '-', substr( $name, 5 ) ); + $headers[$name] = $value; + } elseif ( $name === 'CONTENT_LENGTH' ) { + $headers['CONTENT-LENGTH'] = $value; + } elseif ( $name === 'CONTENT_TYPE' ) { + $headers['CONTENT-TYPE'] = $value; + } +} + +$mock = new MockServer(); +$req = (object) array( + 'query' => $_GET, + 'headers' => $headers, + 'method' => $_SERVER['REQUEST_METHOD'], + 'url' => $_SERVER['REQUEST_URI'], +); +$mock->respond( $req ); diff --git a/test/data/name.php b/test/data/name.php deleted file mode 100644 index 64028585d..000000000 --- a/test/data/name.php +++ /dev/null @@ -1,24 +0,0 @@ -$xml$result"; - die(); -} -$name = $_REQUEST['name']; -if($name == 'foo') { - echo "bar"; - die(); -} else if($name == 'peter') { - echo "pan"; - die(); -} - -echo 'ERROR '; -?> \ No newline at end of file diff --git a/test/data/nocontent.php b/test/data/nocontent.php deleted file mode 100644 index 9c8431bd7..000000000 --- a/test/data/nocontent.php +++ /dev/null @@ -1,5 +0,0 @@ - \ No newline at end of file diff --git a/test/data/params_html.php b/test/data/params_html.php deleted file mode 100644 index e88ef1521..000000000 --- a/test/data/params_html.php +++ /dev/null @@ -1,12 +0,0 @@ -
-$value ) - echo "$value"; -?> -
-
-$value ) - echo "$value"; -?> -
\ No newline at end of file diff --git a/test/data/qunit-fixture.html b/test/data/qunit-fixture.html new file mode 100644 index 000000000..e0fd3e60e --- /dev/null +++ b/test/data/qunit-fixture.html @@ -0,0 +1,237 @@ +

See this blog entry for more information.

+

+ Here are some links in a normal paragraph: Google, + Google Groups (Link). + This link has class="blog": + diveintomark + +

+
+

Everything inside the red border is inside a div with id="foo".

+

This is a normal link: Yahoo

+

This link has class="blog": Simon Willison's Weblog

+ +
+
+
+
+ +

Try them out:

+ +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + test element +
    +Float test. + +
    + + +
    +
    + +
    + + + + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + +
    +
    hi there
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
      +
    1. Rice
    2. +
    3. Beans
    4. +
    5. Blinis
    6. +
    7. Tofu
    8. +
    + +
    I'm hungry. I should...
    + ...Eat lots of food... | + ...Eat a little food... | + ...Eat no food... + ...Eat a burger... + ...Eat some funyuns... + ...Eat some funyuns... + + + + + + +
    + +
    + + +
    + +
    + 1 + 2 + + + + + + + + +
    +
    +
    +
    fadeIn
    fadeIn
    +
    fadeOut
    fadeOut
    + +
    show
    show
    +
    hide
    hide
    +
    hide
    hide
    + +
    togglein
    togglein
    +
    toggleout
    toggleout
    +
    toggleout
    toggleout
    + +
    slideUp
    slideUp
    +
    slideDown
    slideDown
    +
    slideUp
    slideUp
    + +
    slideToggleIn
    slideToggleIn
    +
    slideToggleOut
    slideToggleOut
    + +
    fadeToggleIn
    fadeToggleIn
    +
    fadeToggleOut
    fadeToggleOut
    + +
    fadeTo
    fadeTo
    +
    + +
    + +
    diff --git a/test/data/qunit-fixture.js b/test/data/qunit-fixture.js new file mode 100644 index 000000000..6ea2f3b3d --- /dev/null +++ b/test/data/qunit-fixture.js @@ -0,0 +1,4 @@ +// Generated by build/tasks/qunit_fixture.js +QUnit.config.fixture = "

    See this blog entry for more information.

    \n

    \n\tHere are some links in a normal paragraph: Google,\n\tGoogle Groups (Link).\n\tThis link has class=\"blog\":\n\tdiveintomark\n\n

    \n
    \n\t

    Everything inside the red border is inside a div with id=\"foo\".

    \n\t

    This is a normal link: Yahoo

    \n\t

    This link has class=\"blog\": Simon Willison's Weblog

    \n\n
    \n
    \n\t
    \n
    \n\n

    Try them out:

    \n\n
      \n
      \n\t\n\t\n\t\n\t\n\n\t\n\t\n\t\n\n\t\n\t\n\n\t\n\t\n\n\t\n\n\t\n\n\t\n\t\n\t\n\t\n\t\n\n\t\n\t\t\n\t\t\n\t\n\n\t\n\t\n\t\n\t\n\t\n\t\n\n\ttest element\n
      \nFloat test.\n\n
      \n\t\n\t\n
      \n
      \n\n
      \n\t\n\t\n\t\n\t\n
      \n\n
      \n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\n
      \n
      \n\t
      \n\t\t
      \n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t
      \n\t
      \n\t
      hi there
      \n\t
      \n\t\t
      hidden
      \n\t
      \n\t
      \n\t\t
      \n\t
      \n\t
      \n
      \n\n
      \n\t
        \n\t\t
      1. Rice
      2. \n\t\t
      3. Beans
      4. \n\t\t
      5. Blinis
      6. \n\t\t
      7. Tofu
      8. \n\t
      \n\n\t
      I'm hungry. I should...
      \n\t...Eat lots of food... |\n\t...Eat a little food... |\n\t...Eat no food...\n\t...Eat a burger...\n\t...Eat some funyuns...\n\t...Eat some funyuns...\n\t\n\t\n\t\n\t\n\t\t\n\t\n
      \n\n
      \n\t\n\t\n
      \n\n
      \n\t1\n\t2\n\t\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\n\t\n\t\n
      \n
      \n\t
      \n\t\t
      fadeIn
      fadeIn
      \n\t\t
      fadeOut
      fadeOut
      \n\n\t\t
      show
      show
      \n\t\t
      hide
      hide
      \n\t\t
      hide
      hide
      \n\n\t\t
      togglein
      togglein
      \n\t\t
      toggleout
      toggleout
      \n\t\t
      toggleout
      toggleout
      \n\n\t\t
      slideUp
      slideUp
      \n\t\t
      slideDown
      slideDown
      \n\t\t
      slideUp
      slideUp
      \n\n\t\t
      slideToggleIn
      slideToggleIn
      \n\t\t
      slideToggleOut
      slideToggleOut
      \n\n\t\t
      fadeToggleIn
      fadeToggleIn
      \n\t\t
      fadeToggleOut
      fadeToggleOut
      \n\n\t\t
      fadeTo
      fadeTo
      \n\t
      \n\n\t
      \n\t\n
      \n"; +// Compat with QUnit 1.x: +document.getElementById( "qunit-fixture" ).innerHTML = QUnit.config.fixture; diff --git a/test/data/script.php b/test/data/script.php deleted file mode 100644 index fb7110491..000000000 --- a/test/data/script.php +++ /dev/null @@ -1,11 +0,0 @@ - -ok( true, "Script executed correctly." ); diff --git a/test/data/statusText.php b/test/data/statusText.php deleted file mode 100644 index daf58ce3f..000000000 --- a/test/data/statusText.php +++ /dev/null @@ -1,5 +0,0 @@ - \ No newline at end of file diff --git a/test/data/support/csp-clean.php b/test/data/support/csp-clean.php deleted file mode 100644 index e16d047a3..000000000 --- a/test/data/support/csp-clean.php +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/test/data/support/csp-log.php b/test/data/support/csp-log.php deleted file mode 100644 index efbb9d7bc..000000000 --- a/test/data/support/csp-log.php +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/test/data/support/csp.php b/test/data/support/csp.php deleted file mode 100644 index 446000239..000000000 --- a/test/data/support/csp.php +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - CSP Test Page - - - - - - -

      CSP Test Page

      - - diff --git a/test/data/test.html b/test/data/test.html deleted file mode 100644 index f5bc2199f..000000000 --- a/test/data/test.html +++ /dev/null @@ -1,7 +0,0 @@ -html text
      - - -blabla diff --git a/test/data/test.include.html b/test/data/test.include.html new file mode 100644 index 000000000..73299db07 --- /dev/null +++ b/test/data/test.include.html @@ -0,0 +1,7 @@ +html text
      + + +blabla diff --git a/test/data/test.php b/test/data/test.php deleted file mode 100644 index d93dafad8..000000000 --- a/test/data/test.php +++ /dev/null @@ -1,7 +0,0 @@ -html text
      - - -blabla diff --git a/test/data/testbar.php b/test/data/testbar.php deleted file mode 100644 index 21aa6882b..000000000 --- a/test/data/testbar.php +++ /dev/null @@ -1,3 +0,0 @@ -this.testBar = "bar"; -jQuery("#ap").html("bar"); -ok( true, "testbar.php executed"); diff --git a/test/data/testinit.js b/test/data/testinit.js index 1aa9a65da..d6c0236e6 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -1,6 +1,11 @@ /* eslint no-multi-str: "off" */ -var baseURL = "", +// baseURL is intentionally set to "data/" instead of "". +// This is not just for convenience (since most files are in data/) +// but also to ensure that urls without prefix fail. +// Otherwise it's easy to write tests that pass on test/index.html +// but fail in Karma runner (where the baseURL is different). +var baseURL = "data/", supportjQuery = this.jQuery, // see RFC 2606 @@ -148,11 +153,13 @@ window.fireNative = document.createEvent ? /** * Add random number to url to stop caching * - * @example url("data/test.html") - * @result "data/test.html?10538358428943" + * Also prefixes with baseURL automatically. * - * @example url("data/test.php?foo=bar") - * @result "data/test.php?foo=bar&10538358345554" + * @example url("index.html") + * @result "data/index.html?10538358428943" + * + * @example url("mock.php?foo=bar") + * @result "data/mock.php?foo=bar&10538358345554" */ function url( value ) { return baseURL + value + ( /\?/.test( value ) ? "&" : "?" ) + @@ -239,7 +246,7 @@ this.testIframe = function( title, fileName, func, wrapper ) { var done = assert.async(), $iframe = supportjQuery( "