| <!DOCTYPE html> |
| <script src="../../../resources/js-test.js"></script> |
| |
| <pre id="console"></div> |
| |
| <script> |
| description('Tests ShadowRoot.olderShadowRoot property'); |
| |
| function createRoots(host, n) { |
| var roots = []; |
| for (var i = 0; i < n; i++) { |
| roots.push(host.createShadowRoot()); |
| } |
| return roots; |
| } |
| |
| // Out of document |
| var host = document.createElement('div'); |
| var roots = createRoots(host, 2); |
| shouldBe('roots[1].olderShadowRoot', 'roots[0]'); |
| shouldBeNull('roots[0].olderShadowRoot'); |
| |
| // In document |
| host = document.createElement('div'); |
| document.body.appendChild(host); |
| roots = createRoots(host, 3); |
| shouldBe('roots[2].olderShadowRoot', 'roots[1]'); |
| shouldBe('roots[1].olderShadowRoot', 'roots[0]'); |
| shouldBeNull('roots[0].olderShadowRoot'); |
| host.remove(); |
| |
| // Out of document, in nested shadow, accessed out of order |
| host = document.createElement('span'); |
| roots[1].appendChild(host); |
| roots = createRoots(host, 7); |
| shouldBeNull('roots[0].olderShadowRoot'); |
| shouldBe('roots[1].olderShadowRoot', 'roots[0]'); |
| shouldBe('roots[6].olderShadowRoot', 'roots[5]'); |
| |
| // Single root |
| host = document.createElement('table'); |
| root = host.createShadowRoot(); |
| shouldBeNull('root.olderShadowRoot'); |
| |
| // Cannot set property |
| host = document.createElement('span'); |
| roots = createRoots(host, 2); |
| var donor = document.createElement('div'); |
| donor.root = donor.createShadowRoot(); |
| roots[1].olderShadowRoot = donor.root; |
| shouldBe('roots[1].olderShadowRoot', 'roots[0]'); |
| |
| successfullyParsed = true; |
| </script> |
| </body> |
| </html> |