@@ -59,7 +59,22 @@ protected function script( $req ) {
59
59
} else {
60
60
header ( 'Content-type: text/html ' );
61
61
}
62
- echo 'QUnit.assert.ok( true, "mock executed" ); ' ;
62
+
63
+ if ( !empty ( $ req ->query ['cors ' ] ) ) {
64
+ header ( "Access-Control-Allow-Origin: * " );
65
+ }
66
+
67
+ if ( !empty ( $ req ->query ['callback ' ] ) ) {
68
+ $ headers = array_combine (
69
+ array_map ( 'strtolower ' , array_keys ( $ req ->headers ) ),
70
+ array_values ( $ req ->headers )
71
+ );
72
+
73
+ echo cleanCallback ( $ req ->query ['callback ' ] ) .
74
+ "( " . json_encode ( [ 'headers ' => $ headers ] ) . ") " ;
75
+ } else {
76
+ echo 'QUnit.assert.ok( true, "mock executed" ); ' ;
77
+ }
63
78
}
64
79
65
80
// Used to be in test.js, but was renamed to testbar.php
@@ -75,6 +90,10 @@ protected function json( $req ) {
75
90
header ( 'Content-type: application/json ' );
76
91
}
77
92
93
+ if ( isset ( $ req ->query ['cors ' ] ) ) {
94
+ header ( 'Access-Control-Allow-Origin: * ' );
95
+ }
96
+
78
97
if ( isset ( $ req ->query ['array ' ] ) ) {
79
98
echo '[ {"name": "John", "age": 21}, {"name": "Peter", "age": 25 } ] ' ;
80
99
} else {
@@ -196,16 +215,12 @@ protected function testHTML( $req ) {
196
215
}
197
216
198
217
protected function cspFrame ( $ req ) {
199
- // This is CSP only for browsers with "Content-Security-Policy" header support
200
- // i.e. no old WebKit or old Firefox
201
218
header ( "Content-Security-Policy: default-src 'self'; report-uri ./mock.php?action=cspLog " );
202
219
header ( 'Content-type: text/html ' );
203
220
echo file_get_contents ( __DIR__ . '/csp.include.html ' );
204
221
}
205
222
206
223
protected function cspNonce ( $ req ) {
207
- // This is CSP only for browsers with "Content-Security-Policy" header support
208
- // i.e. no old WebKit or old Firefox
209
224
$ test = $ req ->query ['test ' ] ? '- ' . $ req ->query ['test ' ] : '' ;
210
225
header ( "Content-Security-Policy: script-src 'nonce-jquery+hardcoded+nonce'; report-uri ./mock.php?action=cspLog " );
211
226
header ( 'Content-type: text/html ' );
0 commit comments