diff --git tests/phpunit/includes/functions.php tests/phpunit/includes/functions.php
index 696741166e..5fb08b03bf 100644
|
|
|
function _wp_rest_server_class_filter() { |
| 190 | 190 | // Skip `setcookie` calls in auth_cookie functions due to warning: |
| 191 | 191 | // Cannot modify header information - headers already sent by ... |
| 192 | 192 | tests_add_filter( 'send_auth_cookies', '__return_false' ); |
| | 193 | |
| | 194 | /** |
| | 195 | * glob() for a pattern in subdirectories. |
| | 196 | * |
| | 197 | * Does not support the `GLOB_BRACE` flag. |
| | 198 | * |
| | 199 | * Based on https://php.net/manual/en/function.glob.php#106595, which was licensed under Creative Commons Attribution 3.0. |
| | 200 | * |
| | 201 | * @since 5.0.0 |
| | 202 | * |
| | 203 | * @param string $pattern The regular expression pattern to search for. |
| | 204 | * @param int $flags Optional. Any flags that should be passed on to `glob()`. |
| | 205 | * @return array |
| | 206 | */ |
| | 207 | function glob_recursive( $pattern, $flags = 0 ) { |
| | 208 | $files = glob( $pattern, $flags ); |
| | 209 | |
| | 210 | foreach ( glob( dirname( $pattern ) . '/*', GLOB_ONLYDIR | GLOB_NOSORT ) as $dir ) { |
| | 211 | $files = array_merge( $files, glob_recursive( $dir . '/' . basename( $pattern ), $flags ) ); |
| | 212 | } |
| | 213 | |
| | 214 | return $files; |
| | 215 | } |
diff --git tests/phpunit/tests/dependencies/mediaelementjs.php tests/phpunit/tests/dependencies/mediaelementjs.php
new file mode 100644
index 0000000000..45de4c15d5
|
-
|
+
|
|
| | 1 | <?php |
| | 2 | |
| | 3 | /** |
| | 4 | * @group dependencies |
| | 5 | * @group scripts |
| | 6 | */ |
| | 7 | class Tests_Dependencies_MediaElementjs extends WP_UnitTestCase { |
| | 8 | /** |
| | 9 | * Test if the MediaElement.js Flash fallbacks have been re-added. |
| | 10 | * |
| | 11 | * MediaElement's Flash fallbacks were removed in WordPress 4.9.2 due to limited use cases and |
| | 12 | * a history of security vulnerabilities. It's unlikely that there'll ever be a need to |
| | 13 | * restore them in the future, and doing so could introduce security vulnerabilities. If you |
| | 14 | * want to re-add them, please discuss that with the Security team first. |
| | 15 | * |
| | 16 | * @since 5.0.0 |
| | 17 | * |
| | 18 | * @ticket 42720 |
| | 19 | */ |
| | 20 | function test_exclusion_of_flash() { |
| | 21 | $mejs_folder = dirname( ABSPATH ) . '/build/' . WPINC . '/js/mediaelement'; |
| | 22 | $js_files = glob( $mejs_folder . '/*.js' ); |
| | 23 | $swf_files = glob_recursive( $mejs_folder . '/*.swf' ); |
| | 24 | |
| | 25 | /* |
| | 26 | * The path in $mejs_folder is hardcoded, so this is just a sanity check to make sure the |
| | 27 | * correct directory is used, in case it gets renamed in the future. |
| | 28 | */ |
| | 29 | $this->assertGreaterThan( 0, count( $js_files ) ); |
| | 30 | |
| | 31 | // Make sure the Flash files haven't been re-added accidentally. |
| | 32 | $this->assertCount( 0, $swf_files ); |
| | 33 | } |
| | 34 | } |