| | 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 | |
| | 24 | /* |
| | 25 | * The path in $mejs_folder is hardcoded, so this is just a sanity check to make sure the |
| | 26 | * correct directory is used, in case it gets renamed in the future. |
| | 27 | */ |
| | 28 | $this->assertGreaterThan( 0, count( $js_files ) ); |
| | 29 | |
| | 30 | $mejs_directory_iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $mejs_folder ) ); |
| | 31 | $mejs_swf_iterator = new RegexIterator( $mejs_directory_iterator, '/\.swf$/i', RecursiveRegexIterator::GET_MATCH ); |
| | 32 | |
| | 33 | // Make sure the Flash files haven't been re-added accidentally. |
| | 34 | $this->assertCount( 0, iterator_to_array( $mejs_swf_iterator ) ); |
| | 35 | } |
| | 36 | } |