OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../resources/testharness.js"></script> |
| 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 |
| 5 <style> |
| 6 div { background-image: url(images.jpg); } |
| 7 </style> |
| 8 |
| 9 <body> |
| 10 </body> |
| 11 |
| 12 <script> |
| 13 var rulesForCssText = function (styleContent) { |
| 14 var doc = document.implementation.createHTMLDocument(""), |
| 15 styleElement = document.createElement("style"); |
| 16 |
| 17 styleElement.textContent = styleContent; |
| 18 // the style will only parsed once it is added to a document |
| 19 doc.body.appendChild(styleElement); |
| 20 |
| 21 return styleElement.sheet.cssRules; |
| 22 }; |
| 23 |
| 24 var cssRulesToText = function (cssRules) { |
| 25 var cssText = ""; |
| 26 Array.prototype.slice.call(cssRules).forEach(function (rule) { |
| 27 cssText += rule.cssText; |
| 28 }); |
| 29 return cssText; |
| 30 }; |
| 31 |
| 32 addEventListener("load", function() { |
| 33 test(function() { |
| 34 var styles = document.getElementsByTagName("style"), |
| 35 cssText = styles[styles.length-1].textContent.trim(); |
| 36 assert_equals(cssRulesToText(rulesForCssText(cssText)), cssText); |
| 37 }, 'Testing URLs in CSS'); |
| 38 }, false); |
| 39 </script> |
OLD | NEW |