OLD | NEW |
1 <html> | 1 <html> |
2 <body> | 2 <body> |
3 <script> | 3 <script> |
4 var base = document.createElement('base'); | 4 var base = document.createElement('base'); |
5 base.href = 'resources/'; | 5 base.href = 'resources/'; |
6 | 6 |
7 var link1 = document.createElement('link'); | 7 var link1 = document.createElement('link'); |
| 8 var promises = []; |
8 link1.setAttribute('rel', 'stylesheet'); | 9 link1.setAttribute('rel', 'stylesheet'); |
9 link1.setAttribute('href', 'stylesheet.css'); | 10 link1.setAttribute('href', 'stylesheet.css'); |
| 11 promises.push(new Promise(function(resolve) { |
| 12 link1.addEventListener('load', function() { resolve(); }, false); |
| 13 })); |
10 | 14 |
11 var foreignDocument = document.implementation.createHTMLDocument(''); | 15 var foreignDocument = document.implementation.createHTMLDocument(''); |
12 var link2 = foreignDocument.createElement('link'); | 16 var link2 = foreignDocument.createElement('link'); |
13 link2.setAttribute('rel', 'stylesheet'); | 17 link2.setAttribute('rel', 'stylesheet'); |
14 link2.setAttribute('href', 'stylesheet2.css'); | 18 link2.setAttribute('href', 'stylesheet2.css'); |
| 19 promises.push(new Promise(function(resolve) { |
| 20 link2.addEventListener('load', function() { resolve(); }, false); |
| 21 })); |
15 | 22 |
16 document.body.appendChild(base); | 23 document.body.appendChild(base); |
17 document.body.appendChild(link1); | 24 document.body.appendChild(link1); |
18 document.body.appendChild(link2); | 25 document.body.appendChild(link2); |
19 | 26 |
20 if (window.testRunner) | 27 if (window.testRunner) { |
21 testRunner.dumpAsText(); | 28 testRunner.dumpAsText(); |
| 29 testRunner.waitUntilDone(); |
| 30 } |
22 </script> | 31 </script> |
23 <p>This tests that links resouce URLs are resolved dynamically when inserted int
o | 32 <p>This tests that links resouce URLs are resolved dynamically when inserted int
o |
24 the document, and honor the base URL of the document at the time of insertion
.</p> | 33 the document, and honor the base URL of the document at the time of insertion
.</p> |
25 | 34 |
26 <h1 id=test>I should be blue</h1> | 35 <h1 id=test>I should be blue</h1> |
27 <h1 id=test2>I should be red</h1> | 36 <h1 id=test2>I should be red</h1> |
28 | 37 |
29 <script> | 38 <script> |
30 var test = document.getElementById('test'); | 39 Promise.all(promises).then(function() { |
31 var testColor = window.getComputedStyle(document.getElementById('test'), null).c
olor; | 40 var test = document.getElementById('test'); |
32 var test2 = document.getElementById('test2'); | 41 var testColor = window.getComputedStyle(document.getElementById('test'), nul
l).color; |
33 var test2Color = window.getComputedStyle(document.getElementById('test2'), null)
.color; | 42 var test2 = document.getElementById('test2'); |
34 test.innerHTML += testColor === 'rgb(0, 0, 255)' ? '...and I am!!!' : '...but I
am not =-('; | 43 var test2Color = window.getComputedStyle(document.getElementById('test2'), n
ull).color; |
35 test2.innerHTML += test2Color === 'rgb(255, 0, 0)' ? '...and I am!!!' : '...but
I am not =-('; | 44 test.innerHTML += testColor === 'rgb(0, 0, 255)' ? '...and I am!!!' : '...bu
t I am not =-('; |
| 45 test2.innerHTML += test2Color === 'rgb(255, 0, 0)' ? '...and I am!!!' : '...
but I am not =-('; |
| 46 testRunner.notifyDone(); |
| 47 }); |
36 </script> | 48 </script> |
37 </body></html> | 49 </body></html> |
38 | |
OLD | NEW |