This test failed when another iframe exists before the one added
during the test, because it uses $('iframe').prop() to access the
property, which, if matching multiple iframes, will use the first
one on the page.
Make it slightly less bad, by specifying that it should use the
last one instead, given we know that mediawiki/api/upload.js appends
to document.body.
Really, though, it should have a more reliable method of obtaining
the references to these nodes.
Change-Id: I0f0723668fa3366fb8228a7a3e8a4cb03ff87d27
api.uploadWithIframe( $( '<input>' )[ 0 ], { filename: 'Testing API upload.jpg' } );
api.uploadWithIframe( $( '<input>' )[ 0 ], { filename: 'Testing API upload.jpg' } );
- $iframe = $( 'iframe' );
+ $iframe = $( 'iframe:last-child' );
$form = $( 'form.mw-api-upload-form' );
$input = $form.find( 'input[name=filename]' );
$form = $( 'form.mw-api-upload-form' );
$input = $form.find( 'input[name=filename]' );
- assert.ok( $form.length > 0 );
- assert.ok( $input.length > 0 );
- assert.ok( $iframe.length > 0 );
- assert.strictEqual( $form.prop( 'target' ), $iframe.prop( 'id' ) );
- assert.strictEqual( $input.val(), 'Testing API upload.jpg' );
+ assert.ok( $form.length > 0, 'form' );
+ assert.ok( $input.length > 0, 'input' );
+ assert.ok( $iframe.length > 0, 'frame' );
+ assert.strictEqual( $form.prop( 'target' ), $iframe.prop( 'id' ), 'form.target and frame.id ' );
+ assert.strictEqual( $input.val(), 'Testing API upload.jpg', 'input value' );
} );
}( mediaWiki, jQuery ) );
} );
}( mediaWiki, jQuery ) );