aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/data/mock.php25
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' );