|
| 1 | +<!doctype html> |
| 2 | +<html> |
| 3 | + <head> |
| 4 | + <title>base load test</title> |
| 5 | + <base href="../../html/"> |
| 6 | + <script> |
| 7 | + window.loadEvents = 0; |
| 8 | + (function() { |
| 9 | + function importLoaded(event) { |
| 10 | + window.loadEvents++; |
| 11 | + if (event.type === 'load' && event.target.import) { |
| 12 | + var s = event.target.import.querySelector('script'); |
| 13 | + chai.assert.ok(s, 'load event target can be used to find element in import'); |
| 14 | + } |
| 15 | + } |
| 16 | + |
| 17 | + function importError(event) { |
| 18 | + window.loadEvents++; |
| 19 | + } |
| 20 | + |
| 21 | + window.importLoaded = importLoaded; |
| 22 | + window.importError = importError; |
| 23 | + })(); |
| 24 | + </script> |
| 25 | + <script src="../../../tools/test/htmltest.js"></script> |
| 26 | + <script src="../../../tools/test/chai/chai.js"></script> |
| 27 | + <script src="../../html-imports.js"></script> |
| 28 | + <link rel="import" href="imports/load-1.html" onload="importLoaded(event)"> |
| 29 | + <link rel="import" href="imports/load-2.html" onload="importLoaded(event)"> |
| 30 | + <link rel="import" id="willError" href="imports/404.html" onerror="importError(event)"> |
| 31 | + </head> |
| 32 | + <body> |
| 33 | + <div id="test1" class="red">Test</div> |
| 34 | + <div id="test2" class="blue">Test</div> |
| 35 | + <div id="test3" class="image"></div> |
| 36 | + <script> |
| 37 | + document.addEventListener('HTMLImportsLoaded', function() { |
| 38 | + var baseURI = location.href.replace('base/load-base.html', '').replace(location.search, ''); |
| 39 | + chai.assert.equal(document.baseURI, baseURI, 'document.baseURI is correctly modified by base element'); |
| 40 | + // |
| 41 | + chai.assert.equal(loadEvents, 3, 'expected # of load events'); |
| 42 | + var test1 = getComputedStyle(document.querySelector('#test1')).backgroundColor; |
| 43 | + chai.assert.equal(test1, 'rgb(255, 0, 0)'); |
| 44 | + var test2 = getComputedStyle(document.querySelector('#test2')).backgroundColor; |
| 45 | + chai.assert.equal(test2, 'rgb(0, 0, 255)'); |
| 46 | + done(); |
| 47 | + }); |
| 48 | + </script> |
| 49 | + </body> |
| 50 | +</html> |
0 commit comments