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 | |
27 Array.prototype.slice.call(cssRules).forEach(function (rule) { | |
28 cssText += rule.cssText; | |
29 }); | |
30 return cssText; | |
31 }; | |
32 | |
33 addEventListener("load", function() { | |
34 test(function() { | |
rune
2015/09/08 23:57:28
Indentation looks inconsistent. Sometimes 8, most
nainar
2015/09/09 00:30:30
Done.
On 2015/09/08 at 23:57:28, rune wrote:
| |
35 var styles = document.getElementsByTagName("style"), | |
36 cssText = styles[styles.length-1].textContent.trim(); | |
37 assert_equals(cssRulesToText(rulesForCssText(cssText)), cssT ext); | |
38 }, 'Testing URLs in CSS'); | |
39 }, false); | |
40 </script> | |
OLD | NEW |