TinyMCE wpView: prevent fatal (security) errors when trying to access iframe.contentWindow in pausePlayers() and unsetPlayers(). See #28905.

git-svn-id: https://develop.svn.wordpress.org/trunk@29202 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2014-07-17 00:49:11 +00:00
parent 283fa473e6
commit 50f7313fdd

View File

@ -132,6 +132,7 @@ window.wp = window.wp || {};
frameBorder: '0', frameBorder: '0',
allowTransparency: 'true', allowTransparency: 'true',
scrolling: 'no', scrolling: 'no',
'class': 'wpview-sandbox',
style: { style: {
width: '100%', width: '100%',
display: 'block' display: 'block'
@ -554,9 +555,10 @@ window.wp = window.wp || {};
pausePlayers: function() { pausePlayers: function() {
this.getNodes( function( editor, node, content ) { this.getNodes( function( editor, node, content ) {
var p, win = $( 'iframe', content ).get(0).contentWindow; var p, win,
iframe = $( 'iframe.wpview-sandbox', content ).get(0);
if ( win && win.mejs ) { if ( iframe && ( win = iframe.contentWindow ) && win.mejs ) {
for ( p in win.mejs.players ) { for ( p in win.mejs.players ) {
win.mejs.players[p].pause(); win.mejs.players[p].pause();
} }
@ -566,9 +568,10 @@ window.wp = window.wp || {};
unsetPlayers: function() { unsetPlayers: function() {
this.getNodes( function( editor, node, content ) { this.getNodes( function( editor, node, content ) {
var p, win = $( 'iframe', content ).get(0).contentWindow; var p, win,
iframe = $( 'iframe.wpview-sandbox', content ).get(0);
if ( win && win.mejs ) { if ( iframe && ( win = iframe.contentWindow ) && win.mejs ) {
for ( p in win.mejs.players ) { for ( p in win.mejs.players ) {
win.mejs.players[p].remove(); win.mejs.players[p].remove();
} }