diff options
author | Timmy Willison <timmywil@users.noreply.github.com> | 2024-08-22 21:21:43 -0400 |
---|---|---|
committer | Timmy Willison <timmywil@users.noreply.github.com> | 2024-08-24 10:05:01 -0400 |
commit | 8037b9f53ec4ba2ccd86fca510c8e8f2a0b6dcd2 (patch) | |
tree | 67f7a3940fb8dd9a127334b4308ef97db5345147 | |
parent | ed18576506689e9f787cf7196595222b94937d6d (diff) | |
download | jquery-8037b9f53ec4ba2ccd86fca510c8e8f2a0b6dcd2.tar.gz jquery-8037b9f53ec4ba2ccd86fca510c8e8f2a0b6dcd2.zip |
Tests: align mock.php with main branch (sans spacing diffs)
Ref gh-5531
-rw-r--r-- | test/data/mock.php | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/test/data/mock.php b/test/data/mock.php index 5cff30c34..9e7a96e27 100644 --- a/test/data/mock.php +++ b/test/data/mock.php @@ -59,7 +59,22 @@ class MockServer { } else { header( 'Content-type: text/html' ); } - echo 'QUnit.assert.ok( true, "mock executed" );'; + + if ( !empty( $req->query['cors'] ) ) { + header( "Access-Control-Allow-Origin: *" ); + } + + if ( !empty( $req->query['callback'] ) ) { + $headers = array_combine( + array_map( 'strtolower', array_keys( $req->headers ) ), + array_values( $req->headers ) + ); + + echo cleanCallback( $req->query['callback'] ) . + "(" . json_encode( [ 'headers' => $headers ] ) . ")"; + } else { + echo 'QUnit.assert.ok( true, "mock executed" );'; + } } // Used to be in test.js, but was renamed to testbar.php @@ -75,6 +90,10 @@ QUnit.assert.ok( true, "mock executed");'; header( 'Content-type: application/json' ); } + if ( isset( $req->query['cors'] ) ) { + header( 'Access-Control-Allow-Origin: *' ); + } + if ( isset( $req->query['array'] ) ) { echo '[ {"name": "John", "age": 21}, {"name": "Peter", "age": 25 } ]'; } else { @@ -196,16 +215,12 @@ QUnit.assert.ok( true, "mock executed");'; } 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 cspNonce( $req ) { - // This is CSP only for browsers with "Content-Security-Policy" header support - // i.e. no old WebKit or old Firefox $test = $req->query['test'] ? '-' . $req->query['test'] : ''; header( "Content-Security-Policy: script-src 'nonce-jquery+hardcoded+nonce'; report-uri ./mock.php?action=cspLog" ); header( 'Content-type: text/html' ); |