| <!DOCTYPE html> |
| <html> |
| <body> |
| <script src='../../resources/testharness.js'></script> |
| <script src='../../resources/testharnessreport.js'></script> |
| <div id="container"></div> |
| <script> |
| var container = document.getElementById('container'); |
| |
| test(function () { |
| var header = document.createElement('header'); |
| var shadowRoot = header.attachShadow({mode: 'open'}); |
| shadowRoot.innerHTML = '<span id="foo"></span>'; |
| container.appendChild(header); |
| |
| assert_equals(window.foo, undefined); |
| }, "Window's named property getter should not return elements in shadow DOMs by id"); |
| |
| test(function () { |
| var header = document.createElement('header'); |
| var shadowRoot = header.attachShadow({mode: 'open'}); |
| shadowRoot.innerHTML = '<span id="foo1"></span>'; |
| container.appendChild(header); |
| |
| var span = document.createElement("span"); |
| span.id = 'foo1'; |
| container.appendChild(span); |
| |
| assert_equals(window.foo1, span); |
| assert_equals(shadowRoot.firstChild.id, 'foo1'); |
| shadowRoot.removeChild(shadowRoot.firstChild); |
| assert_equals(window.foo1, span); |
| }, "Window's named property getter should not return elements in shadow DOMs by id (duplicate id)"); |
| |
| test(function () { |
| var header = document.createElement('header'); |
| var shadowRoot = header.attachShadow({mode: 'open'}); |
| shadowRoot.innerHTML = '<span></span>'; |
| container.appendChild(header); |
| |
| assert_equals(window.foo2, undefined); |
| shadowRoot.firstChild.id = 'foo2'; |
| assert_equals(window.foo2, undefined); |
| }, "Window's named property getter should not return elements in shadow DOMs by id (id attribute update)"); |
| |
| test(function () { |
| var header = document.createElement('header'); |
| var shadowRoot = header.attachShadow({mode: 'open'}); |
| shadowRoot.innerHTML = '<span></span>'; |
| container.appendChild(header); |
| |
| var span = document.createElement("span"); |
| span.id = 'foo3'; |
| container.appendChild(span); |
| |
| assert_equals(window.foo3, span); |
| shadowRoot.firstChild.id = 'foo3'; |
| assert_equals(window.foo3, span); |
| |
| shadowRoot.firstChild.id = 'other'; |
| assert_equals(window.foo3, span); |
| }, "Window's named property getter should not return elements in shadow DOMs by id (duplicate id attribute update)"); |
| |
| test(function () { |
| var header = document.createElement('header'); |
| var shadowRoot = header.attachShadow({mode: 'open'}); |
| shadowRoot.innerHTML = '<form name="bar"></form>'; |
| document.body.appendChild(header); |
| |
| assert_equals(window.bar, undefined); |
| }, "Window's named property getter should not return elements in shadow DOMs by name"); |
| |
| test(function () { |
| var header = document.createElement('header'); |
| var shadowRoot = header.attachShadow({mode: 'open'}); |
| shadowRoot.innerHTML = '<form name="bar1"></form>'; |
| document.body.appendChild(header); |
| |
| var form = document.createElement("form"); |
| form.setAttribute('name', 'bar1'); |
| container.appendChild(form); |
| |
| assert_equals(window.bar1, form); |
| assert_equals(shadowRoot.firstChild.getAttribute('name'), 'bar1'); |
| shadowRoot.removeChild(shadowRoot.firstChild); |
| assert_equals(window.bar1, form); |
| }, "Window's named property getter should not return elements in shadow DOMs by name (duplicate name)"); |
| |
| test(function () { |
| var header = document.createElement('header'); |
| var shadowRoot = header.attachShadow({mode: 'open'}); |
| shadowRoot.innerHTML = '<form></form>'; |
| document.body.appendChild(header); |
| |
| assert_equals(window.bar2, undefined); |
| shadowRoot.firstChild.setAttribute('name', 'bar2'); |
| assert_equals(window.bar2, undefined); |
| }, "Window's named property getter should not return elements in shadow DOMs by name (name attribute update)"); |
| |
| test(function () { |
| var header = document.createElement('header'); |
| var shadowRoot = header.attachShadow({mode: 'open'}); |
| shadowRoot.innerHTML = '<form></form>'; |
| document.body.appendChild(header); |
| |
| var form = document.createElement("form"); |
| form.setAttribute('name', 'bar3'); |
| container.appendChild(form); |
| |
| assert_equals(window.bar3, form); |
| shadowRoot.firstChild.setAttribute('name', 'bar3'); |
| assert_equals(window.bar3, form); |
| |
| shadowRoot.firstChild.setAttribute('name', 'other'); |
| assert_equals(window.bar3, form); |
| }, "Window's named property getter should not return elements in shadow DOMs by name (duplicate name attribute update)"); |
| </script> |
| </body> |
| </html> |