Skip to content

Commit

Permalink
MDL-30876 filter_mediaplugin Wrapping the style sheets access with tr…
Browse files Browse the repository at this point in the history
…y & catch

Conflicts:

	lib/javascript-static.js
  • Loading branch information
dmonllao authored and Sam Hemelryk committed Jul 17, 2012
1 parent 6039dc5 commit 8f80180
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions lib/javascript-static.js
Original file line number Diff line number Diff line change
Expand Up @@ -1771,15 +1771,27 @@ M.util.load_flowplayer = function() {

var rule;
for (var j=0; j < document.styleSheets.length; j++) {
if (typeof (document.styleSheets[j].rules) != 'undefined') {
var allrules = document.styleSheets[j].rules;
} else if (typeof (document.styleSheets[j].cssRules) != 'undefined') {
var allrules = document.styleSheets[j].cssRules;
} else {
// why??

// To avoid javascript security violation accessing cross domain stylesheets
var allrules = false;
try {
if (typeof (document.styleSheets[j].rules) != 'undefined') {
allrules = document.styleSheets[j].rules;
} else if (typeof (document.styleSheets[j].cssRules) != 'undefined') {
allrules = document.styleSheets[j].cssRules;
} else {
// why??
continue;
}
} catch (e) {
continue;
}
if (!allrules) continue;

// On cross domain style sheets Chrome V8 allows access to rules but returns null
if (!allrules) {
continue;
}

for(var i=0; i<allrules.length; i++) {
rule = '';
if (/^\.mp3flowplayer_.*Color$/.test(allrules[i].selectorText)) {
Expand Down

0 comments on commit 8f80180

Please sign in to comment.