<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[206463] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/206463">206463</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2016-09-27 14:04:15 -0700 (Tue, 27 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Import w3c shadow DOM tests and fix one assertion
https://bugs.webkit.org/show_bug.cgi?id=162629

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

Import shadow DOM tests in web-platform-tests as of 7163d6eeed81e9e020545fbe0c4b11fc2c5963cd
except untriaged tests for v0 API, which we obviously don't implement.

Most of these tests are the ones we upstreamed from fast/shadow-dom/.

* web-platform-tests/shadow-dom/Document-prototype-adoptNode-expected.txt: Renamed from LayoutTests/fast/shadow-dom/Document-prototype-adoptNode-expected.txt.
* web-platform-tests/shadow-dom/Document-prototype-adoptNode.html: Renamed from LayoutTests/fast/shadow-dom/Document-prototype-adoptNode.html.
* web-platform-tests/shadow-dom/Document-prototype-currentScript-expected.txt: Renamed from LayoutTests/fast/shadow-dom/Document-prototype-currentScript-expected.txt.
* web-platform-tests/shadow-dom/Document-prototype-currentScript.html: Renamed from LayoutTests/fast/shadow-dom/Document-prototype-currentScript.html.
* web-platform-tests/shadow-dom/Document-prototype-importNode-expected.txt: Renamed from LayoutTests/fast/shadow-dom/Document-prototype-importNode-expected.txt.
* web-platform-tests/shadow-dom/Document-prototype-importNode.html: Renamed from LayoutTests/fast/shadow-dom/Document-prototype-importNode.html.
* web-platform-tests/shadow-dom/Element-interface-attachShadow-expected.txt: Added.
* web-platform-tests/shadow-dom/Element-interface-attachShadow.html: Renamed from LayoutTests/fast/shadow-dom/Element-interface-attachShadow.html.
* web-platform-tests/shadow-dom/Element-interface-shadowRoot-attribute-expected.txt: Renamed from LayoutTests/fast/shadow-dom/Element-interface-shadowRoot-attribute-expected.txt.
* web-platform-tests/shadow-dom/Element-interface-shadowRoot-attribute.html: Renamed from LayoutTests/fast/shadow-dom/Element-interface-shadowRoot-attribute.html.
* web-platform-tests/shadow-dom/Extensions-to-Event-Interface-expected.txt: Renamed from LayoutTests/fast/shadow-dom/Extensions-to-Event-Interface-expected.txt.
* web-platform-tests/shadow-dom/Extensions-to-Event-Interface.html: Renamed from LayoutTests/fast/shadow-dom/Extensions-to-Event-Interface.html.
* web-platform-tests/shadow-dom/HTMLSlotElement-interface-expected.txt: Renamed from LayoutTests/fast/shadow-dom/HTMLSlotElement-interface-expected.txt.
* web-platform-tests/shadow-dom/HTMLSlotElement-interface.html: Renamed from LayoutTests/fast/shadow-dom/HTMLSlotElement-interface.html.
* web-platform-tests/shadow-dom/MouseEvent-prototype-offsetX-offsetY-expected.txt: Renamed from LayoutTests/fast/shadow-dom/MouseEvent-prototype-offsetX-offsetY-expected.txt.
* web-platform-tests/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html: Renamed from LayoutTests/fast/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html.
* web-platform-tests/shadow-dom/Node-prototype-cloneNode-expected.txt: Added.
* web-platform-tests/shadow-dom/Node-prototype-cloneNode.html: Renamed from LayoutTests/fast/shadow-dom/Node-prototype-cloneNode.html.
* web-platform-tests/shadow-dom/OWNERS: Added.
* web-platform-tests/shadow-dom/ShadowRoot-interface-expected.txt: Renamed from LayoutTests/fast/shadow-dom/ShadowRoot-interface-expected.txt.
* web-platform-tests/shadow-dom/ShadowRoot-interface.html: Renamed from LayoutTests/fast/shadow-dom/ShadowRoot-interface.html.
* web-platform-tests/shadow-dom/Slotable-interface-expected.txt: Renamed from LayoutTests/fast/shadow-dom/Slotable-interface-assignedSlot-expected.txt.
* web-platform-tests/shadow-dom/Slotable-interface.html: Renamed from LayoutTests/fast/shadow-dom/Slotable-interface-assignedSlot.html.
* web-platform-tests/shadow-dom/event-composed-expected.txt: Added.
* web-platform-tests/shadow-dom/event-composed-path-expected.txt: Added.
* web-platform-tests/shadow-dom/event-composed-path-with-related-target-expected.txt: Added.
* web-platform-tests/shadow-dom/event-composed-path-with-related-target.html: Added.
* web-platform-tests/shadow-dom/event-composed-path.html: Added.
* web-platform-tests/shadow-dom/event-composed.html: Added.
* web-platform-tests/shadow-dom/event-inside-shadow-tree-expected.txt: Renamed from LayoutTests/fast/shadow-dom/event-inside-shadow-tree-expected.txt.
* web-platform-tests/shadow-dom/event-inside-shadow-tree.html: Renamed from LayoutTests/fast/shadow-dom/event-inside-shadow-tree.html.
* web-platform-tests/shadow-dom/event-inside-slotted-node-expected.txt: Renamed from LayoutTests/fast/shadow-dom/event-inside-slotted-node-expected.txt.
* web-platform-tests/shadow-dom/event-inside-slotted-node.html: Renamed from LayoutTests/fast/shadow-dom/event-inside-slotted-node.html.
* web-platform-tests/shadow-dom/event-with-related-target-expected.txt: Renamed from LayoutTests/fast/shadow-dom/event-with-related-target-expected.txt.
* web-platform-tests/shadow-dom/event-with-related-target.html: Renamed from LayoutTests/fast/shadow-dom/event-with-related-target.html.
* web-platform-tests/shadow-dom/leaktests/get-elements-expected.txt: Added.
* web-platform-tests/shadow-dom/leaktests/get-elements.html: Added.
* web-platform-tests/shadow-dom/leaktests/html-collection-expected.txt: Added.
* web-platform-tests/shadow-dom/leaktests/html-collection.html: Added.
* web-platform-tests/shadow-dom/leaktests/w3c-import.log: Added.
* web-platform-tests/shadow-dom/leaktests/window-frames-expected.txt: Added.
* web-platform-tests/shadow-dom/leaktests/window-frames.html: Added.
* web-platform-tests/shadow-dom/resources/Document-prototype-currentScript-helper.js: Renamed from LayoutTests/fast/shadow-dom/resources/Document-prototype-currentScript-helper.js.
* web-platform-tests/shadow-dom/resources/event-path-test-helpers.js: Added.
* web-platform-tests/shadow-dom/resources/shadow-dom-utils.js: Added.
* web-platform-tests/shadow-dom/resources/shadow-dom.js: Added.
* web-platform-tests/shadow-dom/resources/w3c-import.log: Added.
* web-platform-tests/shadow-dom/scroll-to-the-fragment-in-shadow-tree-expected.txt: Added.
* web-platform-tests/shadow-dom/scroll-to-the-fragment-in-shadow-tree.html: Added.
* web-platform-tests/shadow-dom/slotchange-event-expected.txt: Renamed from LayoutTests/fast/shadow-dom/slotchange-event-expected.txt.
* web-platform-tests/shadow-dom/slotchange-event.html: Renamed from LayoutTests/fast/shadow-dom/slotchange-event.html.
* web-platform-tests/shadow-dom/slotchange-expected.txt: Added.
* web-platform-tests/shadow-dom/slotchange.html: Added.
* web-platform-tests/shadow-dom/slots-expected.txt: Added.
* web-platform-tests/shadow-dom/slots-fallback-expected.txt: Added.
* web-platform-tests/shadow-dom/slots-fallback.html: Added.
* web-platform-tests/shadow-dom/slots.html: Added.
* web-platform-tests/shadow-dom/w3c-import.log: Added.

Source/WebCore:

The assertion failure was caused by RelatedNodeRetargeter's constructor mixing up the ancestor tree scopes
for the target and the related target. Fixed the bug by reversing the two.

Tests: imported/w3c/web-platform-tests/shadow-dom/event-composed-path-with-related-target.html

* dom/EventPath.cpp:
(WebCore::RelatedNodeRetargeter::RelatedNodeRetargeter): i and m_ancestorTreeScopes are for the related target
and j and targetTreeScopeAncestors are for the target.

LayoutTests:

Deleted the duplicated copies of tests in fast/shadow/ since this patch re-imports them via web-platform-tests.

* fast/shadow-dom/Element-interface-attachShadow-expected.txt: Removed.
* fast/shadow-dom/Node-prototype-cloneNode-expected.txt: Removed.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomEventPathcpp">trunk/Source/WebCore/dom/EventPath.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/</li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomDocumentprototypeadoptNodeexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-adoptNode-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomDocumentprototypeadoptNodehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-adoptNode.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomDocumentprototypecurrentScriptexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-currentScript-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomDocumentprototypecurrentScripthtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-currentScript.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomDocumentprototypeimportNodeexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-importNode-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomDocumentprototypeimportNodehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-importNode.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomElementinterfaceattachShadowexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-attachShadow-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomElementinterfaceattachShadowhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-attachShadow.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomElementinterfaceshadowRootattributeexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-shadowRoot-attribute-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomElementinterfaceshadowRootattributehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-shadowRoot-attribute.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomExtensionstoEventInterfaceexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Extensions-to-Event-Interface-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomExtensionstoEventInterfacehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Extensions-to-Event-Interface.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomHTMLSlotElementinterfaceexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/HTMLSlotElement-interface-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomHTMLSlotElementinterfacehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/HTMLSlotElement-interface.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomMouseEventprototypeoffsetXoffsetYexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/MouseEvent-prototype-offsetX-offsetY-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomMouseEventprototypeoffsetXoffsetYhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomNodeprototypecloneNodeexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Node-prototype-cloneNode-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomNodeprototypecloneNodehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Node-prototype-cloneNode.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomOWNERS">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/OWNERS</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomShadowRootinterfaceexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/ShadowRoot-interface-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomShadowRootinterfacehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/ShadowRoot-interface.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomSlotableinterfaceexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Slotable-interface-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomSlotableinterfacehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Slotable-interface.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventcomposedexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventcomposedpathexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventcomposedpathwithrelatedtargetexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path-with-related-target-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventcomposedpathwithrelatedtargethtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path-with-related-target.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventcomposedpathhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventcomposedhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventinsideshadowtreeexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-shadow-tree-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventinsideshadowtreehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-shadow-tree.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventinsideslottednodeexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-slotted-node-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventinsideslottednodehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-slotted-node.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventwithrelatedtargetexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-with-related-target-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventwithrelatedtargethtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-with-related-target.html</a></li>
<li>trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/</li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomleaktestsgetelementsexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/get-elements-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomleaktestsgetelementshtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/get-elements.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomleaktestshtmlcollectionexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/html-collection-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomleaktestshtmlcollectionhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/html-collection.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomleaktestsw3cimportlog">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/w3c-import.log</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomleaktestswindowframesexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/window-frames-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomleaktestswindowframeshtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/window-frames.html</a></li>
<li>trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/</li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomresourcesDocumentprototypecurrentScripthelperjs">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/Document-prototype-currentScript-helper.js</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomresourceseventpathtesthelpersjs">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/event-path-test-helpers.js</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomresourcesshadowdomutilsjs">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/shadow-dom-utils.js</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomresourcesshadowdomjs">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/shadow-dom.js</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomresourcesw3cimportlog">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/w3c-import.log</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomscrolltothefragmentinshadowtreeexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/scroll-to-the-fragment-in-shadow-tree-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomscrolltothefragmentinshadowtreehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/scroll-to-the-fragment-in-shadow-tree.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomslotchangeeventexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange-event-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomslotchangeeventhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange-event.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomslotchangeexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomslotchangehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomslotsexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomslotsfallbackexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-fallback-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomslotsfallbackhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-fallback.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomslotshtml">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomw3cimportlog">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/w3c-import.log</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastshadowdomDocumentprototypeadoptNodeexpectedtxt">trunk/LayoutTests/fast/shadow-dom/Document-prototype-adoptNode-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomDocumentprototypeadoptNodehtml">trunk/LayoutTests/fast/shadow-dom/Document-prototype-adoptNode.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomDocumentprototypecurrentScriptexpectedtxt">trunk/LayoutTests/fast/shadow-dom/Document-prototype-currentScript-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomDocumentprototypecurrentScripthtml">trunk/LayoutTests/fast/shadow-dom/Document-prototype-currentScript.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomDocumentprototypeimportNodeexpectedtxt">trunk/LayoutTests/fast/shadow-dom/Document-prototype-importNode-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomDocumentprototypeimportNodehtml">trunk/LayoutTests/fast/shadow-dom/Document-prototype-importNode.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomElementinterfaceattachShadowexpectedtxt">trunk/LayoutTests/fast/shadow-dom/Element-interface-attachShadow-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomElementinterfaceattachShadowhtml">trunk/LayoutTests/fast/shadow-dom/Element-interface-attachShadow.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomElementinterfaceshadowRootattributeexpectedtxt">trunk/LayoutTests/fast/shadow-dom/Element-interface-shadowRoot-attribute-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomElementinterfaceshadowRootattributehtml">trunk/LayoutTests/fast/shadow-dom/Element-interface-shadowRoot-attribute.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomExtensionstoEventInterfaceexpectedtxt">trunk/LayoutTests/fast/shadow-dom/Extensions-to-Event-Interface-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomExtensionstoEventInterfacehtml">trunk/LayoutTests/fast/shadow-dom/Extensions-to-Event-Interface.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomHTMLSlotElementinterfaceexpectedtxt">trunk/LayoutTests/fast/shadow-dom/HTMLSlotElement-interface-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomHTMLSlotElementinterfacehtml">trunk/LayoutTests/fast/shadow-dom/HTMLSlotElement-interface.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomMouseEventprototypeoffsetXoffsetYexpectedtxt">trunk/LayoutTests/fast/shadow-dom/MouseEvent-prototype-offsetX-offsetY-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomMouseEventprototypeoffsetXoffsetYhtml">trunk/LayoutTests/fast/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomNodeprototypecloneNodeexpectedtxt">trunk/LayoutTests/fast/shadow-dom/Node-prototype-cloneNode-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomNodeprototypecloneNodehtml">trunk/LayoutTests/fast/shadow-dom/Node-prototype-cloneNode.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomShadowRootinterfaceexpectedtxt">trunk/LayoutTests/fast/shadow-dom/ShadowRoot-interface-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomShadowRootinterfacehtml">trunk/LayoutTests/fast/shadow-dom/ShadowRoot-interface.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomSlotableinterfaceassignedSlotexpectedtxt">trunk/LayoutTests/fast/shadow-dom/Slotable-interface-assignedSlot-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomSlotableinterfaceassignedSlothtml">trunk/LayoutTests/fast/shadow-dom/Slotable-interface-assignedSlot.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomeventinsideshadowtreeexpectedtxt">trunk/LayoutTests/fast/shadow-dom/event-inside-shadow-tree-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomeventinsideshadowtreehtml">trunk/LayoutTests/fast/shadow-dom/event-inside-shadow-tree.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomeventinsideslottednodeexpectedtxt">trunk/LayoutTests/fast/shadow-dom/event-inside-slotted-node-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomeventinsideslottednodehtml">trunk/LayoutTests/fast/shadow-dom/event-inside-slotted-node.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomeventwithrelatedtargetexpectedtxt">trunk/LayoutTests/fast/shadow-dom/event-with-related-target-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomeventwithrelatedtargethtml">trunk/LayoutTests/fast/shadow-dom/event-with-related-target.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomresourcesDocumentprototypecurrentScripthelperjs">trunk/LayoutTests/fast/shadow-dom/resources/Document-prototype-currentScript-helper.js</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomslotchangeeventexpectedtxt">trunk/LayoutTests/fast/shadow-dom/slotchange-event-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomslotchangeeventhtml">trunk/LayoutTests/fast/shadow-dom/slotchange-event.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/ChangeLog        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-09-27  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Import w3c shadow DOM tests and fix one assertion
+        https://bugs.webkit.org/show_bug.cgi?id=162629
+
+        Reviewed by Chris Dumez.
+
+        Deleted the duplicated copies of tests in fast/shadow/ since this patch re-imports them via web-platform-tests.
+
+        * fast/shadow-dom/Element-interface-attachShadow-expected.txt: Removed.
+        * fast/shadow-dom/Node-prototype-cloneNode-expected.txt: Removed.
+
</ins><span class="cx"> 2016-09-27  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Marking imported/w3c/web-platform-tests/media-source/mediasource-liveseekable.html as flaky on mac.
</span></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomDocumentprototypeadoptNodeexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/Document-prototype-adoptNode-expected.txt (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Document-prototype-adoptNode-expected.txt        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/Document-prototype-adoptNode-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,4 +0,0 @@
</span><del>-
-PASS adoptNode on a shadow root in open mode must throw a HierarchyRequestError 
-PASS adoptNode on a shadow root in closed mode must throw a HierarchyRequestError 
-
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomDocumentprototypeadoptNodehtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/Document-prototype-adoptNode.html (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Document-prototype-adoptNode.html        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/Document-prototype-adoptNode.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,32 +0,0 @@
</span><del>-&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
-&lt;title&gt;DOM and Shadow DOM: Document.prototype.adoptNode&lt;/title&gt;
-&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
-&lt;meta name=&quot;assert&quot; content=&quot;The adoptNode(node) method must throw a HierarchyRequestError exception if node is a shadow root.&quot;&gt;
-&lt;link rel=&quot;help&quot; href=&quot;https://dom.spec.whatwg.org/#dom-document-adoptnode&quot;&gt;
-&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
-&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
-&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
-&lt;/head&gt;
-&lt;body&gt;
-&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
-&lt;script&gt;
-
-function testAdoptNode(mode) {
-    test(function () {
-        var newDocument = document.implementation.createHTMLDocument();
-        assert_throws({'name': 'HierarchyRequestError'}, function () {
-            var element = document.createElement('div');
-            var shadowRoot = element.attachShadow({mode: mode});
-            newDocument.adoptNode(shadowRoot);
-        });
-    }, 'adoptNode on a shadow root in ' + mode + ' mode must throw a HierarchyRequestError');
-}
-
-testAdoptNode('open');
-testAdoptNode('closed');
-
-&lt;/script&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomDocumentprototypecurrentScriptexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/Document-prototype-currentScript-expected.txt (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Document-prototype-currentScript-expected.txt        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/Document-prototype-currentScript-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,10 +0,0 @@
</span><del>-
-PASS document.currentScript must not to be set to a script element in a shadow tree in open mode 
-PASS document.currentScript must not to be set to a script element in a shadow tree in closed mode 
-PASS document.currentScript must be set to a script element that loads an external script in a document tree 
-PASS document.currentScript must be set to a script element that loads an external script in a document tree 
-PASS document.currentScript must not be set to a script element that loads an external script in an open shadow tree 
-PASS document.currentScript must not be set to a script element that loads an external script in a closed shadow tree 
-PASS document.currentScript must be set to a script element that loads an external script that was in an open shadow tree and then removed 
-PASS document.currentScript must be set to a script element that loads an external script that was in a closed shadow tree and then removed 
-
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomDocumentprototypecurrentScripthtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/Document-prototype-currentScript.html (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Document-prototype-currentScript.html        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/Document-prototype-currentScript.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,100 +0,0 @@
</span><del>-&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
-&lt;title&gt;DOM and Shadow DOM: Document.prototype.adoptNode&lt;/title&gt;
-&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
-&lt;meta name=&quot;assert&quot; content=&quot;If the script element is in a document, then set the script element's node document's currentScript attribute to the script element.&quot;&gt;
-&lt;link rel=&quot;help&quot; href=&quot;https://html.spec.whatwg.org/multipage/scripting.html#execute-the-script-block&quot;&gt;
-&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
-&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
-&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
-&lt;/head&gt;
-&lt;body&gt;
-&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
-&lt;script id=&quot;outerScriptElement&quot;&gt;
-
-var outerScriptElement = document.currentScript;
-
-function testInlineScript(mode)
-{
-    test(function () {
-        var host = document.createElement('div');
-        var shadowRoot = host.attachShadow({mode: mode});
-        var scriptElement = document.createElement('script');
-        scriptElement.textContent = 'assert_equals(document.currentScript, outerScriptElement)';
-        shadowRoot.appendChild(scriptElement);
-
-        assert_equals(document.currentScript, outerScriptElement,
-            'document.currentScript must be set to the currently excusing script element in a document tree before executing a script in a shadow tree');
-        document.body.appendChild(host);
-        assert_equals(document.currentScript, outerScriptElement,
-            'document.currentScript must be set to the currently excusing script element in a document tree after executing a script in a shadow tree');
-
-    }, 'document.currentScript must not to be set to a script element in a shadow tree in ' + mode + ' mode');
-}
-
-testInlineScript('open');
-testInlineScript('closed');
-
-var executeExternalScript = null;
-var testedScriptElement = null;
-function executeNextTest()
-{
-    var testCase = asyncScriptTests.shift();
-    var mode = testCase.mode;
-    var remove = testCase.mode;
-    if (!testCase)
-        return;
-
-    testCase.test.step(function () {
-        testedScriptElement = document.createElement('script');
-        testedScriptElement.src = 'resources/Document-prototype-currentScript-helper.js';
-
-        if (mode !== null) {
-            var host = document.createElement('div');
-            var shadowRoot = host.attachShadow({mode: mode});
-            shadowRoot.appendChild(testedScriptElement);
-            document.body.appendChild(host);
-        } else {
-            document.body.appendChild(testedScriptElement);
-        }
-
-        if (testCase.remove)
-            testedScriptElement.parentNode.removeChild(testedScriptElement);
-    });
-
-    executeExternalScript = function () {
-        testCase.test.step(function () {
-            assert_equals(document.currentScript, testCase.expected());
-        });
-        testCase.test.done();
-        setTimeout(executeNextTest, 1);
-    }
-}
-
-var asyncScriptTests = [
-    {
-        test: async_test('document.currentScript must be set to a script element that loads an external script in a document tree'),
-        mode: null, remove: false, expected: function () { return testedScriptElement; }},
-    {
-        test: async_test('document.currentScript must be set to a script element that loads an external script in a document tree'),
-        mode: null, remove: true, expected: function () { return testedScriptElement; }},
-    {
-        test: async_test('document.currentScript must not be set to a script element that loads an external script in an open shadow tree'),
-        mode: 'open', remove: false, expected: function () { return null; }},
-    {
-        test: async_test('document.currentScript must not be set to a script element that loads an external script in a closed shadow tree'),
-        mode: 'closed', remove: false, expected: function () { return null; }},
-    {
-        test: async_test('document.currentScript must be set to a script element that loads an external script that was in an open shadow tree and then removed'),
-        mode: 'open', remove: true, expected: function () { return testedScriptElement; }},
-    {
-        test: async_test('document.currentScript must be set to a script element that loads an external script that was in a closed shadow tree and then removed'),
-        mode: 'closed', remove: true, expected: function () { return testedScriptElement; }},
-];
-
-executeNextTest();
-
-&lt;/script&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomDocumentprototypeimportNodeexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/Document-prototype-importNode-expected.txt (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Document-prototype-importNode-expected.txt        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/Document-prototype-importNode-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,4 +0,0 @@
</span><del>-
-PASS importNode on a shadow root in open mode must throw a NotSupportedError 
-PASS importNode on a shadow root in closed mode must throw a NotSupportedError 
-
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomDocumentprototypeimportNodehtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/Document-prototype-importNode.html (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Document-prototype-importNode.html        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/Document-prototype-importNode.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,32 +0,0 @@
</span><del>-&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
-&lt;title&gt;DOM and Shadow DOM: Document.prototype.importNode&lt;/title&gt;
-&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
-&lt;meta name=&quot;assert&quot; content=&quot;The importNode(node, deep) method must throw a NotSupportedError exception if node is a shadow root.&quot;&gt;
-&lt;link rel=&quot;help&quot; href=&quot;https://dom.spec.whatwg.org/#dom-document-importnode&quot;&gt;
-&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
-&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
-&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
-&lt;/head&gt;
-&lt;body&gt;
-&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
-&lt;script&gt;
-
-function testImportNode(mode) {
-    test(function () {
-        var newDocument = document.implementation.createHTMLDocument();
-        assert_throws({'name': 'NotSupportedError'}, function () {
-            var element = document.createElement('div');
-            var shadowRoot = element.attachShadow({mode: mode});
-            newDocument.importNode(shadowRoot);
-        });
-    }, 'importNode on a shadow root in ' + mode + ' mode must throw a NotSupportedError');
-}
-
-testImportNode('open');
-testImportNode('closed');
-
-&lt;/script&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomElementinterfaceattachShadowexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/Element-interface-attachShadow-expected.txt (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Element-interface-attachShadow-expected.txt        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/Element-interface-attachShadow-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,11 +0,0 @@
</span><del>-
-PASS Check the existence of Element.attachShadow 
-PASS Nodes other than Element should not have attachShadow 
-PASS Element.attachShadow must throw a TypeError if mode is not &quot;open&quot; or &quot;closed&quot; 
-PASS Element.attachShadow must create an instance of ShadowRoot 
-PASS Element.attachShadow must throw a InvalidStateError if the context object already hosts a shadow tree 
-PASS Element.attachShadow must throw a NotSupportedError on HTML elements whose local name is not one of article, aside, blockquote, body, div, footer, h1, h2, h3, h4, h5, h6, header, nav, p, section, span 
-PASS Element.attachShadow must not throw a NotSupportedError on article, aside, blockquote, body, div, footer, h1, h2, h3, h4, h5, h6, header, nav, p, section, span 
-PASS Element.attachShadow must throw a NotSupportedError on a HTMLKnownElement which does not have a valid custom element 
-PASS Element.attachShadow must throw a NotSupportedError on a HTMLKnownElement which has a valid custom element 
-
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomElementinterfaceattachShadowhtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/Element-interface-attachShadow.html (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Element-interface-attachShadow.html        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/Element-interface-attachShadow.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,139 +0,0 @@
</span><del>-&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
-&lt;title&gt;Shadow DOM: Attaching a ShadowRoot&lt;/title&gt;
-&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
-&lt;meta name=&quot;assert&quot; content=&quot;Element.prototype.attachShadow should create an instance of ShadowRoot&quot;&gt;
-&lt;link rel=&quot;help&quot; href=&quot;https://w3c.github.io/webcomponents/spec/shadow/#widl-Element-attachShadow-ShadowRoot-ShadowRootInit-shadowRootInitDict&quot;&gt;
-&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
-&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
-&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
-&lt;/head&gt;
-&lt;body&gt;
-&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
-&lt;script&gt;
-
-test(function () {
-    assert_true('attachShadow' in Element.prototype, 'Element.prototype.attachShadow must exist');
-    assert_equals(typeof(document.createElement('div').attachShadow), 'function', 'An instance of div must have attachShadow which is a function');
-}, 'Check the existence of Element.attachShadow');
-
-test(function () {
-    assert_false('attachShadow' in Node.prototype, 'Node.prototype.attachShadow must not exist');
-    assert_false('attachShadow' in CharacterData.prototype, 'CharacterData.prototype.attachShadow must not exist');
-    assert_false('attachShadow' in Comment.prototype, 'Comment.prototype.attachShadow must not exist');
-    assert_equals(typeof(document.createComment('').attachShadow), 'undefined', 'An instance of comment must not have attachShadow');
-    assert_false('attachShadow' in Document.prototype, 'Document.prototype.attachShadow must not exist');
-    assert_equals(typeof(document.attachShadow), 'undefined', 'An instance of document must not have attachShadow which is a function');
-    assert_false('attachShadow' in DocumentFragment.prototype, 'DocumentFragment.prototype.attachShadow must not exist');
-    assert_equals(typeof((new DOMParser()).parseFromString('', 'text/html').attachShadow), 'undefined', 'An instance of document must not have attachShadow which is a function');
-    assert_false('attachShadow' in Text.prototype, 'Text.prototype.attachShadow must not exist');
-    assert_equals(typeof(document.createTextNode('').attachShadow), 'undefined', 'An instance of text node must not have attachShadow');
-}, 'Nodes other than Element should not have attachShadow');
-
-test(function () {
-    assert_throws({'name': 'TypeError'}, function () {
-        document.createElement('div').attachShadow({})
-    }, 'attachShadow must throw a TypeError when mode is omitted');
-
-    assert_throws({'name': 'TypeError'}, function () {
-        document.createElement('div').attachShadow({mode: true})
-    }, 'attachShadow must throw a TypeError when mode is a boolean');
-
-    assert_throws({'name': 'TypeError'}, function () {
-        document.createElement('div').attachShadow({mode: 1})
-    }, 'attachShadow must throw a TypeError when mode is 1');
-}, 'Element.attachShadow must throw a TypeError if mode is not &quot;open&quot; or &quot;closed&quot;');
-
-test(function () {
-    assert_true(document.createElement('div').attachShadow({mode: &quot;open&quot;}) instanceof ShadowRoot,
-        'attachShadow({mode: &quot;open&quot;}) should create an instance of ShadowRoot');
-    assert_true(document.createElement('div').attachShadow({mode: &quot;closed&quot;}) instanceof ShadowRoot,
-        'attachShadow({mode: &quot;closed&quot;}) should create an instance of ShadowRoot');
-}, 'Element.attachShadow must create an instance of ShadowRoot');
-
-test(function () {
-    assert_throws({'name': 'InvalidStateError'}, function () {
-        var div = document.createElement('div');
-        div.attachShadow({mode: &quot;open&quot;});
-        div.attachShadow({mode: &quot;open&quot;});
-    }, 'Calling attachShadow({mode: &quot;open&quot;}) twice on the same element must throw');
-
-    assert_throws({'name': 'InvalidStateError'}, function () {
-        var div = document.createElement('div');
-        div.attachShadow({mode: &quot;closed&quot;});
-        div.attachShadow({mode: &quot;closed&quot;});
-    }, 'Calling attachShadow({mode: &quot;closed&quot;}) twice on the same element must throw');
-
-    assert_throws({'name': 'InvalidStateError'}, function () {
-        var div = document.createElement('div');
-        div.attachShadow({mode: &quot;open&quot;});
-        div.attachShadow({mode: &quot;closed&quot;});
-    }, 'Calling attachShadow({mode: &quot;closed&quot;}) after attachShadow({mode: &quot;open&quot;}) on the same element must throw');
-
-    assert_throws({'name': 'InvalidStateError'}, function () {
-        var div = document.createElement('div');
-        div.attachShadow({mode: &quot;closed&quot;});
-        div.attachShadow({mode: &quot;open&quot;});
-    }, 'Calling attachShadow({mode: &quot;open&quot;}) after attachShadow({mode: &quot;closed&quot;}) on the same element must throw');
-}, 'Element.attachShadow must throw a InvalidStateError if the context object already hosts a shadow tree');
-
-var htmlElementNames = ['a', 'abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'b', 'base', 'basefont', 'bdi',
-    'bdo', 'bgsound', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup',
-    'command', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption',
-    'figure', 'font', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr',
-    'html', 'i', 'iframe', 'image', 'img', 'input', 'ins', 'isindex', 'kbd', 'keygen', 'label', 'layer', 'legend', 'li', 'link', 'listing',
-    'main', 'map', 'mark', 'marquee', 'menu', 'meta', 'meter', 'nav', 'nobr', 'noembed', 'noframes', 'nolayer', 'object', 'ol', 'optgroup',
-    'option', 'output', 'p', 'param', 'picture', 'plaintext', 'pre', 'progress', 'q', 'rb', 'rp', 'rt', 'rtc', 'ruby', 's', 'samp', 'script',
-    'section', 'select', 'slot', 'small', 'source', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td',
-    'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr', 'xmp', 'noscript'];
-var allowingAttachShadow = [&quot;article&quot;, &quot;aside&quot;, &quot;blockquote&quot;, &quot;body&quot;, &quot;div&quot;, &quot;footer&quot;, &quot;h1&quot;, &quot;h2&quot;, &quot;h3&quot;, &quot;h4&quot;, &quot;h5&quot;, &quot;h6&quot;, &quot;header&quot;, &quot;nav&quot;, &quot;p&quot;, &quot;section&quot;, &quot;span&quot;];
-
-test(function () {
-    for (var elementName of htmlElementNames) {
-        if (allowingAttachShadow.indexOf(elementName) &gt;= 0)
-            continue;
-
-        assert_throws({'name': 'NotSupportedError'}, function () {
-            document.createElement(elementName).attachShadow({mode: &quot;open&quot;});
-        }, 'Calling attachShadow({mode: &quot;open&quot;}) on ' + elementName + ' element must throw');
-
-        assert_throws({'name': 'NotSupportedError'}, function () {
-            document.createElement(elementName).attachShadow({mode: &quot;closed&quot;});
-        }, 'Calling attachShadow({mode: &quot;closed&quot;}) on ' + elementName + ' element must throw');
-    }
-}, 'Element.attachShadow must throw a NotSupportedError on HTML elements whose local name is not one of ' + allowingAttachShadow.join(', '));
-
-test(function () {
-    for (var elementName of allowingAttachShadow) {
-        assert_true(document.createElement(elementName).attachShadow({mode: &quot;open&quot;}) instanceof ShadowRoot,
-            'Calling attachShadow({mode: &quot;open&quot;}) on ' + elementName + ' element must not throw');
-
-        assert_true(document.createElement(elementName).attachShadow({mode: &quot;closed&quot;}) instanceof ShadowRoot,
-            'Calling attachShadow({mode: &quot;closed&quot;}) on ' + elementName + ' element must not throw');
-    }
-}, 'Element.attachShadow must not throw a NotSupportedError on ' + allowingAttachShadow.join(', '));
-
-test(function () {
-    assert_throws({'name': 'NotSupportedError'}, function () {
-        document.createElement('w3cfutureelement').attachShadow({mode: &quot;open&quot;});
-    }, 'Calling attachShadow({mode: &quot;open&quot;}) on a HTML element whose local name is &quot;w3cfutureelement&quot; must throw');
-
-    assert_throws({'name': 'NotSupportedError'}, function () {
-        document.createElement('w3cfutureelement').attachShadow({mode: &quot;closed&quot;});
-    }, 'Calling attachShadow({mode: &quot;closed&quot;}) on a HTML element whose local name is &quot;w3cfutureelement&quot; must throw');
-
-}, 'Element.attachShadow must throw a NotSupportedError on a HTMLKnownElement which does not have a valid custom element');
-
-test(function () {
-    assert_true(document.createElement('custom-element').attachShadow({mode: &quot;open&quot;}) instanceof ShadowRoot,
-        'Calling attachShadow({mode: &quot;open&quot;}) on a HTML element whose local name is &quot;custom-element&quot; element must not throw');
-
-    assert_true(document.createElement('custom-element').attachShadow({mode: &quot;closed&quot;}) instanceof ShadowRoot,
-        'Calling attachShadow({mode: &quot;closed&quot;}) on a HTML element whose local name is &quot;custom-element&quot; must not throw');
-
-}, 'Element.attachShadow must throw a NotSupportedError on a HTMLKnownElement which has a valid custom element');
-
-&lt;/script&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomElementinterfaceshadowRootattributeexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/Element-interface-shadowRoot-attribute-expected.txt (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Element-interface-shadowRoot-attribute-expected.txt        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/Element-interface-shadowRoot-attribute-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,5 +0,0 @@
</span><del>-
-PASS shadowRoot must be defined on Element prototype 
-PASS shadowRoot attribute must return the open shadow root associated with the element 
-PASS shadowRoot attribute must return null if the shadow root attached to the element is closed 
-
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomElementinterfaceshadowRootattributehtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/Element-interface-shadowRoot-attribute.html (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Element-interface-shadowRoot-attribute.html        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/Element-interface-shadowRoot-attribute.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,46 +0,0 @@
</span><del>-&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
-&lt;title&gt;Shadow DOM: Element interface shadowRoot attribute&lt;/title&gt;
-&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
-&lt;meta name=&quot;assert&quot; content=&quot;shadowRoot attribute on Element interface must return the associated open shadow tree if there is one&quot;&gt;
-&lt;link rel=&quot;help&quot; href=&quot;https://w3c.github.io/webcomponents/spec/shadow/#the-shadowroot-interface&quot;&gt;
-&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
-&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
-&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
-&lt;/head&gt;
-&lt;body&gt;
-&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
-&lt;script&gt;
-
-test(function () {
-    assert_true('shadowRoot' in Element.prototype, 'shadowRoot must be defined on Element prototype');
-    assert_true('shadowRoot' in document.createElement('div'), 'shadowRoot must be defined on an instance of div element');
-    assert_false('shadowRoot' in Node.prototype, 'shadowRoot must not be defined on Node prototype');
-    assert_false('shadowRoot' in Text.prototype, 'shadowRoot must not be defined on Text prototype');
-    assert_false('shadowRoot' in document.createTextNode(''), 'shadowRoot must not be defined on an instance of Text node');
-    assert_false('shadowRoot' in Comment.prototype, 'shadowRoot must not be defined on Comment prototype');
-    assert_false('shadowRoot' in document.createComment(''), 'shadowRoot must not be defined on an instance of Comment node');
-    assert_false('shadowRoot' in Document.prototype, 'shadowRoot must not be defined on Document prototype');
-    assert_false('shadowRoot' in document, 'shadowRoot must not be defined on an instance of Document');
-    assert_false('shadowRoot' in DocumentFragment.prototype, 'shadowRoot must not be defined on DocumentFragment prototype');
-    assert_false('shadowRoot' in (new DOMParser).parseFromString('', 'text/html'), 'shadowRoot must not be defined on an instance of DocumentFragment node');
-}, 'shadowRoot must be defined on Element prototype');
-
-test(function () {
-    var host = document.createElement('div');
-    assert_equals(host.shadowRoot, null, 'shadowRoot must return null when the host does not have a shadow tree attached to it');
-
-    var openShadowRoot = host.attachShadow({mode: 'open'});
-    assert_equals(host.shadowRoot, openShadowRoot, 'shadowRoot must return the open shadow root attachShadow attached');
-}, 'shadowRoot attribute must return the open shadow root associated with the element');
-
-test(function () {
-    var host = document.createElement('div');
-    host.attachShadow({mode: 'closed'});
-    assert_equals(host.shadowRoot, null);
-}, 'shadowRoot attribute must return null if the shadow root attached to the element is closed');
-
-&lt;/script&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomExtensionstoEventInterfaceexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/Extensions-to-Event-Interface-expected.txt (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Extensions-to-Event-Interface-expected.txt        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/Extensions-to-Event-Interface-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,20 +0,0 @@
</span><del>-
-PASS composedPath() must exist on Event 
-PASS composedPath() must return an empty array when the event has not been dispatched 
-PASS composedPath() must return an empty array when the event is no longer dispatched 
-PASS composed must exist on Event 
-PASS composed on EventInit must default to false 
-PASS composed on EventInit must set the composed flag 
-PASS The event must propagate out of open mode shadow boundaries when the composed flag is set 
-PASS The event must propagate out of closed mode shadow boundaries when the composed flag is set 
-PASS The event must not propagate out of open mode shadow boundaries when the composed flag is unset 
-PASS The event must not propagate out of closed mode shadow boundaries when the composed flag is unset 
-PASS The event must not propagate out of open mode shadow boundaries when the composed flag is unset on an event with relatedTarget 
-PASS The event must not propagate out of closed mode shadow boundaries when the composed flag is unset on an event with relatedTarget 
-PASS The event must not propagate out of open mode shadow tree of the target but must propagate out of inner shadow trees when the scoped flag is set 
-PASS The event must not propagate out of closed mode shadow tree of the target but must propagate out of inner shadow trees when the scoped flag is set 
-PASS The event must propagate out of open mode shadow tree in which the relative target and the relative related target are the same 
-PASS The event must propagate out of closed mode shadow tree in which the relative target and the relative related target are the same 
-PASS composedPath() must contain and only contain the unclosed nodes of target in open mode shadow trees 
-PASS composedPath() must contain and only contain the unclosed nodes of target in closed mode shadow trees 
-
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomExtensionstoEventInterfacehtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/Extensions-to-Event-Interface.html (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Extensions-to-Event-Interface.html        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/Extensions-to-Event-Interface.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,235 +0,0 @@
</span><del>-&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
-&lt;title&gt;Shadow DOM: Extensions to Event Interface&lt;/title&gt;
-&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
-&lt;meta name=&quot;assert&quot; content=&quot;Event interface must have composedPath() as a method&quot;&gt;
-&lt;link rel=&quot;help&quot; href=&quot;http://w3c.github.io/webcomponents/spec/shadow/#extensions-to-event-interface&quot;&gt;
-&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
-&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
-&lt;script src=&quot;resources/event-path-test-helpers.js&quot;&gt;&lt;/script&gt;
-&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
-&lt;/head&gt;
-&lt;body&gt;
-&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
-&lt;script&gt;
-
-test(function () {
-    assert_true('composedPath' in Event.prototype);
-    assert_true('composedPath' in new Event('my-event'));
-}, 'composedPath() must exist on Event');
-
-test(function () {
-    var event = new Event('my-event');
-    assert_array_equals(event.composedPath(), []);
-}, 'composedPath() must return an empty array when the event has not been dispatched');
-
-test(function () {
-    var event = new Event('my-event');
-    document.body.dispatchEvent(event);
-    assert_array_equals(event.composedPath(), []);
-}, 'composedPath() must return an empty array when the event is no longer dispatched');
-
-test(function () {
-    assert_true('composed' in Event.prototype);
-    assert_true('composed' in new Event('my-event'));
-}, 'composed must exist on Event');
-
-test(function () {
-    var event = new Event('my-event');
-    assert_false(event.composed);
-}, 'composed on EventInit must default to false');
-
-test(function () {
-    var event = new Event('my-event', {composed: true});
-    assert_true(event.composed);
-
-    event = new Event('my-event', {composed: false});
-    assert_false(event.composed);
-}, 'composed on EventInit must set the composed flag');
-
-/*
--SR: ShadowRoot  -S: Slot  target: (~)  *: indicates start  digit: event path order
-A (4) --------------------------- A-SR (3)
-+ B ------------ B-SR             + A1 (2) --- A1-SR (1)
-  + C            + B1 --- B1-SR   + A2-S       + A1a (*; 0)
-  + D --- D-SR     + B1a    + B1b --- B1b-SR
-          + D1              + B1c-S   + B1b1
-                                      + B1b2
-*/
-
-function testComposedEvent(mode) {
-    test(function () {
-        var nodes = createTestTree(mode);
-        var log = dispatchEventWithLog(nodes, nodes.A1a, new Event('my-event', {composed: true, bubbles: true}));
-
-        var expectedPath = ['A1a', 'A1-SR', 'A1', 'A-SR', 'A'];
-        assert_array_equals(log.eventPath, expectedPath);
-        assert_array_equals(log.eventPath.length, log.pathAtTargets.length);
-        assert_array_equals(log.pathAtTargets[0], expectedPath);
-        assert_array_equals(log.pathAtTargets[1], expectedPath);
-        assert_array_equals(log.pathAtTargets[2], mode == 'open' ? expectedPath : ['A1', 'A-SR', 'A'],
-            'composedPath must only contain unclosed nodes of the current target.');
-    }, 'The event must propagate out of ' + mode + ' mode shadow boundaries when the composed flag is set');
-}
-
-testComposedEvent('open');
-testComposedEvent('closed');
-
-/*
--SR: ShadowRoot  -S: Slot  target: (~)  *: indicates start  digit: event path order
-A ------------------------------- A-SR
-+ B ------------ B-SR             + A1 --- A1-SR (1)
-  + C            + B1 --- B1-SR   + A2-S   + A1a (*; 0)
-  + D --- D-SR     + B1a  + B1b --- B1b-SR
-          + D1            + B1c-S   + B1b1
-                                    + B1b2
-*/
-
-function testNonComposedEvent(mode) {
-    test(function () {
-        var nodes = createTestTree(mode);
-        var log = dispatchEventWithLog(nodes, nodes.A1a, new Event('my-event', {composed: false, bubbles: true}));
-
-        var expectedPath = ['A1a', 'A1-SR'];
-        assert_array_equals(log.eventPath, expectedPath);
-        assert_array_equals(log.eventPath.length, log.pathAtTargets.length);
-        assert_array_equals(log.pathAtTargets[0], expectedPath);
-        assert_array_equals(log.pathAtTargets[1], expectedPath);
-    }, 'The event must not propagate out of ' + mode + ' mode shadow boundaries when the composed flag is unset');
-}
-
-testNonComposedEvent('open');
-testNonComposedEvent('closed');
-
-/*
--SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
-A ------------------------------- A-SR
-+ B ------------ B-SR             + A1 ----------- A1-SR (1)
-  + C            + B1 --- B1-SR   + A2-S [*; 0-1]  + A1a (*; 0)
-  + D --- D-SR     + B1a  + B1b --- B1b-SR
-          + D1            + B1c-S   + B1b1
-                                    + B1b2
-*/
-
-function testNonComposedEventWithRelatedTarget(mode) {
-    test(function () {
-        var nodes = createTestTree(mode);
-        var log = dispatchEventWithLog(nodes, nodes.A1a, new MouseEvent('foo', {composed: false, bubbles: true, relatedTarget: nodes['A2-S']}));
-
-        var expectedPath = ['A1a', 'A1-SR'];
-        assert_array_equals(log.eventPath, expectedPath);
-        assert_array_equals(log.eventPath.length, log.pathAtTargets.length);
-        assert_array_equals(log.pathAtTargets[0], expectedPath);
-        assert_array_equals(log.pathAtTargets[1], expectedPath);
-        assert_array_equals(log.relatedTargets, ['A2-S', 'A2-S']);
-    }, 'The event must not propagate out of ' + mode + ' mode shadow boundaries when the composed flag is unset on an event with relatedTarget');
-}
-
-testNonComposedEventWithRelatedTarget('open');
-testNonComposedEventWithRelatedTarget('closed');
-
-/*
--SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
-A ------------------------------------------------ A-SR
-+ B ------------ B-SR (4)                          + A1 --- A1-SR
-  + C            + B1 (3) [0,3-4] --- B1-SR (2)    + A2-S   + A1a
-  + D --- D-SR     + B1a (*; 0)       + B1b [1-2] --- B1b-SR
-          + D1                        + B1c-S (1)     + B1b1
-                                                      + B1b2 [*]
-*/
-
-function testScopedEventWithUnscopedRelatedTargetThroughSlot(mode) {
-    test(function () {
-        var nodes = createTestTree(mode);
-        var log = dispatchEventWithLog(nodes, nodes.B1a, new MouseEvent('foo', {scoped: true, relatedTargetScoped: false, bubbles: true, relatedTarget: nodes['B1b2']}));
-
-        var expectedPath = ['B1a', 'B1c-S', 'B1-SR', 'B1', 'B-SR'];
-        var pathExposedToB1a = ['B1a', 'B1', 'B-SR'];
-        assert_array_equals(log.eventPath, expectedPath);
-        assert_array_equals(log.eventPath.length, log.pathAtTargets.length);
-        assert_array_equals(log.pathAtTargets[0], mode == 'open' ? expectedPath : pathExposedToB1a);
-        assert_array_equals(log.pathAtTargets[1], expectedPath);
-        assert_array_equals(log.pathAtTargets[2], expectedPath);
-        assert_array_equals(log.pathAtTargets[3], mode == 'open' ? expectedPath : pathExposedToB1a);
-        assert_array_equals(log.pathAtTargets[4], mode == 'open' ? expectedPath : pathExposedToB1a);
-        assert_array_equals(log.relatedTargets, ['B1', 'B1b', 'B1b', 'B1', 'B1']);
-    }, 'The event must not propagate out of ' + mode + ' mode shadow tree of the target but must propagate out of inner shadow trees when the scoped flag is set');
-}
-
-testScopedEventWithUnscopedRelatedTargetThroughSlot('open');
-testScopedEventWithUnscopedRelatedTargetThroughSlot('closed');
-
-/*
--SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
-A ------------------------------- A-SR (3)
-+ B ------------ B-SR             + A1 (2) ------- A1-SR (1)
-  + C            + B1 --- B1-SR   + A2-S [*; 0-3]  + A1a (*; 0)
-  + D --- D-SR     + B1a  + B1b --- B1b-SR
-          + D1            + B1c-S   + B1b1
-                                    + B1b2
-*/
-
-function testComposedEventWithRelatedTarget(mode) {
-    test(function () {
-        var nodes = createTestTree(mode);
-        log = dispatchEventWithLog(nodes, nodes.A1a, new MouseEvent('foo', {composed: true, bubbles: true, relatedTarget: nodes['A2-S']}));
-
-        var expectedPath = ['A1a', 'A1-SR', 'A1', 'A-SR'];
-        var pathExposedToA1 = ['A1', 'A-SR'];
-        assert_array_equals(log.eventPath, expectedPath);
-        assert_array_equals(log.eventPath.length, log.pathAtTargets.length);
-        assert_array_equals(log.pathAtTargets[0], expectedPath);
-        assert_array_equals(log.pathAtTargets[1], expectedPath);
-        assert_array_equals(log.pathAtTargets[2], mode == 'open' ? expectedPath : pathExposedToA1);
-        assert_array_equals(log.pathAtTargets[3], mode == 'open' ? expectedPath : pathExposedToA1);
-        assert_array_equals(log.relatedTargets, ['A2-S', 'A2-S', 'A2-S', 'A2-S']);
-    }, 'The event must propagate out of ' + mode + ' mode shadow tree in which the relative target and the relative related target are the same');
-}
-
-testComposedEventWithRelatedTarget('open');
-testComposedEventWithRelatedTarget('closed');
-
-/*
--SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
-A (8) [0-5,8] ---------------------------------------- A-SR (7)
-+ B (5)  ------- B-SR (4)                              + A1 [6,7] --- A1-SR
-  + C            + B1 (3) ------- B1-SR (2)            + A2-S (6)     + A1a [*]
-  + D --- D-SR     + B1a (*; 0)   + B1b ------- B1b-SR
-          + D1                    + B1c-S (1)   + B1b1
-                                                + B1b2
-*/
-
-function testComposedEventThroughSlot(mode) {
-    test(function () {
-        var nodes = createTestTree(mode);
-        log = dispatchEventWithLog(nodes, nodes.B1a, new MouseEvent('foo', {composed: true, bubbles: true, relatedTarget: nodes.A1a}));
-
-        var expectedPath =          ['B1a', 'B1c-S', 'B1-SR', 'B1', 'B-SR', 'B', 'A2-S', 'A-SR', 'A'];
-        var expectedRelatedTarget = ['A',   'A',     'A',     'A',   'A',   'A', 'A1',   'A1',   'A'];
-        var pathExposedToB1a =      ['B1a',                   'B1', 'B-SR', 'B',                 'A'];
-        var pathExposedToB1cS =     ['B1a', 'B1c-S', 'B1-SR', 'B1', 'B-SR', 'B',                 'A'];
-        var pathExposedToB =        [                                       'B',                 'A'];
-        var pathExposedToA1 =       [                                       'B', 'A2-S', 'A-SR', 'A'];
-
-        assert_array_equals(log.eventPath, expectedPath);
-        assert_array_equals(log.eventPath.length, log.pathAtTargets.length);
-        assert_array_equals(log.pathAtTargets[0], mode == 'open' ? expectedPath : pathExposedToB1a);
-        assert_array_equals(log.pathAtTargets[1], mode == 'open' ? expectedPath : pathExposedToB1cS);
-        assert_array_equals(log.pathAtTargets[2], mode == 'open' ? expectedPath : pathExposedToB1cS);
-        assert_array_equals(log.pathAtTargets[3], mode == 'open' ? expectedPath : pathExposedToB1a);
-        assert_array_equals(log.pathAtTargets[4], mode == 'open' ? expectedPath : pathExposedToB1a);
-        assert_array_equals(log.pathAtTargets[5], mode == 'open' ? expectedPath : pathExposedToB);
-        assert_array_equals(log.pathAtTargets[6], mode == 'open' ? expectedPath : pathExposedToA1);
-        assert_array_equals(log.pathAtTargets[7], mode == 'open' ? expectedPath : pathExposedToA1);
-        assert_array_equals(log.pathAtTargets[8], mode == 'open' ? expectedPath : pathExposedToB);
-        assert_array_equals(log.relatedTargets, expectedRelatedTarget);
-    }, 'composedPath() must contain and only contain the unclosed nodes of target in ' + mode + ' mode shadow trees');
-}
-
-testComposedEventThroughSlot('open');
-testComposedEventThroughSlot('closed');
-
-&lt;/script&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomHTMLSlotElementinterfaceexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/HTMLSlotElement-interface-expected.txt (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/HTMLSlotElement-interface-expected.txt        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/HTMLSlotElement-interface-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,20 +0,0 @@
</span><del>-
-PASS HTMLSlotElement must be defined on window 
-PASS &quot;name&quot; attribute on HTMLSlotElement must reflect &quot;name&quot; attribute 
-PASS assignedNodes() on a HTMLSlotElement must return an empty array when the slot element is not in a tree or in a document tree 
-PASS assignedNodes({&quot;flattened&quot;:false}) on a HTMLSlotElement must return an empty array when the slot element is not in a tree or in a document tree 
-PASS assignedNodes({&quot;flattened&quot;:true}) on a HTMLSlotElement must return an empty array when the slot element is not in a tree or in a document tree 
-PASS assignedNodes() must return the list of assigned nodes when none of the assigned nodes themselves are slots 
-PASS assignedNodes({&quot;flattened&quot;:false}) must return the list of assigned nodes when none of the assigned nodes themselves are slots 
-PASS assignedNodes({&quot;flattened&quot;:true}) must return the list of assigned nodes when none of the assigned nodes themselves are slots 
-PASS assignedNodes() must update when slot and name attributes are modified 
-PASS assignedNodes({&quot;flattened&quot;:false}) must update when slot and name attributes are modified 
-PASS assignedNodes({&quot;flattened&quot;:true}) must update when slot and name attributes are modified 
-PASS assignedNodes must update when a default slot is introduced dynamically by a slot rename 
-PASS assignedNodes({&quot;flattened&quot;:false}) must update when slot and name attributes are modified 
-PASS assignedNodes({&quot;flattened&quot;:true}) must update when slot and name attributes are modified 
-PASS assignedNodes must update when slot elements are inserted or removed 
-PASS assignedNodes must update when slot elements are inserted or removed 
-PASS assignedNodes must update when slot elements are inserted or removed 
-PASS assignedNodes({flatten: true}) must return the distributed nodes, and assignedNodes() and assignedNodes({flatten: false}) must returned the assigned nodes 
-
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomHTMLSlotElementinterfacehtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/HTMLSlotElement-interface.html (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/HTMLSlotElement-interface.html        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/HTMLSlotElement-interface.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,270 +0,0 @@
</span><del>-&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
-&lt;title&gt;Shadow DOM: HTMLSlotElement interface&lt;/title&gt;
-&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
-&lt;meta name=&quot;assert&quot; content=&quot;HTMLSlotElement must exist on window with name attribute and getAssignedNode() method&quot;&gt;
-&lt;link rel=&quot;help&quot; href=&quot;https://w3c.github.io/webcomponents/spec/shadow/#the-slot-element&quot;&gt;
-&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
-&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
-&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
-&lt;/head&gt;
-&lt;body&gt;
-&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
-&lt;script&gt;
-
-test(function () {
-    assert_true('HTMLSlotElement' in window, 'HTMLSlotElement must be defined on window');
-    assert_equals(HTMLSlotElement.prototype.__proto__, HTMLElement.prototype, 'HTMLSlotElement should inherit from HTMLElement');
-    assert_true(document.createElement('slot') instanceof HTMLSlotElement, 'slot element should be an instance of HTMLSlotElement');
-    assert_true(document.createElement('slot') instanceof HTMLElement, 'slot element should be an instance of HTMLElement');
-}, 'HTMLSlotElement must be defined on window');
-
-test(function () {
-    assert_true('name' in HTMLSlotElement.prototype, '&quot;name&quot; attribute must be defined on HTMLSlotElement.prototype');
-
-    var slotElement = document.createElement('slot');
-    assert_equals(slotElement.name, '', '&quot;name&quot; attribute must return the empty string when &quot;name&quot; content attribute is not set');
-
-    slotElement.setAttribute('name', 'foo');
-    assert_equals(slotElement.name, 'foo', '&quot;name&quot; attribute must return the value of the &quot;name&quot; content attribute');
-
-    slotElement.name = 'bar';
-    assert_equals(slotElement.name, 'bar', '&quot;name&quot; attribute must return the assigned value');
-    assert_equals(slotElement.getAttribute('name'), 'bar', '&quot;name&quot; attribute must update the &quot;name&quot; content attribute');
-}, '&quot;name&quot; attribute on HTMLSlotElement must reflect &quot;name&quot; attribute');
-
-function testSlotOutsideShadowTree(options)
-{
-    test(function () {
-        assert_true('assignedNodes' in HTMLSlotElement.prototype, '&quot;assignedNodes&quot; method must be defined on HTMLSlotElement.prototype');
-
-        var slotElement = document.createElement('slot');
-        assert_array_equals(slotElement.assignedNodes(options), [], 'assignedNodes() must return an empty array when the slot element is not in any tree');
-
-        document.body.appendChild(slotElement);
-        assert_array_equals(slotElement.assignedNodes(options), [], 'assignedNodes() must return an empty array when the slot element is in a document tree');
-
-    }, 'assignedNodes(' + (options ? JSON.stringify(options) : '')
-        + ') on a HTMLSlotElement must return an empty array when the slot element is not in a tree or in a document tree');
-}
-
-testSlotOutsideShadowTree(null);
-testSlotOutsideShadowTree({flattened: false});
-testSlotOutsideShadowTree({flattened: true});
-
-function testSingleLevelOfSlotting(options)
-{
-    test(function () {
-        assert_true('assignedNodes' in HTMLSlotElement.prototype, '&quot;assignedNodes&quot; method must be defined on HTMLSlotElement.prototype');
-
-        var shadowHost = document.createElement('div');
-        var child = document.createElement('p');
-
-        var shadowRoot = shadowHost.attachShadow({mode: 'open'});
-        var slotElement = document.createElement('slot');
-        shadowRoot.appendChild(slotElement);
-
-        assert_array_equals(slotElement.assignedNodes(options), [], 'assignedNodes() must return an empty array when there are no nodes in the shadow tree');
-
-        shadowHost.appendChild(child);
-        assert_array_equals(slotElement.assignedNodes(options), [child], 'assignedNodes() on a default slot must return an element without slot element');
-
-        child.setAttribute('slot', 'foo');
-        assert_array_equals(slotElement.assignedNodes(options), [], 'assignedNodes() on a default slot must not return an element with non-empty slot attribute');
-
-        child.setAttribute('slot', '');
-        assert_array_equals(slotElement.assignedNodes(options), [child], 'assignedNodes() on a default slot must return an element with empty slot attribute');
-
-        slotElement.setAttribute('name', 'bar');
-        assert_array_equals(slotElement.assignedNodes(options), [], 'assignedNodes() on a named slot must not return an element with empty slot attribute');
-
-        slotElement.setAttribute('name', '');
-        assert_array_equals(slotElement.assignedNodes(options), [child], 'assignedNodes() on an empty name slot must return an element with empty slot attribute');
-
-    }, 'assignedNodes(' + (options ? JSON.stringify(options) : '') + ') must return the list of assigned nodes when none of the assigned nodes themselves are slots');
-}
-
-testSingleLevelOfSlotting(null);
-testSingleLevelOfSlotting({flattened: false});
-testSingleLevelOfSlotting({flattened: true});
-
-function testMutatingSlottedContents(options)
-{
-    test(function () {
-        var shadowHost = document.createElement('div');
-        var p = document.createElement('p');
-        var b = document.createElement('b');
-        shadowHost.appendChild(p);
-        shadowHost.appendChild(b);
-
-        var shadowRoot = shadowHost.attachShadow({mode: 'open'});
-        var slotElement = document.createElement('slot');
-        shadowRoot.appendChild(slotElement);
-
-        assert_array_equals(slotElement.assignedNodes(options), [p, b], 'assignedNodes must return the distributed nodes');
-
-        slotElement.name = 'foo';
-        assert_array_equals(slotElement.assignedNodes(options), [], 'assignedNodes must be empty when there are no matching elements for the slot name');
-
-        b.slot = 'foo';
-        assert_array_equals(slotElement.assignedNodes(options), [b], 'assignedNodes must return the nodes with the matching slot name');
-
-        p.slot = 'foo';
-        assert_array_equals(slotElement.assignedNodes(options), [p, b], 'assignedNodes must return the nodes with the matching slot name in the tree order');
-
-        slotElement.removeAttribute('name');
-        assert_array_equals(slotElement.assignedNodes(options), [], 'assignedNodes must be empty for a default slot when all elements have &quot;slot&quot; attributes specified');
-
-    }, 'assignedNodes(' + (options ? JSON.stringify(options) : '') + ') must update when slot and name attributes are modified');
-}
-
-testMutatingSlottedContents(null);
-testMutatingSlottedContents({flattened: false});
-testMutatingSlottedContents({flattened: true});
-
-function testMutatingSlotName(options)
-{
-    test(function () {
-        var shadowHost = document.createElement('div');
-        var child = document.createElement('span');
-        shadowHost.appendChild(child);
-
-        var shadowRoot = shadowHost.attachShadow({mode: 'open'});
-        var slotElement = document.createElement('slot');
-        slotElement.name = 'foo';
-        shadowRoot.appendChild(slotElement);
-
-        assert_array_equals(slotElement.assignedNodes(options), [], 'assignedNodes must be empty when there are no matching elements for the slot name');
-
-        slotElement.removeAttribute('name');
-        assert_array_equals(slotElement.assignedNodes(options), [child], 'assignedNodes must be empty when there are no matching elements for the slot name');
-
-    }, 'assignedNodes must update when a default slot is introduced dynamically by a slot rename');
-}
-
-testMutatingSlotName(null);
-testMutatingSlottedContents({flattened: false});
-testMutatingSlottedContents({flattened: true});
-
-function testInsertingAndRemovingSlots(options)
-{
-    test(function () {
-        var shadowHost = document.createElement('div');
-        var p = document.createElement('p');
-        var text = document.createTextNode('');
-        var comment = document.createComment('');
-        var processingInstruction = document.createProcessingInstruction('target', 'data');
-        var b = document.createElement('b');
-        shadowHost.appendChild(p);
-        shadowHost.appendChild(text);
-        shadowHost.appendChild(comment);
-        shadowHost.appendChild(processingInstruction);
-        shadowHost.appendChild(b);
-
-        var shadowRoot = shadowHost.attachShadow({mode: 'open'});
-
-        var firstSlotElement = document.createElement('slot');
-        shadowRoot.appendChild(firstSlotElement);
-
-        var secondSlotElement = document.createElement('slot');
-        shadowRoot.appendChild(secondSlotElement);
-
-        assert_array_equals(firstSlotElement.assignedNodes(options), [p, text, b],
-            'assignedNodes on a default slot must return the elements without slot attributes and text nodes');
-        assert_array_equals(secondSlotElement.assignedNodes(options), [],
-            'assignedNodes on the second unnamed slot element must return an empty array');
-
-        shadowRoot.removeChild(firstSlotElement);
-        assert_array_equals(firstSlotElement.assignedNodes(options), [],
-            'assignedNodes on a detached formerly-default slot must return an empty array');
-        assert_array_equals(secondSlotElement.assignedNodes(options), [p, text, b],
-            'assignedNodes on the second unnamed slot element after removing the first must return the elements without slot attributes and text nodes');
-
-        shadowRoot.removeChild(secondSlotElement);
-        shadowRoot.appendChild(secondSlotElement);
-        assert_array_equals(firstSlotElement.assignedNodes(options), [],
-            'Removing and re-inserting a default slot must not change the result of assignedNodes on a detached slot');
-        assert_array_equals(secondSlotElement.assignedNodes(options), [p, text, b],
-            'Removing and re-inserting a default slot must not change the result of assignedNodes');
-
-        shadowRoot.insertBefore(firstSlotElement, secondSlotElement);
-        assert_array_equals(firstSlotElement.assignedNodes(options), [p, text, b],
-            'assignedNodes on a newly inserted unnamed slot element must return the elements without slot attributes and text nodes');
-        assert_array_equals(secondSlotElement.assignedNodes(options), [],
-            'assignedNodes on formerly-first but now second unnamed slot element must return an empty array');
-
-    }, 'assignedNodes must update when slot elements are inserted or removed');
-}
-
-testInsertingAndRemovingSlots(null);
-testInsertingAndRemovingSlots({flattened: false});
-testInsertingAndRemovingSlots({flattened: true});
-
-test(function () {
-    var outerHost = document.createElement('div');
-    var outerChild = document.createElement('span');
-    outerHost.appendChild(outerChild);
-
-    var outerShadow = outerHost.attachShadow({mode: 'closed'});
-    var innerHost = document.createElement('div');
-    var outerSlot = document.createElement('slot');
-    var innerChild = document.createElement('b');
-    outerShadow.appendChild(innerHost);
-    innerHost.appendChild(outerSlot);
-    innerHost.appendChild(innerChild);
-
-    var innerShadow = innerHost.attachShadow({mode: 'closed'});
-    var innerSlot = document.createElement('slot');
-    innerShadow.appendChild(innerSlot);
-
-    assert_array_equals(outerSlot.assignedNodes(), [outerChild], 'assignedNodes() on a default slot must return the assigned nodes');
-    assert_array_equals(outerSlot.assignedNodes({flatten: false}), [outerChild], 'assignedNodes({flatten: false}) on a default slot must return the assigned nodes');
-    assert_array_equals(outerSlot.assignedNodes({flatten: true}), [outerChild], 'assignedNodes({flatten: true}) on a default slot must return the assigned nodes if they are not themselves slots');
-
-    assert_array_equals(innerSlot.assignedNodes(), [outerSlot, innerChild], 'assignedNodes() on a default slot must return the assigned nodes');
-    assert_array_equals(innerSlot.assignedNodes({flatten: false}), [outerSlot, innerChild], 'assignedNodes({flatten: false}) on a default slot must return the assigned nodes');
-    assert_array_equals(innerSlot.assignedNodes({flatten: true}), [outerChild, innerChild], 'assignedNodes({flatten: true}) on a default slot must return the distributed nodes');
-
-    outerSlot.name = 'foo';
-    assert_array_equals(outerSlot.assignedNodes(), [], 'assignedNodes() on a named slot must return an empty array if there are no matching elements');
-    assert_array_equals(outerSlot.assignedNodes({flatten: false}), [], 'assignedNodes({flatten: false}) on a named slot must return an empty array if there are no matching elements');
-    assert_array_equals(outerSlot.assignedNodes({flatten: true}), [], 'assignedNodes({flatten: true}) on a named slot must return an empty array if there are no matching elements');
-
-    assert_array_equals(innerSlot.assignedNodes(), [outerSlot, innerChild], 'assignedNodes() on a default slot must return the assigned nodes');
-    assert_array_equals(innerSlot.assignedNodes({flatten: false}), [outerSlot, innerChild], 'assignedNodes({flatten: false}) on a default slot must return the assigned nodes');
-    assert_array_equals(innerSlot.assignedNodes({flatten: true}), [innerChild], 'assignedNodes({flatten: true}) on a default slot must return the distributed nodes');
-
-    outerChild.slot = 'foo';
-    assert_array_equals(outerSlot.assignedNodes(), [outerChild], 'assignedNodes() on a named slot must return matching elements');
-    assert_array_equals(outerSlot.assignedNodes({flatten: false}), [outerChild], 'assignedNodes({flatten: false}) on a named slot must return matching elements');
-    assert_array_equals(outerSlot.assignedNodes({flatten: true}), [outerChild], 'assignedNodes({flatten: true}) on a named slot must return matching elements');
-
-    assert_array_equals(innerSlot.assignedNodes(), [outerSlot, innerChild], 'assignedNodes() on a default slot must return the assigned nodes');
-    assert_array_equals(innerSlot.assignedNodes({flatten: false}), [outerSlot, innerChild], 'assignedNodes({flatten: false}) on a default slot must return the assigned nodes');
-    assert_array_equals(innerSlot.assignedNodes({flatten: true}), [outerChild, innerChild], 'assignedNodes({flatten: true}) on a default slot must return the distributed nodes');
-
-    var newInnerSlot = document.createElement('slot');
-    innerShadow.insertBefore(newInnerSlot, innerSlot);
-    assert_array_equals(newInnerSlot.assignedNodes(), [outerSlot, innerChild], 'assignedNodes() on a default slot must return the assigned nodes');
-    assert_array_equals(newInnerSlot.assignedNodes({flatten: false}), [outerSlot, innerChild], 'assignedNodes({flatten: false}) on a default slot must return the assigned nodes');
-    assert_array_equals(newInnerSlot.assignedNodes({flatten: true}), [outerChild, innerChild], 'assignedNodes({flatten: true}) on a default slot must return the distributed nodes');
-
-    assert_array_equals(innerSlot.assignedNodes(), [], 'assignedNodes() on a nameless slot element which appears after a default slot must return an empty array');
-    assert_array_equals(innerSlot.assignedNodes({flatten: false}), [], 'assignedNodes({flatten: false}) on a nameless slot element which appears after a default slot must return an empty array');
-    assert_array_equals(innerSlot.assignedNodes({flatten: true}), [], 'assignedNodes({flatten: true}) on a nameless slot element which appears after a default slot must return an empty array');
-
-    innerShadow.removeChild(newInnerSlot);
-    assert_array_equals(newInnerSlot.assignedNodes(), [], 'assignedNodes() must return an empty array when the slot element is not in any tree');
-    assert_array_equals(newInnerSlot.assignedNodes({flatten: false}), [], 'assignedNodes({flatten: false}) must return an empty array when the slot element is not in any tree');
-    assert_array_equals(newInnerSlot.assignedNodes({flatten: true}), [], 'assignedNodes({flatten: true}) must return an empty array when the slot element is not in any tree');
-
-    assert_array_equals(innerSlot.assignedNodes(), [outerSlot, innerChild], 'assignedNodes() on a default slot must return the assigned nodes');
-    assert_array_equals(innerSlot.assignedNodes({flatten: false}), [outerSlot, innerChild], 'assignedNodes({flatten: false}) on a default slot must return the assigned nodes');
-    assert_array_equals(innerSlot.assignedNodes({flatten: true}), [outerChild, innerChild], 'assignedNodes({flatten: true}) on a default slot must return the distributed nodes');
-
-}, 'assignedNodes({flatten: true}) must return the distributed nodes, and assignedNodes() and assignedNodes({flatten: false}) must returned the assigned nodes');
-
-&lt;/script&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomMouseEventprototypeoffsetXoffsetYexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/MouseEvent-prototype-offsetX-offsetY-expected.txt (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/MouseEvent-prototype-offsetX-offsetY-expected.txt        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/MouseEvent-prototype-offsetX-offsetY-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,6 +0,0 @@
</span><del>-Click here
-
-PASS MouseEvent's offsetX and offsetY attributes must be relative to the target. 
-PASS MouseEvent's offsetX and offsetY attributes must be relative to the shadow host when an event is dispatched inside its shadow tree. 
-PASS MouseEvent's offsetX and offsetY attributes must be relative to the target when an event is dispatched on a slotted content. 
-
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomMouseEventprototypeoffsetXoffsetYhtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,155 +0,0 @@
</span><del>-&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
-&lt;title&gt;Shadow DOM: MouseEvent's offsetX and offsetY attributes must be relative to the relative target.&lt;/title&gt;
-&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
-&lt;meta name=&quot;assert&quot; content=&quot;The MouseEvent offsetX and offsetY attributes must return the coordinates relative to the origin of the padding edge of the relative target&quot;&gt;
-&lt;link rel=&quot;help&quot; href=&quot;http://w3c.github.io/webcomponents/spec/shadow/#event-dispatch&quot;&gt;
-&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
-&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
-&lt;script src=&quot;resources/event-path-test-helpers.js&quot;&gt;&lt;/script&gt;
-&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
-&lt;/head&gt;
-&lt;body&gt;
-&lt;style&gt;
-html, body { padding: 0; margin: 0; }
-my-host { display: block; width: 180px; height: 80px; margin: 10px 20px; padding: 10px; background: #ccc; }
-#log { margin: 1rem; }
-&lt;/style&gt;
-&lt;my-host&gt;&lt;/my-host&gt;
-&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
-&lt;script&gt;
-
-var shadowStyle = '#container { width: 160px; height: 60px; padding: 10px; background: yellow; } #target { margin-left: 5px; background: orange; }';
-var host = document.querySelector('my-host');
-
-function attachLoggers(targets)
-{
-    var eventLogs = [];
-    for (var i = 0; i &lt; targets.length; i++) {
-        targets[i].addEventListener('mousedown', function (event) {
-            eventLogs.push({current: this, target: event.target, offsetX: event.offsetX, offsetY: event.offsetY});
-        });
-    }
-    return eventLogs;
-}
-
-test(function () {
-    host.innerHTML = '&lt;style&gt;' + shadowStyle + '&lt;/style&gt;&lt;div id=&quot;container&quot;&gt;&lt;span id=&quot;target&quot;&gt;Click here&lt;/div&gt;&lt;/div&gt;';
-
-    var target = host.querySelector('#target');
-    var container = host.querySelector('#container');
-
-    var eventLogs = attachLoggers([target, container, host, document.body]);
-    var mouseEvent = new MouseEvent('mousedown', {clientX: 51, clientY: 37, composed: true, bubbles: true});
-    target.dispatchEvent(mouseEvent);
-
-    assert_equals(host.offsetLeft, 20, 'The host must be at (20px, 10px)');
-    assert_equals(host.offsetTop, 10, 'The host must be at (20px, 10px)');
-    assert_equals(target.offsetLeft, 45, 'The target must be at (45px, 30px)');
-    assert_equals(target.offsetTop, 30, 'The target must be at (45px, 30px)');
-
-    assert_equals(eventLogs[0].current, target);
-    assert_equals(eventLogs[0].target, target);
-    assert_equals(eventLogs[0].offsetX, 21); // Padding edge of target is at (30px, 20px)
-    assert_equals(eventLogs[0].offsetY, 17);
-
-    assert_equals(eventLogs[1].current, container);
-    assert_equals(eventLogs[1].target, target);
-    assert_equals(eventLogs[1].offsetX, 21);
-    assert_equals(eventLogs[1].offsetY, 17);
-
-    assert_equals(eventLogs[2].current, host);
-    assert_equals(eventLogs[2].target, target);
-    assert_equals(eventLogs[2].offsetX, 21);
-    assert_equals(eventLogs[2].offsetY, 17);
-
-    assert_equals(eventLogs[3].current, document.body);
-    assert_equals(eventLogs[3].target, target);
-    assert_equals(eventLogs[3].offsetX, 21);
-    assert_equals(eventLogs[3].offsetY, 17);
-}, 'MouseEvent\'s offsetX and offsetY attributes must be relative to the target.');
-
-var shadowRoot = host.attachShadow({mode: 'closed'});
-test(function () {
-    shadowRoot.innerHTML = '&lt;style&gt;' + shadowStyle + '&lt;/style&gt;&lt;div id=&quot;container&quot;&gt;&lt;span id=&quot;target&quot;&gt;Click here&lt;/div&gt;&lt;/div&gt;';
-
-    var target = shadowRoot.querySelector('#target');
-    var container = shadowRoot.querySelector('#container');
-
-    var eventLogs = attachLoggers([target, container, shadowRoot, host, document.body]);
-    var mouseEvent = new MouseEvent('mousedown', {clientX: 51, clientY: 37, composed: true, bubbles: true});
-    target.dispatchEvent(mouseEvent);
-
-    assert_equals(host.offsetLeft, 20, 'The host must be at (20px, 10px)');
-    assert_equals(host.offsetTop, 10, 'The host must be at (20px, 10px)');
-    assert_equals(target.offsetLeft, 45, 'The target must be at (45px, 30px)');
-    assert_equals(target.offsetTop, 30, 'The target must be at (45px, 30px)');
-
-    assert_equals(eventLogs[0].current, target);
-    assert_equals(eventLogs[0].target, target);
-    assert_equals(eventLogs[0].offsetX, 21); // Padding edge of target is at (30px, 20px)
-    assert_equals(eventLogs[0].offsetY, 17);
-
-    assert_equals(eventLogs[1].current, container);
-    assert_equals(eventLogs[1].target, target);
-    assert_equals(eventLogs[1].offsetX, 21);
-    assert_equals(eventLogs[1].offsetY, 17);
-
-    assert_equals(eventLogs[3].current, host);
-    assert_equals(eventLogs[3].target, host);
-    assert_equals(eventLogs[3].offsetX, 31); // Padding edge of host is at (20px, 10px)
-    assert_equals(eventLogs[3].offsetY, 27);
-
-    assert_equals(eventLogs[4].current, document.body);
-    assert_equals(eventLogs[4].target, host);
-    assert_equals(eventLogs[4].offsetX, 31);
-    assert_equals(eventLogs[4].offsetY, 27);
-}, 'MouseEvent\'s offsetX and offsetY attributes must be relative to the shadow host when an event is dispatched inside its shadow tree.');
-
-test(function () {
-    shadowRoot.innerHTML = '&lt;style&gt;' + shadowStyle + '&lt;/style&gt;&lt;div id=&quot;container&quot;&gt;&lt;slot&gt;&lt;/slot&gt;&lt;/div&gt;';
-    host.innerHTML = '&lt;style&gt;' + shadowStyle + '&lt;/style&gt;&lt;div id=&quot;target&quot;&gt;Click here&lt;/div&gt;';
-
-    var target = host.querySelector('#target');
-    var container = shadowRoot.querySelector('#container');
-
-    var eventLogs = attachLoggers([target, container, shadowRoot, host, document.body]);
-    var mouseEvent = new MouseEvent('mousedown', {clientX: 51, clientY: 37, scoped: false, bubbles: true});
-    target.dispatchEvent(mouseEvent);
-
-    assert_equals(host.offsetLeft, 20, 'The host must be at (20px, 10px)');
-    assert_equals(host.offsetTop, 10, 'The host must be at (20px, 10px)');
-    assert_equals(target.offsetLeft, 45, 'The target must be at (45px, 30px)');
-    assert_equals(target.offsetTop, 30, 'The target must be at (45px, 30px)');
-
-    assert_equals(eventLogs[0].current, target);
-    assert_equals(eventLogs[0].target, target);
-    assert_equals(eventLogs[0].target.offsetParent, document.body);
-    assert_equals(eventLogs[0].offsetX, 6); // Padding edge of target is at (45px, 30px)
-    assert_equals(eventLogs[0].offsetY, 7);
-
-    assert_equals(eventLogs[1].current, container);
-    assert_equals(eventLogs[1].target, target);
-    assert_equals(eventLogs[1].offsetX, 6);
-    assert_equals(eventLogs[1].offsetY, 7);
-
-    assert_equals(eventLogs[2].current, shadowRoot);
-    assert_equals(eventLogs[2].target, target);
-    assert_equals(eventLogs[2].offsetX, 6);
-    assert_equals(eventLogs[2].offsetY, 7);
-
-    assert_equals(eventLogs[3].current, host);
-    assert_equals(eventLogs[3].target, target);
-    assert_equals(eventLogs[3].offsetX, 6);
-    assert_equals(eventLogs[3].offsetY, 7);
-
-    assert_equals(eventLogs[4].current, document.body);
-    assert_equals(eventLogs[4].target, target);
-    assert_equals(eventLogs[4].offsetX, 6);
-    assert_equals(eventLogs[4].offsetY, 7);
-}, 'MouseEvent\'s offsetX and offsetY attributes must be relative to the target when an event is dispatched on a slotted content.');
-
-&lt;/script&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomNodeprototypecloneNodeexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/Node-prototype-cloneNode-expected.txt (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Node-prototype-cloneNode-expected.txt        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/Node-prototype-cloneNode-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,5 +0,0 @@
</span><del>-
-PASS cloneNode on a shadow root in open mode must throw a NotSupportedError 
-PASS cloneNode on a shadow root in closed mode must throw a NotSupportedError 
-PASS cloneNode on an open shadow root must throw a NotSupportedError 
-
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomNodeprototypecloneNodehtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/Node-prototype-cloneNode.html (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Node-prototype-cloneNode.html        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/Node-prototype-cloneNode.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,46 +0,0 @@
</span><del>-&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
-&lt;title&gt;Shadow DOM: Extensions to Node interface&lt;/title&gt;
-&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
-&lt;meta name=&quot;assert&quot; content=&quot;Invoking the cloneNode() method on a ShadowRoot instance must always throw a NotSupportedError.&quot;&gt;
-&lt;link rel=&quot;help&quot; href=&quot;http://w3c.github.io/webcomponents/spec/shadow/#the-shadowroot-interface&quot;&gt;
-&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
-&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
-&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
-&lt;/head&gt;
-&lt;body&gt;
-&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
-&lt;script&gt;
-
-function testCloneNode(mode) {
-    test(function () {
-        assert_throws({'name': 'NotSupportedError'}, function () {
-            var element = document.createElement('div');
-            var shadowRoot = element.attachShadow({mode: mode});
-            shadowRoot.cloneNode(false);
-        }, 'cloneNode(false) on a shadow root in ' + mode + ' mode must throw a NotSupportedError');
-
-        assert_throws({'name': 'NotSupportedError'}, function () {
-            var element = document.createElement('div');
-            var shadowRoot = element.attachShadow({mode: mode});
-            shadowRoot.cloneNode(false);
-        }, 'cloneNode(true) on a closed shadow root must throw a NotSupportedError');
-
-    }, 'cloneNode on a shadow root in ' + mode + ' mode must throw a NotSupportedError');
-}
-
-testCloneNode('open');
-testCloneNode('closed');
-
-test(function () {
-    var element = document.createElement('div');
-    var shadowRoot = element.attachShadow({mode: 'open'});
-
-    assert_equals(element.cloneNode(false).shadowRoot, null, 'cloneNode(false) on an open shadow host mode must clone its shadow root');
-    assert_equals(element.cloneNode(true).shadowRoot, null, 'cloneNode(true) on an open shadow host mode must clone its shadow root');
-}, 'cloneNode on an open shadow root must throw a NotSupportedError');
-
-&lt;/script&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomShadowRootinterfaceexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/ShadowRoot-interface-expected.txt (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/ShadowRoot-interface-expected.txt        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/ShadowRoot-interface-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,14 +0,0 @@
</span><del>-
-PASS Check the existence of ShadowRoot interface 
-PASS ShadowRoot must inherit from DocumentFragment 
-PASS ShadowRoot must not be a constructor 
-PASS ShadowRoot.activeElement must return the focused element of the context object when shadow root is open. 
-PASS ShadowRoot.activeElement must return the focused element of the context object when shadow root is closed. 
-PASS ShadowRoot.host must return the shadow host of the context object. 
-PASS ShadowRoot.innerHTML must return the result of the HTML fragment serialization algorithm when shadow root is open. 
-PASS ShadowRoot.innerHTML must return the result of the HTML fragment serialization algorithm when shadow root is closed. 
-PASS ShadowRoot.innerHTML must replace all with the result of invoking the fragment parsing algorithm when shadow root is open. 
-PASS ShadowRoot.innerHTML must replace all with the result of invoking the fragment parsing algorithm when shadow root is closed. 
-FAIL ShadowRoot.styleSheets must return a StyleSheetList sequence containing the shadow root style sheets when shadow root is open. undefined is not an object (evaluating 'shadowRoot.styleSheets.length')
-FAIL ShadowRoot.styleSheets must return a StyleSheetList sequence containing the shadow root style sheets when shadow root is closed. undefined is not an object (evaluating 'shadowRoot.styleSheets.length')
-
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomShadowRootinterfacehtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/ShadowRoot-interface.html (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/ShadowRoot-interface.html        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/ShadowRoot-interface.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,112 +0,0 @@
</span><del>-&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
-&lt;title&gt;Shadow DOM: ShadowRoot interface&lt;/title&gt;
-&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
-&lt;meta name=&quot;assert&quot; content=&quot;ShadowRoot interface and its attributes must be defined&quot;&gt;
-&lt;link rel=&quot;help&quot; href=&quot;https://w3c.github.io/webcomponents/spec/shadow/#the-shadowroot-interface&quot;&gt;
-&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
-&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
-&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
-&lt;/head&gt;
-&lt;body&gt;
-&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
-&lt;script&gt;
-
-test(function () {
-    assert_true('ShadowRoot' in window, '&quot;ShadowRoot&quot; exists on window');
-}, 'Check the existence of ShadowRoot interface');
-
-test(function () {
-    assert_equals(ShadowRoot.prototype.__proto__, DocumentFragment.prototype, 'ShadowRoot must inherit from DocumentFragment');
-}, 'ShadowRoot must inherit from DocumentFragment');
-
-test(function () {
-    assert_throws({'name': 'TypeError'}, function () { new ShadowRoot(); }, 'new ShadowRoot() must throw a TypeError');
-}, 'ShadowRoot must not be a constructor');
-
-function testActiveElement(mode) {
-    test(function () {
-        var host = document.createElement('div');
-        document.body.appendChild(host);
-        var shadowRoot = host.attachShadow({'mode': mode});
-        shadowRoot.appendChild(document.createElement('input'));
-        assert_equals(shadowRoot.activeElement, null, 'ShadowRoot.host must return null if an ' + mode + ' shadow tree does not have a focused element');
-        shadowRoot.firstChild.focus();
-        assert_equals(shadowRoot.activeElement, shadowRoot.firstChild, 'ShadowRoot.host must return the focused element of an ' + mode + ' shadow tree');
-        host.remove();
-        assert_equals(shadowRoot.activeElement, null, 'ShadowRoot.host must return null if an ' + mode + ' shadow tree lost focus');
-    }, 'ShadowRoot.activeElement must return the focused element of the context object when shadow root is ' + mode + '.');
-}
-
-testActiveElement('open');
-testActiveElement('closed');
-
-test(function () {
-    var host1 = document.createElement('div');
-    assert_equals(host1.attachShadow({'mode': 'open'}).host, host1, 'ShadowRoot.host must return the shadow host of an open shadow tree')
-
-    var host2 = document.createElement('div');
-    assert_equals(host2.attachShadow({'mode': 'closed'}).host, host2, 'ShadowRoot.host must return the shadow host of a closed shadow tree');
-}, 'ShadowRoot.host must return the shadow host of the context object.');
-
-function testInnerHTML(mode) {
-    test(function () {
-        var host = document.createElement('div');
-        var shadowRoot = host.attachShadow({'mode': mode});
-        assert_equals(shadowRoot.innerHTML, '', 'ShadowRoot.innerHTML must be an empty string when the shadow root does not have any children');
-
-        shadowRoot.appendChild(document.createTextNode('hello'));
-        assert_equals(shadowRoot.innerHTML, 'hello', 'ShadowRoot.innerHTML must serialize a text node child');
-
-        shadowRoot.appendChild(document.createElement('span'));
-        assert_equals(shadowRoot.innerHTML, 'hello&lt;span&gt;&lt;/span&gt;', 'ShadowRoot.innerHTML must serialize a HTML element child');
-    }, 'ShadowRoot.innerHTML must return the result of the HTML fragment serialization algorithm when shadow root is ' + mode + '.');
-}
-
-testInnerHTML('open');
-testInnerHTML('closed');
-
-function testSetInnerHTML(mode) {
-    test(function () {
-        var host = document.createElement('div');
-        var shadowRoot = host.attachShadow({'mode': mode});
-        shadowRoot.innerHTML = 'hello';
-        assert_equals(shadowRoot.childNodes.length, 1, 'ShadowRoot.innerHTML = &quot;hello&quot; must insert a single child (text node)');
-        assert_true(shadowRoot.firstChild instanceof Text, 'The first child of the shadow root after ShadowRoot.innerHTML = &quot;hello&quot; must be a Text node');
-        assert_equals(shadowRoot.firstChild.data, 'hello', 'The first Text node should contain the string &quot;hello&quot; after ShadowRoot.innerHTML = &quot;hello&quot;');
-
-        shadowRoot.innerHTML = '&lt;b&gt;hello&lt;/b&gt;';
-        assert_equals(shadowRoot.childNodes.length, 1, 'ShadowRoot.innerHTML = &quot;&lt;b&gt;hello&lt;/b&gt;&quot; must insert a single child (b)');
-        assert_true(shadowRoot.firstChild instanceof HTMLElement, 'The first child of the shadow root after ShadowRoot.innerHTML = &quot;&lt;b&gt;hello&lt;/b&gt;&quot; must be a HTML element');
-        assert_equals(shadowRoot.firstChild.localName, 'b', 'The local name of the shadow root\'s first child after ShadowRoot.innerHTML = &quot;&lt;b&gt;hello&lt;/b&gt;&quot; must be &quot;b&quot;');
-        assert_equals(shadowRoot.innerHTML, '&lt;b&gt;hello&lt;/b&gt;', 'ShadowRoot.innerHTML must be &quot;&lt;b&gt;hello&lt;/b&gt;&quot; after ShadowRoot.innerHTML = &quot;&lt;b&gt;hello&lt;/b&gt;&quot;');
-
-        shadowRoot.innerHTML = '';
-        assert_equals(shadowRoot.childNodes.length, 0, 'ShadowRoot.innerHTML = &quot;&quot; must remove all its children');
-    }, 'ShadowRoot.innerHTML must replace all with the result of invoking the fragment parsing algorithm when shadow root is ' + mode + '.');
-}
-
-testSetInnerHTML('open');
-testSetInnerHTML('closed');
-
-function testStyleSheets(mode) {
-    test(function () {
-        var host = document.createElement('div');
-        var shadowRoot = host.attachShadow({'mode': mode});
-
-        assert_equals(shadowRoot.styleSheets.length, 0, 'shadowRoot.styleSheets must be empty when the shadow root does not contain any stylesheets');
-        shadowRoot.innerHTML = '&lt;span&gt;&lt;/span&gt;&lt;style&gt; a.rule {} &lt;/style&gt;&lt;style&gt; b.rule {} &lt;/style&gt;';
-        assert_equals(shadowRoot.styleSheets.length, 2, 'shadowRoot.styleSheets must contain two items when the shadow root has two style elements');
-        var styles = shadowRoot.querySelectorAll('style');
-        assert_equals(shadowRoot.styleSheets[0], styles[0].sheet, 'shadowRoot.styleSheets[0] must be the first style element in the shadow root');
-        assert_equals(shadowRoot.styleSheets[1], styles[1].sheet, 'shadowRoot.styleSheets[1] must be the second style element in the shadow root');
-    }, 'ShadowRoot.styleSheets must return a StyleSheetList sequence containing the shadow root style sheets when shadow root is ' + mode + '.');
-}
-
-testStyleSheets('open');
-testStyleSheets('closed');
-
-&lt;/script&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomSlotableinterfaceassignedSlotexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/Slotable-interface-assignedSlot-expected.txt (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Slotable-interface-assignedSlot-expected.txt        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/Slotable-interface-assignedSlot-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,6 +0,0 @@
</span><del>-
-PASS assignedSlot attribute must be defined on NonDocumentTypeChildNode interface 
-PASS assignedSlot must return null when the node does not have an assigned node 
-PASS assignedSlot must return the assigned slot 
-PASS assignedSlot must return null when the assigned slot element is inside a closed shadow tree 
-
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomSlotableinterfaceassignedSlothtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/Slotable-interface-assignedSlot.html (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/Slotable-interface-assignedSlot.html        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/Slotable-interface-assignedSlot.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,95 +0,0 @@
</span><del>-&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
-&lt;title&gt;Shadow DOM: Slotable interface&lt;/title&gt;
-&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
-&lt;meta name=&quot;assert&quot; content=&quot;Slotable interface must have assignedSlot attribute&quot;&gt;
-&lt;link rel=&quot;help&quot; href=&quot;https://w3c.github.io/webcomponents/spec/shadow/#the-slot-element&quot;&gt;
-&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
-&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
-&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
-&lt;/head&gt;
-&lt;body&gt;
-&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
-&lt;script&gt;
-
-test(function () {
-    assert_true('assignedSlot' in Element.prototype, 'assignedSlot must be defined on Element.prototype');
-    assert_true('assignedSlot' in document.createElement('div'), 'assignedSlot must be defined on a div element');
-
-    assert_true('assignedSlot' in Text.prototype, 'assignedSlot must be defined on Text.prototype');
-    assert_true('assignedSlot' in document.createTextNode(''), 'assignedSlot must be defined on a text node');
-    assert_false('assignedSlot' in document.createComment(''), 'assignedSlot must not be defined on a comment node');
-    assert_false('assignedSlot' in document.createProcessingInstruction('target', 'data'), 'assignedSlot must not be defined on a processing instruction node');
-
-}, 'assignedSlot attribute must be defined on NonDocumentTypeChildNode interface');
-
-test(function () {
-    assert_equals(document.createElement('div').assignedSlot, null, 'assignedSlot must be null when the element is not in any tree');
-
-    var shadowHost = document.createElement('div');
-    var shadowRoot = shadowHost.attachShadow({mode: 'open'});
-
-    var childElement = document.createElement('b');
-    shadowHost.appendChild(childElement);
-    assert_equals(childElement.assignedSlot, null, 'assignedSlot on an element must be null when a node is not assigned of any slot');
-
-    var childTextNode = document.createTextNode('');
-    shadowHost.appendChild(childTextNode);
-    assert_equals(childTextNode.assignedSlot, null, 'assignedSlot on a text node must be null when a node is not assigned of any slot');
-
-    var slot = document.createElement('slot');
-    slot.name = 'foo';
-    shadowRoot.appendChild(slot);
-    assert_equals(childElement.assignedSlot, null, 'assignedSlot on an element must be null when a node does not match any slot');
-    assert_equals(childTextNode.assignedSlot, null, 'assignedSlot on a text node must be null when a node does not match any slot');
-
-}, 'assignedSlot must return null when the node does not have an assigned node');
-
-test(function () {
-    var shadowHost = document.createElement('div');
-    var childElement = document.createElement('b');
-    shadowHost.appendChild(childElement);
-
-    var childTextNode = document.createTextNode('');
-    shadowHost.appendChild(childTextNode);
-
-    var shadowRoot = shadowHost.attachShadow({mode: 'open'});
-    var slot = document.createElement('slot');
-    shadowRoot.appendChild(slot);
-
-    assert_equals(childElement.assignedSlot, slot, 'assignedSlot on an element must return the assigned default slot element');
-    assert_equals(childTextNode.assignedSlot, slot, 'assignedSlot on a text node must return the assigned default slot element');
-
-    slot.name = 'foo';
-    assert_equals(childElement.assignedSlot, null, 'assignedSlot on an element must null when the element is unassigned from a slot element');
-    assert_equals(childTextNode.assignedSlot, null, 'assignedSlot on a text node must null when the node is unassigned from a slot element');
-
-    childElement.slot = 'foo';
-    assert_equals(childElement.assignedSlot, slot, 'assignedSlot on an element must return the re-assigned slot element');
-
-    slot.removeAttribute('name');
-    assert_equals(childTextNode.assignedSlot, slot, 'assignedSlot on a text node must return the re-assigned slot element');
-
-}, 'assignedSlot must return the assigned slot');
-
-test(function () {
-    var shadowHost = document.createElement('div');
-    var childElement = document.createElement('b');
-    shadowHost.appendChild(childElement);
-
-    var childTextNode = document.createTextNode('');
-    shadowHost.appendChild(childTextNode);
-
-    var shadowRoot = shadowHost.attachShadow({mode: 'closed'});
-    var slot = document.createElement('slot');
-    shadowRoot.appendChild(slot);
-
-    assert_equals(childElement.assignedSlot, null, 'assignedSlot on an element must return null if the slot is inside a closed shadow tree.');
-    assert_equals(childTextNode.assignedSlot, null, 'assignedSlot on a text node must return null if the slot is inside a closed shadow tree.');
-
-}, 'assignedSlot must return null when the assigned slot element is inside a closed shadow tree');
-
-&lt;/script&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomeventinsideshadowtreeexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/event-inside-shadow-tree-expected.txt (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/event-inside-shadow-tree-expected.txt        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/event-inside-shadow-tree-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,14 +0,0 @@
</span><del>-
-PASS Firing an event inside a grand child of a detached open mode shadow tree 
-PASS Firing an event inside a grand child of a detached closed mode shadow tree 
-PASS Firing an event inside a grand child of an in-document open mode shadow tree 
-PASS Firing an event inside a grand child of an in-document closed mode shadow tree 
-PASS Firing an event inside a detached open mode shadow tree inside open mode shadow tree 
-PASS Firing an event inside a detached open mode shadow tree inside closed mode shadow tree 
-PASS Firing an event inside a detached closed mode shadow tree inside open mode shadow tree 
-PASS Firing an event inside a detached closed mode shadow tree inside closed mode shadow tree 
-PASS Firing an event inside an in-document open mode shadow tree inside open mode shadow tree 
-PASS Firing an event inside an in-document open mode shadow tree inside closed mode shadow tree 
-PASS Firing an event inside an in-document closed mode shadow tree inside open mode shadow tree 
-PASS Firing an event inside an in-document closed mode shadow tree inside closed mode shadow tree 
-
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomeventinsideshadowtreehtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/event-inside-shadow-tree.html (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/event-inside-shadow-tree.html        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/event-inside-shadow-tree.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,149 +0,0 @@
</span><del>-&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
-&lt;title&gt;Shadow DOM: Firing an event inside a shadow tree&lt;/title&gt;
-&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
-&lt;meta name=&quot;assert&quot; content=&quot;The event path calculation algorithm must be used to determine event path&quot;&gt;
-&lt;link rel=&quot;help&quot; href=&quot;https://w3c.github.io/webcomponents/spec/shadow/#event-paths&quot;&gt;
-&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
-&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
-&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
-&lt;/head&gt;
-&lt;body&gt;
-&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
-&lt;script&gt;
-
-function dispatchEventWithLog(target, event) {
-    var log = [];
-
-    for (var node = target; node; node = node.parentNode || node.host) {
-        node.addEventListener(event.type, (function (event) {
-            log.push([this, event.target]);
-        }).bind(node));
-    }
-
-    target.dispatchEvent(event);
-
-    return log;
-}
-
-function createShadowRootWithGrandChild(mode) {
-    var host = document.createElement('div');
-    var root = host.attachShadow({mode: mode});
-
-    var parent = document.createElement('span');
-    root.appendChild(parent);
-
-    var target = document.createElement('b');
-    parent.appendChild(target);
-    return {target: target, parent: parent, root: root, host: host};
-}
-
-function testEventInDetachedShadowTree(mode) {
-    test(function () {
-        var shadow = createShadowRootWithGrandChild(mode);
-
-        log = dispatchEventWithLog(shadow.target, new Event('foo', {composed: true, bubbles: true}));
-
-        assert_array_equals(log.length, 4, 'EventPath must contain [target, parent, shadow root, shadow host]');
-        assert_array_equals(log[0], [shadow.target, shadow.target], 'EventPath[0] must be the target');
-        assert_array_equals(log[1], [shadow.parent, shadow.target], 'EventPath[1] must be the parent of the target');
-        assert_array_equals(log[2], [shadow.root, shadow.target], 'EventPath[2] must be the shadow root');
-        assert_array_equals(log[3], [shadow.host, shadow.host], 'EventPath[3] must be the shadow host');
-
-    }, 'Firing an event inside a grand child of a detached ' + mode + ' mode shadow tree');
-}
-
-testEventInDetachedShadowTree('open');
-testEventInDetachedShadowTree('closed');
-
-function testEventInShadowTreeInsideDocument(mode) {
-    test(function () {
-        var shadow = createShadowRootWithGrandChild(mode);
-        document.body.appendChild(shadow.host);
-
-        log = dispatchEventWithLog(shadow.target, new Event('foo', {composed: true, bubbles: true}));
-
-        assert_array_equals(log.length, 7, 'EventPath must contain [target, parent, shadow root, shadow host, body, html, document]');
-        assert_array_equals(log[0], [shadow.target, shadow.target], 'EventPath[0] must be the target');
-        assert_array_equals(log[1], [shadow.parent, shadow.target], 'EventPath[1] must be the parent of the target');
-        assert_array_equals(log[2], [shadow.root, shadow.target], 'EventPath[2] must be the shadow root');
-        assert_array_equals(log[3], [shadow.host, shadow.host], 'EventPath[3] must be the shadow host');
-        assert_array_equals(log[4], [document.body, shadow.host], 'EventPath[4] must be the body element (parent of shadow host)');
-        assert_array_equals(log[5], [document.documentElement, shadow.host], 'EventPath[5] must be the html element');
-        assert_array_equals(log[6], [document, shadow.host], 'EventPath[6] must be the document node');
-
-    }, 'Firing an event inside a grand child of an in-document ' + mode + ' mode shadow tree');
-}
-
-testEventInShadowTreeInsideDocument('open');
-testEventInShadowTreeInsideDocument('closed');
-
-function createNestedShadowRoot(innerMode, outerMode) {
-    var outerHost = document.createElement('div');
-    var outerRoot = outerHost.attachShadow({mode: outerMode});
-
-    var outerChild = document.createElement('p');
-    outerRoot.appendChild(outerChild);
-
-    var innerHost = document.createElement('span');
-    outerChild.appendChild(innerHost);
-
-    var innerRoot = innerHost.attachShadow({mode: innerMode});
-    var innerChild = document.createElement('span');
-    innerRoot.appendChild(innerChild);
-
-    return {target: innerChild, innerRoot: innerRoot, innerHost: innerHost, outerChild: outerChild, outerRoot: outerRoot, outerHost: outerHost};
-}
-
-function testEventInDetachedNestedShadowTree(innerMode, outerMode) {
-    test(function () {
-        var shadow = createNestedShadowRoot(innerMode, outerMode);
-
-        log = dispatchEventWithLog(shadow.target, new Event('bar', {composed: true, bubbles: true}));
-
-        assert_array_equals(log.length, 6, 'EventPath must contain [target, inner root, inner host, parent, outer root, outer host]');
-        assert_array_equals(log[0], [shadow.target, shadow.target], 'EventPath[0] must be the target');
-        assert_array_equals(log[1], [shadow.innerRoot, shadow.target], 'EventPath[1] must be the inner shadow root');
-        assert_array_equals(log[2], [shadow.innerHost, shadow.innerHost], 'EventPath[2] must be the inner shadow host');
-        assert_array_equals(log[3], [shadow.outerChild, shadow.innerHost], 'EventPath[3] must be the parent of the inner shadow host');
-        assert_array_equals(log[4], [shadow.outerRoot, shadow.innerHost], 'EventPath[4] must be the outer shadow root');
-        assert_array_equals(log[5], [shadow.outerHost, shadow.outerHost], 'EventPath[5] must be the outer shadow host');
-
-    }, 'Firing an event inside a detached ' + innerMode + ' mode shadow tree inside ' + outerMode + ' mode shadow tree');
-}
-
-testEventInDetachedNestedShadowTree('open',  'open');
-testEventInDetachedNestedShadowTree('open',  'closed');
-testEventInDetachedNestedShadowTree('closed', 'open');
-testEventInDetachedNestedShadowTree('closed', 'closed');
-
-function testEventInNestedShadowTreeInsideDocument(innerMode, outerMode) {
-    test(function () {
-        var shadow = createNestedShadowRoot(innerMode, outerMode);
-        document.body.appendChild(shadow.outerHost);
-
-        log = dispatchEventWithLog(shadow.target, new Event('bar', {composed: true, bubbles: true}));
-
-        assert_array_equals(log.length, 6, 'EventPath must contain [target, inner root, inner host, parent, outer root, outer host]');
-        assert_array_equals(log[0], [shadow.target, shadow.target], 'EventPath[0] must be the target');
-        assert_array_equals(log[1], [shadow.innerRoot, shadow.target], 'EventPath[1] must be the inner shadow root');
-        assert_array_equals(log[2], [shadow.innerHost, shadow.innerHost], 'EventPath[2] must be the inner shadow host');
-        assert_array_equals(log[3], [shadow.outerChild, shadow.innerHost], 'EventPath[3] must be the parent of the inner shadow host');
-        assert_array_equals(log[4], [shadow.outerRoot, shadow.innerHost], 'EventPath[4] must be the outer shadow root');
-        assert_array_equals(log[5], [shadow.outerHost, shadow.outerHost], 'EventPath[5] must be the outer shadow host');
-        assert_array_equals(log[6], [document.body, shadow.outerHost], 'EventPath[6] must be the body element');
-        assert_array_equals(log[7], [document.documentElement, shadow.outerHost], 'EventPath[7] must be the html element');
-        assert_array_equals(log[8], [document, shadow.outerHost], 'EventPath[8] must be the document node');
-
-    }, 'Firing an event inside an in-document ' + innerMode + ' mode shadow tree inside ' + outerMode + ' mode shadow tree');
-}
-
-testEventInNestedShadowTreeInsideDocument('open',  'open');
-testEventInNestedShadowTreeInsideDocument('open',  'closed');
-testEventInNestedShadowTreeInsideDocument('closed', 'open');
-testEventInNestedShadowTreeInsideDocument('closed', 'closed');
-
-&lt;/script&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomeventinsideslottednodeexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/event-inside-slotted-node-expected.txt (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/event-inside-slotted-node-expected.txt        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/event-inside-slotted-node-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,22 +0,0 @@
</span><del>-
-PASS Firing an event inside a grand child of a detached open mode shadow host 
-PASS Firing an event inside a grand child of a detached closed mode shadow host 
-PASS Firing an event inside a grand child of an in-document open mode shadow host 
-PASS Firing an event inside a grand child of an in-document closed mode shadow host 
-PASS Firing an event on a node with two ancestors with a detached open and open shadow trees with an inner open shadow tree 
-PASS Firing an event on a node with two ancestors with a detached open and open shadow trees with an inner closed shadow tree 
-PASS Firing an event on a node with two ancestors with a detached open and closed shadow trees with an inner open shadow tree 
-PASS Firing an event on a node with two ancestors with a detached open and closed shadow trees with an inner closed shadow tree 
-PASS Firing an event on a node with two ancestors with a detached closed and open shadow trees with an inner open shadow tree 
-PASS Firing an event on a node with two ancestors with a detached closed and open shadow trees with an inner closed shadow tree 
-PASS Firing an event on a node with two ancestors with a detached closed and closed shadow trees with an inner open shadow tree 
-PASS Firing an event on a node with two ancestors with a detached closed and closed shadow trees with an inner closed shadow tree 
-PASS Firing an event on a node with two ancestors with a detached open and open shadow trees with an inner open shadow tree 
-PASS Firing an event on a node with two ancestors with a detached open and open shadow trees with an inner closed shadow tree 
-PASS Firing an event on a node with two ancestors with a detached open and closed shadow trees with an inner open shadow tree 
-PASS Firing an event on a node with two ancestors with a detached open and closed shadow trees with an inner closed shadow tree 
-PASS Firing an event on a node with two ancestors with a detached closed and open shadow trees with an inner open shadow tree 
-PASS Firing an event on a node with two ancestors with a detached closed and open shadow trees with an inner closed shadow tree 
-PASS Firing an event on a node with two ancestors with a detached closed and closed shadow trees with an inner open shadow tree 
-PASS Firing an event on a node with two ancestors with a detached closed and closed shadow trees with an inner closed shadow tree 
-
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomeventinsideslottednodehtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/event-inside-slotted-node.html (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/event-inside-slotted-node.html        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/event-inside-slotted-node.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,259 +0,0 @@
</span><del>-&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
-    &lt;title&gt;Shadow DOM: Firing an event inside a node assigned to a slot&lt;/title&gt;
-    &lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
-    &lt;meta name=&quot;assert&quot; content=&quot;The event path calculation algorithm must be used to determine event path&quot;&gt;
-    &lt;link rel=&quot;help&quot; href=&quot;https://w3c.github.io/webcomponents/spec/shadow/#event-paths&quot;&gt;
-    &lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
-    &lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
-    &lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
-&lt;/head&gt;
-&lt;body&gt;
-    &lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
-    &lt;script&gt;
-
-        function dispatchEventWithLog(shadow, event) {
-            var log = [];
-
-            var attachedNodes = [];
-            for (var nodeKey in shadow) {
-                var startingNode = shadow[nodeKey];
-                for (var node = startingNode; node; node = node.parentNode) {
-                    if (attachedNodes.indexOf(node) &gt;= 0)
-                        continue;
-                    attachedNodes.push(node);
-                    node.addEventListener(event.type, (function (event) {
-                        log.push([this, event.target]);
-                    }).bind(node));
-                }
-            }
-
-            shadow.target.dispatchEvent(event);
-
-            return log;
-        }
-
-        function element(name, children, className) {
-            var element = document.createElement(name);
-            if (className)
-                element.className = className;
-            if (children) {
-                for (var child of children)
-                    element.appendChild(child);
-            }
-            return element;
-        }
-
-        function attachShadow(host, mode, children) {
-            var shadowRoot = host.attachShadow({mode: mode});
-            if (children) {
-                for (var child of children)
-                    shadowRoot.appendChild(child);
-            }
-            return shadowRoot;
-        }
-
-        function createShadowHostWithAssignedGrandChild(mode) {
-            var host = element('div', [
-                element('b', [
-                    element('i')
-                ])
-            ]);
-
-            var root = attachShadow(host, mode, [
-                element('span', [
-                    element('slot')
-                ])
-            ]);
-
-            return {target: host.querySelector('i'), targetParent: host.querySelector('b'), host: host,
-                    slot: root.querySelector('slot'), slotParent: root.querySelector('span'), root: root};
-        }
-
-        function testEventInDetachedShadowHostDescendant(mode) {
-            test(function () {
-                var shadow = createShadowHostWithAssignedGrandChild(mode);
-
-                log = dispatchEventWithLog(shadow, new Event('foo', {bubbles: true, composed: true}));
-
-                assert_equals(log.length, 6, 'EventPath must contain [target, target parent, slot, slot parent, shadow root, shadow host]');
-                assert_array_equals(log[0], [shadow.target, shadow.target], 'EventPath[0] must be the target');
-                assert_array_equals(log[1], [shadow.targetParent, shadow.target], 'EventPath[1] must be the parent of the target');
-                assert_array_equals(log[2], [shadow.slot, shadow.target], 'EventPath[2] must be the slot');
-                assert_array_equals(log[3], [shadow.slotParent, shadow.target], 'EventPath[3] must be the parent of the slot');
-                assert_array_equals(log[4], [shadow.root, shadow.target], 'EventPath[4] must be the shadow root');
-                assert_array_equals(log[5], [shadow.host, shadow.target], 'EventPath[5] must be the shadow host');
-
-            }, 'Firing an event inside a grand child of a detached ' + mode + ' mode shadow host');
-        }
-
-        testEventInDetachedShadowHostDescendant('open');
-        testEventInDetachedShadowHostDescendant('closed');
-
-        function testEventInShadowHostDescendantInsideDocument(mode) {
-            test(function () {
-                var shadow = createShadowHostWithAssignedGrandChild(mode);
-                document.body.appendChild(shadow.host);
-
-                log = dispatchEventWithLog(shadow, new Event('foo', {bubbles: true, composed: true}));
-
-                assert_equals(log.length, 9, 'EventPath must contain [target, target parent, slot, slot parent, shadow root, shadow host, body, html, document]');
-                assert_array_equals(log[0], [shadow.target, shadow.target], 'EventPath[0] must be the target');
-                assert_array_equals(log[1], [shadow.targetParent, shadow.target], 'EventPath[1] must be the parent of the target');
-                assert_array_equals(log[2], [shadow.slot, shadow.target], 'EventPath[2] must be the slot');
-                assert_array_equals(log[3], [shadow.slotParent, shadow.target], 'EventPath[3] must be the parent of the slot');
-                assert_array_equals(log[4], [shadow.root, shadow.target], 'EventPath[4] must be the shadow root');
-                assert_array_equals(log[5], [shadow.host, shadow.target], 'EventPath[5] must be the shadow host');
-                assert_array_equals(log[6], [document.body, shadow.target], 'EventPath[6] must be the body element');
-                assert_array_equals(log[7], [document.documentElement, shadow.target], 'EventPath[7] must be the html element');
-                assert_array_equals(log[8], [document, shadow.target], 'EventPath[8] must be the html element');
-
-            }, 'Firing an event inside a grand child of an in-document ' + mode + ' mode shadow host');
-        }
-
-        testEventInShadowHostDescendantInsideDocument('open');
-        testEventInShadowHostDescendantInsideDocument('closed');
-
-        function createNestedShadowTreesWithSlots(innerMode, outerUpperMode, outerLowerMode) {
-            var upperHost = element('upper-host', [
-                element('p', [
-                    element('lower-host', [
-                        element('a')
-                    ])
-                ])
-            ]);
-
-            var upperShadow = attachShadow(upperHost, outerUpperMode, [
-                element('b', [
-                    element('slot', [], 'upper-slot')
-                ])
-            ]);
-
-            var lowerHost = upperHost.querySelector('lower-host');
-            var lowerShadow = attachShadow(lowerHost, outerLowerMode, [
-                element('em', [
-                    element('inner-host', [
-                        element('span', [
-                            element('slot', [], 'lower-slot')
-                        ])
-                    ])
-                ])
-            ]);
-
-            innerShadow = attachShadow(lowerShadow.querySelector('inner-host'), innerMode, [
-                element('i', [
-                    element('slot', [], 'inner-slot')
-                ])
-            ]);
-
-            return {
-                host: upperHost,
-                target: upperHost.querySelector('a'),
-                upperShadow: upperShadow,
-                upperSlot: upperShadow.querySelector('slot'),
-                lowerShadow: lowerShadow,
-                lowerSlot: lowerShadow.querySelector('slot'),
-                innerShadow: innerShadow,
-                innerSlot: innerShadow.querySelector('slot'),
-            };
-        }
-
-        /*
-        upper-host (14) -- (upperShadow; 13)
-         + p (10)          + b (12)
-          |                  + slot (upperSlot; 11)
-          + lower-host (9) -- (lowerShadow; 8)
-            + a (target; 0)   + em (7)
-                                + inner-host (6) -------- (innerShadow; 5)
-                                  + span (2)              + i (4)
-                                    + slot (lowerSlot; 1) + slot (innerSlot; 3)
-        */
-
-        function testEventUnderTwoShadowRoots(outerUpperMode, outerLowerMode, innerMode) {
-            test(function () {
-                var shadow = createNestedShadowTreesWithSlots(innerMode, outerUpperMode, outerLowerMode);
-
-                log = dispatchEventWithLog(shadow, new Event('foo', {bubbles: true, composed: true}));
-
-                assert_equals(log.length, 15, 'EventPath must contain 15 targets');
-
-                assert_array_equals(log[0], [shadow.target, shadow.target], 'EventPath[0] must be the target');
-                assert_array_equals(log[1], [shadow.lowerSlot, shadow.target], 'EventPath[1] must be the slot inside the lower shadow tree');
-                assert_array_equals(log[2], [shadow.lowerSlot.parentNode, shadow.target], 'EventPath[2] must be the parent of the slot inside the lower shadow tree');
-                assert_array_equals(log[3], [shadow.innerSlot, shadow.target], 'EventPath[3] must be the slot inside the shadow tree inside the lower shadow tree');
-                assert_array_equals(log[4], [shadow.innerSlot.parentNode, shadow.target], 'EventPath[4] must be the child of the inner shadow root');
-                assert_array_equals(log[5], [shadow.innerShadow, shadow.target], 'EventPath[5] must be the inner shadow root');
-                assert_array_equals(log[6], [shadow.innerShadow.host, shadow.target], 'EventPath[6] must be the host of the inner shadow tree');
-                assert_array_equals(log[7], [shadow.lowerShadow.firstChild, shadow.target], 'EventPath[7] must be the parent of the inner shadow host');
-                assert_array_equals(log[8], [shadow.lowerShadow, shadow.target], 'EventPath[8] must be the lower shadow root');
-                assert_array_equals(log[9], [shadow.lowerShadow.host, shadow.target], 'EventPath[9] must be the lower shadow host');
-                assert_array_equals(log[10], [shadow.host.firstChild, shadow.target], 'EventPath[10] must be the parent of the grand parent of the target');
-                assert_array_equals(log[11], [shadow.upperSlot, shadow.target], 'EventPath[11] must be the slot inside the upper shadow tree');
-                assert_array_equals(log[12], [shadow.upperSlot.parentNode, shadow.target], 'EventPath[12] must be the parent of the slot inside the upper shadow tree');
-                assert_array_equals(log[13], [shadow.upperShadow, shadow.target], 'EventPath[13] must be the upper shadow root');
-                assert_array_equals(log[14], [shadow.host, shadow.target], 'EventPath[14] must be the host');
-
-            }, 'Firing an event on a node with two ancestors with a detached ' + outerUpperMode + ' and ' + outerLowerMode
-                + ' shadow trees with an inner ' + innerMode + ' shadow tree');
-        }
-
-        testEventUnderTwoShadowRoots('open', 'open', 'open');
-        testEventUnderTwoShadowRoots('open', 'open', 'closed');
-        testEventUnderTwoShadowRoots('open', 'closed', 'open');
-        testEventUnderTwoShadowRoots('open', 'closed', 'closed');
-        testEventUnderTwoShadowRoots('closed', 'open', 'open');
-        testEventUnderTwoShadowRoots('closed', 'open', 'closed');
-        testEventUnderTwoShadowRoots('closed', 'closed', 'open');
-        testEventUnderTwoShadowRoots('closed', 'closed', 'closed');
-
-        /*
-        upper-host (11) -- (upperShadow; 10)
-         + p (7)           + b (9)
-          |                  + slot (upperSlot; 8)
-          + lower-host (6) -- (lowerShadow; 5)
-            + a               + em (4)
-                                + inner-host (3) -- (innerShadow; 2)
-                                  + span            + i (1)
-                                    + slot            + slot (innerSlot, target; 0)
-        */
-
-        function testEventInsideNestedShadowsUnderAnotherShadow(outerUpperMode, outerLowerMode, innerMode) {
-            test(function () {
-                var shadow = createNestedShadowTreesWithSlots(innerMode, outerUpperMode, outerLowerMode);
-                shadow.deepestNodeInLightDOM = shadow.target; // Needed for dispatchEventWithLog to attach event listeners. 
-                shadow.target = shadow.innerSlot;
-
-                log = dispatchEventWithLog(shadow, new Event('foo', {bubbles: true, composed: true}));
-
-                assert_equals(log.length, 12, 'EventPath must contain 12 targets');
-
-                assert_array_equals(log[0], [shadow.target, shadow.target], 'EventPath[0] must be the target');
-                assert_array_equals(log[1], [shadow.target.parentNode, shadow.target], 'EventPath[1] must be the parent of the target');
-                assert_array_equals(log[2], [shadow.innerShadow, shadow.target], 'EventPath[2] must be the inner shadow root');
-                assert_array_equals(log[3], [shadow.innerShadow.host, shadow.innerShadow.host], 'EventPath[3] must be the inner shadow host');
-                assert_array_equals(log[4], [shadow.lowerShadow.firstChild, shadow.innerShadow.host], 'EventPath[4] must be the parent of the inner shadow host');
-                assert_array_equals(log[5], [shadow.lowerShadow, shadow.innerShadow.host], 'EventPath[5] must be the lower (but outer) shadow root');
-                assert_array_equals(log[6], [shadow.lowerShadow.host, shadow.lowerShadow.host], 'EventPath[6] must be the lower (but outer) shadow root');
-                assert_array_equals(log[7], [shadow.host.firstChild, shadow.lowerShadow.host], 'EventPath[7] must be the slot inside the upper shadow tree');
-                assert_array_equals(log[8], [shadow.upperSlot, shadow.lowerShadow.host], 'EventPath[8] must be the slot inside the upper shadow tree');
-                assert_array_equals(log[9], [shadow.upperSlot.parentNode, shadow.lowerShadow.host], 'EventPath[9] must be the parent of the slot inside the upper shadow tree');
-                assert_array_equals(log[10], [shadow.upperShadow, shadow.lowerShadow.host], 'EventPath[10] must be the upper shadow root');
-                assert_array_equals(log[11], [shadow.upperShadow.host, shadow.lowerShadow.host], 'EventPath[11] must be the host');
-
-            }, 'Firing an event on a node with two ancestors with a detached ' + outerUpperMode + ' and ' + outerLowerMode
-                + ' shadow trees with an inner ' + innerMode + ' shadow tree');
-        }
-
-        testEventInsideNestedShadowsUnderAnotherShadow('open', 'open', 'open');
-        testEventInsideNestedShadowsUnderAnotherShadow('open', 'open', 'closed');
-        testEventInsideNestedShadowsUnderAnotherShadow('open', 'closed', 'open');
-        testEventInsideNestedShadowsUnderAnotherShadow('open', 'closed', 'closed');
-        testEventInsideNestedShadowsUnderAnotherShadow('closed', 'open', 'open');
-        testEventInsideNestedShadowsUnderAnotherShadow('closed', 'open', 'closed');
-        testEventInsideNestedShadowsUnderAnotherShadow('closed', 'closed', 'open');
-        testEventInsideNestedShadowsUnderAnotherShadow('closed', 'closed', 'closed');
-
-    &lt;/script&gt;
-    &lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomeventwithrelatedtargetexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/event-with-related-target-expected.txt (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/event-with-related-target-expected.txt        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/event-with-related-target-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,20 +0,0 @@
</span><del>-
-PASS Firing an event at B1a with relatedNode at B1 with open mode shadow trees 
-PASS Firing an event at B1a with relatedNode at B1 with closed mode shadow trees 
-PASS Firing an event at B1a with relatedNode at B1b1 with open mode shadow trees 
-PASS Firing an event at B1a with relatedNode at B1b1 with closed mode shadow trees 
-PASS Firing an event at B1b1 with relatedNode at B1a with open mode shadow trees 
-PASS Firing an event at B1b1 with relatedNode at B1a with closed mode shadow trees 
-PASS Firing an event at B1a with relatedNode at D1 with open mode shadow trees 
-PASS Firing an event at B1a with relatedNode at D1 with closed mode shadow trees 
-PASS Firing an event at D1 with relatedNode at B1a with open mode shadow trees 
-PASS Firing an event at D1 with relatedNode at B1a with closed mode shadow trees 
-PASS Firing an event at B1a with relatedNode at A1a with open mode shadow trees 
-PASS Firing an event at B1a with relatedNode at A1a with closed mode shadow trees 
-PASS Firing an event at B1a with relatedNode at A1a with open mode shadow trees 
-PASS Firing an event at B1a with relatedNode at A1a with closed mode shadow trees 
-PASS Firing an event at B1a with relatedNode at A1a with open mode shadow trees 
-PASS Firing an event at B1a with relatedNode at A1a with closed mode shadow trees 
-PASS Firing an event at B1a with relatedNode at A1a with open mode shadow trees 
-PASS Firing an event at B1a with relatedNode at A1a with closed mode shadow trees 
-
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomeventwithrelatedtargethtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/event-with-related-target.html (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/event-with-related-target.html        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/event-with-related-target.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,257 +0,0 @@
</span><del>-&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
-    &lt;title&gt;Shadow DOM: Firing an event with relatedTarget inside a shadow tree&lt;/title&gt;
-    &lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
-    &lt;meta name=&quot;assert&quot; content=&quot;The retargeting algorithm is used to determine relative targets&quot;&gt;
-    &lt;link rel=&quot;help&quot; href=&quot;https://w3c.github.io/webcomponents/spec/shadow/#retargeting-relatedtarget&quot;&gt;
-    &lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
-    &lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
-    &lt;script src=&quot;resources/event-path-test-helpers.js&quot;&gt;&lt;/script&gt;
-    &lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
-&lt;/head&gt;
-&lt;body&gt;
-    &lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
-    &lt;script&gt;
-
-        /*
-        -SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
-        A ----------------------------------------------- A-SR
-        + B ----------- B-SR (4)                          + A1 --- A1-SR
-          + C           + B1 (3) [*; 0-4] --- B1-SR (2)   + A2-S   + A1a
-          + D --- D-SR    + B1a (*; 0)        + B1b [1,2] --- B1b-SR
-                  + D1                        + B1c-S (1)     + B1b1
-                                                              + B1b2
-        */
-        function testEventAtB1aWithB1a(mode) {
-            test(function () {
-                var nodes = createTestTree(mode);
-
-                log = dispatchEventWithLog(nodes, nodes.B1a, new MouseEvent('foo', {bubbles: true, composed: true, relatedTarget: nodes.B1}));
-
-                assert_array_equals(log.eventPath,
-                    ['B1a', 'B1c-S', 'B1-SR', 'B1', 'B-SR'], 'The event path must be correct.');
-                assert_array_equals(log.relatedTargets,
-                    ['B1',  'B1',    'B1',    'B1', 'B1'], 'The related targets must be correct.');
-
-            }, 'Firing an event at B1a with relatedNode at B1 with ' + mode + ' mode shadow trees');
-        }
-
-        testEventAtB1aWithB1a('open');
-        testEventAtB1aWithB1a('closed');
-
-        /*
-        -SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
-        A ------------------------------------------------- A-SR
-        + B ----------- B-SR (4)                            + A1 --- A1-SR
-          + C           + B1 (3) [0,3-4] --- B1-SR (2)      + A2-S   + A1a
-          + D --- D-SR    + B1a (*; 0)       + B1b [1,2] --- B1b-SR
-                  + D1                       + B1c-S (1)     + B1b1 [*]
-                                                             + B1b2
-        */
-        function testEventAtB1aWithB1b1(mode) {
-            test(function () {
-                var nodes = createTestTree(mode);
-
-                log = dispatchEventWithLog(nodes, nodes.B1a, new MouseEvent('foo', {bubbles: true, composed: true, relatedTarget: nodes.B1b1}));
-
-                assert_array_equals(log.eventPath,
-                    ['B1a', 'B1c-S', 'B1-SR', 'B1', 'B-SR'], 'The event path must be correct.');
-                assert_array_equals(log.relatedTargets,
-                    ['B1',  'B1b',   'B1b',   'B1', 'B1'], 'The related targets must be correct.');
-
-            }, 'Firing an event at B1a with relatedNode at B1b1 with ' + mode + ' mode shadow trees');
-        }
-
-        testEventAtB1aWithB1b1('open');
-        testEventAtB1aWithB1b1('closed');
-
-        /*
-        -SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
-        A -------------------------------------------------- A-SR
-        + B ------------- B-SR (5)                           + A1 --- A1-SR
-          + C             + B1 (4) ------- B1-SR (3)         + A2-S   + A1a
-          + D --- D-SR    + B1a [*; 0-5]   + B1b (2) --- B1b-SR (1)
-                  + D1                     + B1c-S       + B1b1 (*; 0)
-                                                         + B1b2
-        */
-        function testEventAtB1b1WithB1a(mode) {
-            test(function () {
-                var nodes = createTestTree(mode);
-
-                log = dispatchEventWithLog(nodes, nodes.B1b1, new MouseEvent('foo', {bubbles: true, composed: true, relatedTarget: nodes.B1a}));
-
-                assert_array_equals(log.eventPath,
-                    ['B1b1', 'B1b-SR', 'B1b', 'B1-SR', 'B1', 'B-SR'], 'The event path must be correct.');
-                assert_array_equals(log.relatedTargets,
-                    ['B1a',  'B1a',    'B1a', 'B1a',   'B1a', 'B1a'], 'The related targets must be correct.');
-
-            }, 'Firing an event at B1b1 with relatedNode at B1a with ' + mode + ' mode shadow trees');
-        }
-
-        testEventAtB1b1WithB1a('open');
-        testEventAtB1b1WithB1a('closed');
-
-        /*
-        -SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
-        A (8) -------------------------------------------------- A-SR (7)
-        + B (5) -------------- B-SR (4)                          + A1 -------- A1-SR
-          + C                  + B1 (3) [*; 0-4] --- B1-SR (2)   + A2-S (6)    + A1a
-          + D [0-8] --- D-SR     + B1a (*; 0)        + B1b ------ B1b-SR
-                        + D1 [*]                     + B1c-S (1)  + B1b1
-                                                                  + B1b2
-        */
-        function testEventAtB1aWithD1(mode) {
-            test(function () {
-                var nodes = createTestTree(mode);
-
-                log = dispatchEventWithLog(nodes, nodes.B1a, new MouseEvent('foo', {bubbles: true, composed: true, relatedTarget: nodes.D1}));
-
-                assert_array_equals(log.eventPath,
-                    ['B1a', 'B1c-S', 'B1-SR', 'B1', 'B-SR', 'B', 'A2-S', 'A-SR', 'A'], 'The event path must be correct.');
-                assert_array_equals(log.relatedTargets,
-                    ['D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D'], 'The related targets must be correct.');
-
-            }, 'Firing an event at B1a with relatedNode at D1 with ' + mode + ' mode shadow trees');
-        }
-
-        testEventAtB1aWithD1('open');
-        testEventAtB1aWithD1('closed');
-
-        /*
-        -SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
-        A (6) ----------------------------------- A-SR (5)
-        + B (3) [0] ----------- B-SR              + A1 ------ A1-SR
-          + C                   + B1 ----- B1-SR  + A2-S (4)  + A1a
-          + D (2) --- D-SR (1)  + B1a [*]  + B1b --- B1b-SR
-                        + D1 (*; 0)         + B1c-S   + B1b1
-                                                      + B1b2
-        */
-        function testEventAtD1WithB1a(mode) {
-            test(function () {
-                var nodes = createTestTree(mode);
-
-                log = dispatchEventWithLog(nodes, nodes.D1, new MouseEvent('foo', {bubbles: true, composed: true, relatedTarget: nodes.B1a}));
-
-                assert_array_equals(log.eventPath,
-                    ['D1', 'D-SR', 'D', 'B', 'A2-S', 'A-SR', 'A'], 'The event path must be correct.');
-                assert_array_equals(log.relatedTargets,
-                    ['B', 'B', 'B', 'B', 'B', 'B', 'B'], 'The related targets must be correct.');
-
-            }, 'Firing an event at D1 with relatedNode at B1a with ' + mode + ' mode shadow trees');
-        }
-
-        testEventAtD1WithB1a('open');
-        testEventAtD1WithB1a('closed');
-
-        /*
-        -SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
-        A (8) [0-5,8] ---------------------------------------- A-SR (7)
-        + B (5)  ------- B-SR (4)                              + A1 [6,7] --- A1-SR
-          + C            + B1 (3) ----- B1-SR (2)              + A2-S (6)     + A1a [*]
-          + D --- D-SR   + B1a (*; 0)   + B1b ------- B1b-SR
-                  + D1                  + B1c-S (1)   + B1b1
-                                                      + B1b2
-        */
-        function testEventAtB1aWithA1a(mode) {
-            test(function () {
-                var nodes = createTestTree(mode);
-
-                log = dispatchEventWithLog(nodes, nodes.B1a, new MouseEvent('foo', {bubbles: true, composed: true, relatedTarget: nodes.A1a}));
-
-                assert_array_equals(log.eventPath,
-                    ['B1a', 'B1c-S', 'B1-SR', 'B1', 'B-SR', 'B', 'A2-S', 'A-SR', 'A'], 'The event path must be correct.');
-                assert_array_equals(log.relatedTargets,
-                    ['A',   'A',     'A',     'A',   'A',   'A', 'A1',   'A1',   'A'], 'The related targets must be correct.');
-
-            }, 'Firing an event at B1a with relatedNode at A1a with ' + mode + ' mode shadow trees');
-        }
-
-        testEventAtB1aWithA1a('open');
-        testEventAtB1aWithA1a('closed');
-
-        /*
-        -SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
-        A (4) ----------------------------------------- A-SR (3)
-        + B [0-4]  ----- B-SR                           + A1 (2) --- A1-SR (1)
-          + C            + B1 ------- B1-SR             + A2-S       + A1a (*; 0)
-          + D --- D-SR     + B1a [*]  + B1b --- B1b-SR
-                  + D1                + B1c-S   + B1b1
-                                                + B1b2
-        */
-        function testEventAtA1aWithB1a(mode) {
-            test(function () {
-                var nodes = createTestTree(mode);
-
-                log = dispatchEventWithLog(nodes, nodes.A1a, new MouseEvent('foo', {bubbles: true, composed: true, relatedTarget: nodes.B1a}));
-
-                assert_array_equals(log.eventPath,
-                    ['A1a', 'A1-SR', 'A1', 'A-SR', 'A'], 'The event path must be correct.');
-                assert_array_equals(log.relatedTargets,
-                    ['B', 'B', 'B', 'B', 'B'], 'The related targets must be correct.');
-
-            }, 'Firing an event at B1a with relatedNode at A1a with ' + mode + ' mode shadow trees');
-        }
-
-        testEventAtA1aWithB1a('open');
-        testEventAtA1aWithB1a('closed');
-
-        /*
-        -SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
-        A (8) ----------------------------------- A-SR (7)
-        + B (5)  ----- B-SR (4)                   + A2-S (6)
-          + C          + B1 (3) ----- B1-SR (2)
-          + D --- D-SR   + B1a (*; 0) + B1b ------- B1b-SR
-                  + D1                + B1c-S (1)   + B1b1
-                                                    + B1b2
-        A1 [0-6] --- A1-SR
-                   + A1a [*]
-        */
-        function testEventAtB1aWithDetachedA1a(mode) {
-            test(function () {
-                var nodes = createTestTree(mode);
-
-                nodes['A-SR'].removeChild(nodes.A1);
-                log = dispatchEventWithLog(nodes, nodes.B1a, new MouseEvent('foo', {bubbles: true, composed: true, relatedTarget: nodes.A1a}));
-
-                assert_array_equals(log.eventPath,
-                    ['B1a', 'B1c-S', 'B1-SR', 'B1', 'B-SR', 'B', 'A2-S', 'A-SR', 'A'], 'The event path must be correct.');
-                assert_array_equals(log.relatedTargets,
-                    ['A1', 'A1', 'A1', 'A1', 'A1', 'A1', 'A1', 'A1', 'A1'], 'The related targets must be correct.');
-
-            }, 'Firing an event at B1a with relatedNode at A1a with ' + mode + ' mode shadow trees');
-        }
-
-        testEventAtB1aWithDetachedA1a('open');
-        testEventAtB1aWithDetachedA1a('closed');
-
-        /*
-        -SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
-        A ----------------------------------- A-SR
-        + B [0-3]  ----- B-SR                 + A2-S
-          + C            + B1 -------- B1-SR
-          + D --- D-SR     + B1a [*]   + B1b --- B1b-SR
-                  + D1                 + B1c-S   + B1b1
-                                                 + B1b2
-        A1 (2) --- A1-SR (1)
-                   + A1a (*; 0)
-        */
-        function testEventAtA1aWithDetachedB1a(mode) {
-            test(function () {
-                var nodes = createTestTree(mode);
-
-                nodes['A-SR'].removeChild(nodes.A1);
-                log = dispatchEventWithLog(nodes, nodes.A1a, new MouseEvent('foo', {bubbles: true, composed: true, relatedTarget: nodes.B1a}));
-
-                assert_array_equals(log.eventPath,      ['A1a', 'A1-SR', 'A1'], 'The event path must be correct.');
-                assert_array_equals(log.relatedTargets, ['B',   'B',     'B' ], 'The related targets must be correct.');
-
-            }, 'Firing an event at B1a with relatedNode at A1a with ' + mode + ' mode shadow trees');
-        }
-
-        testEventAtA1aWithDetachedB1a('open');
-        testEventAtA1aWithDetachedB1a('closed');
-
-    &lt;/script&gt;
-    &lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomresourcesDocumentprototypecurrentScripthelperjs"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/resources/Document-prototype-currentScript-helper.js (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/resources/Document-prototype-currentScript-helper.js        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/resources/Document-prototype-currentScript-helper.js        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1 +0,0 @@
</span><del>-executeExternalScript();
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomslotchangeeventexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/slotchange-event-expected.txt (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/slotchange-event-expected.txt        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/slotchange-event-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,36 +0,0 @@
</span><del>-
-PASS slotchange event must fire on a default slot element inside an open shadow root  in a document 
-PASS slotchange event must fire on a default slot element inside a closed shadow root  in a document 
-PASS slotchange event must fire on a default slot element inside an open shadow root  not in a document 
-PASS slotchange event must fire on a default slot element inside a closed shadow root  not in a document 
-PASS slotchange event must fire on a named slot element insidean open shadow root  in a document 
-PASS slotchange event must fire on a named slot element insidea closed shadow root  in a document 
-PASS slotchange event must fire on a named slot element insidean open shadow root  not in a document 
-PASS slotchange event must fire on a named slot element insidea closed shadow root  not in a document 
-PASS slotchange event must not fire on a slot element inside an open shadow root  in a document when another slot's assigned nodes change 
-PASS slotchange event must not fire on a slot element inside a closed shadow root  in a document when another slot's assigned nodes change 
-PASS slotchange event must not fire on a slot element inside an open shadow root  not in a document when another slot's assigned nodes change 
-PASS slotchange event must not fire on a slot element inside a closed shadow root  not in a document when another slot's assigned nodes change 
-PASS slotchange event must not fire on a slot element inside an open shadow root  in a document when the shadow host was mutated before the slot was inserted or after the slot was removed 
-PASS slotchange event must not fire on a slot element inside a closed shadow root  in a document when the shadow host was mutated before the slot was inserted or after the slot was removed 
-PASS slotchange event must not fire on a slot element inside an open shadow root  not in a document when the shadow host was mutated before the slot was inserted or after the slot was removed 
-PASS slotchange event must not fire on a slot element inside a closed shadow root  not in a document when the shadow host was mutated before the slot was inserted or after the slot was removed 
-PASS slotchange event must fire on a slot element inside an open shadow root  in a document even if the slot was removed immediately after the assigned nodes were mutated 
-PASS slotchange event must fire on a slot element inside a closed shadow root  in a document even if the slot was removed immediately after the assigned nodes were mutated 
-PASS slotchange event must fire on a slot element inside an open shadow root  not in a document even if the slot was removed immediately after the assigned nodes were mutated 
-PASS slotchange event must fire on a slot element inside a closed shadow root  not in a document even if the slot was removed immediately after the assigned nodes were mutated 
-PASS slotchange event must fire on a slot element inside an open shadow root  in a document when innerHTML modifies the children of the shadow host 
-PASS slotchange event must fire on a slot element inside a closed shadow root  in a document when innerHTML modifies the children of the shadow host 
-PASS slotchange event must fire on a slot element inside an open shadow root  not in a document when innerHTML modifies the children of the shadow host 
-PASS slotchange event must fire on a slot element inside a closed shadow root  not in a document when innerHTML modifies the children of the shadow host 
-PASS slotchange event must fire on a slot element inside an open shadow root  in a document when nested slots's contents change 
-PASS slotchange event must fire on a slot element inside a closed shadow root  in a document when nested slots's contents change 
-PASS slotchange event must fire on a slot element inside an open shadow root  not in a document when nested slots's contents change 
-PASS slotchange event must fire on a slot element inside a closed shadow root  not in a document when nested slots's contents change 
-PASS slotchange event must fire at the end of current microtask after mutation observers are invoked inside an open shadow root  in a document when slots's contents change 
-PASS slotchange event must fire at the end of current microtask after mutation observers are invoked inside a closed shadow root  in a document when slots's contents change 
-PASS slotchange event must fire at the end of current microtask after mutation observers are invoked inside an open shadow root  not in a document when slots's contents change 
-PASS slotchange event must fire at the end of current microtask after mutation observers are invoked inside a closed shadow root  not in a document when slots's contents change 
-hello
-hello
-
</del></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomslotchangeeventhtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/shadow-dom/slotchange-event.html (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/slotchange-event.html        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/fast/shadow-dom/slotchange-event.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,619 +0,0 @@
</span><del>-&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
-&lt;title&gt;Shadow DOM: slotchange event&lt;/title&gt;
-&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
-&lt;script src=&quot;../../resources/testharness.js&quot;&gt;&lt;/script&gt;
-&lt;script src=&quot;../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
-&lt;link rel='stylesheet' href='../../resources/testharness.css'&gt;
-&lt;/head&gt;
-&lt;body&gt;
-&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
-&lt;script&gt;
-
-function treeName(mode, connectedToDocument)
-{
-    return (mode == 'open' ? 'an ' : 'a ') + mode + ' shadow root '
-        + (connectedToDocument ? '' : ' not') + ' in a document';
-}
-
-function testAppendingSpanToShadowRootWithDefaultSlot(mode, connectedToDocument)
-{
-    var test = async_test('slotchange event must fire on a default slot element inside '
-        + treeName(mode, connectedToDocument));
-
-    var host;
-    var slot;
-    var eventCount = 0;
-
-    test.step(function () {
-        host = document.createElement('div');
-        if (connectedToDocument)
-            document.body.appendChild(host);
-
-        var shadowRoot = host.attachShadow({'mode': mode});
-        slot = document.createElement('slot');
-
-        slot.addEventListener('slotchange', function (event) {
-            if (event.isFakeEvent)
-                return;
-
-            test.step(function () {
-                assert_equals(event.type, 'slotchange', 'slotchange event\'s type must be &quot;slotchange&quot;');
-                assert_equals(event.target, slot, 'slotchange event\'s target must be the slot element');
-                assert_equals(event.relatedTarget, undefined, 'slotchange must not set relatedTarget');
-            });
-            eventCount++;
-        });
-
-        shadowRoot.appendChild(slot);
-
-        host.appendChild(document.createElement('span'));
-        host.appendChild(document.createElement('b'));
-
-        assert_equals(eventCount, 0, 'slotchange event must not be fired synchronously');
-    });
-
-    setTimeout(function () {
-        test.step(function () {
-            assert_equals(eventCount, 1, 'slotchange must be fired exactly once after the assigned nodes changed');
-
-            host.appendChild(document.createElement('i'));
-        });
-
-        setTimeout(function () {
-            test.step(function () {
-                assert_equals(eventCount, 2, 'slotchange must be fired exactly once after the assigned nodes changed');
-
-                host.appendChild(document.createTextNode('hello'));
-
-                var fakeEvent = new Event('slotchange');
-                fakeEvent.isFakeEvent = true;
-                slot.dispatchEvent(fakeEvent);
-            });
-
-            setTimeout(function () {
-                test.step(function () {
-                    assert_equals(eventCount, 3, 'slotchange must be fired exactly once after the assigned nodes changed'
-                        + ' event if there was a synthetic slotchange event fired');
-                });
-                test.done();
-            }, 1);
-        }, 1);
-    }, 1);
-}
-
-testAppendingSpanToShadowRootWithDefaultSlot('open', true);
-testAppendingSpanToShadowRootWithDefaultSlot('closed', true);
-testAppendingSpanToShadowRootWithDefaultSlot('open', false);
-testAppendingSpanToShadowRootWithDefaultSlot('closed', false);
-
-function testAppendingSpanToShadowRootWithNamedSlot(mode, connectedToDocument)
-{
-    var test = async_test('slotchange event must fire on a named slot element inside'
-        + treeName(mode, connectedToDocument));
-
-    var host;
-    var slot;
-    var eventCount = 0;
-
-    test.step(function () {
-        host = document.createElement('div');
-        if (connectedToDocument)
-            document.body.appendChild(host);
-
-        var shadowRoot = host.attachShadow({'mode': mode});
-        slot = document.createElement('slot');
-        slot.name = 'someSlot';
-
-        slot.addEventListener('slotchange', function (event) {
-            if (event.isFakeEvent)
-                return;
-
-            test.step(function () {
-                assert_equals(event.type, 'slotchange', 'slotchange event\'s type must be &quot;slotchange&quot;');
-                assert_equals(event.target, slot, 'slotchange event\'s target must be the slot element');
-                assert_equals(event.relatedTarget, undefined, 'slotchange must not set relatedTarget');
-            });
-            eventCount++;
-        });
-
-        shadowRoot.appendChild(slot);
-
-        var span = document.createElement('span');
-        span.slot = 'someSlot';
-        host.appendChild(span);
-
-        var b = document.createElement('b');
-        b.slot = 'someSlot';
-        host.appendChild(b);
-
-        assert_equals(eventCount, 0, 'slotchange event must not be fired synchronously');
-    });
-
-    setTimeout(function () {
-        test.step(function () {
-            assert_equals(eventCount, 1, 'slotchange must be fired exactly once after the assigned nodes changed');
-
-            var i = document.createElement('i');
-            i.slot = 'someSlot';
-            host.appendChild(i);
-        });
-
-        setTimeout(function () {
-            test.step(function () {
-                assert_equals(eventCount, 2, 'slotchange must be fired exactly once after the assigned nodes changed');
-
-                var em = document.createElement('em');
-                em.slot = 'someSlot';
-                host.appendChild(em);
-
-                var fakeEvent = new Event('slotchange');
-                fakeEvent.isFakeEvent = true;
-                slot.dispatchEvent(fakeEvent);
-            });
-
-            setTimeout(function () {
-                test.step(function () {
-                    assert_equals(eventCount, 3, 'slotchange must be fired exactly once after the assigned nodes changed'
-                        + ' event if there was a synthetic slotchange event fired');
-                });
-                test.done();
-            }, 1);
-
-        }, 1);
-    }, 1);
-}
-
-testAppendingSpanToShadowRootWithNamedSlot('open', true);
-testAppendingSpanToShadowRootWithNamedSlot('closed', true);
-testAppendingSpanToShadowRootWithNamedSlot('open', false);
-testAppendingSpanToShadowRootWithNamedSlot('closed', false);
-
-function testSlotchangeDoesNotFireWhenOtherSlotsChange(mode, connectedToDocument)
-{
-    var test = async_test('slotchange event must not fire on a slot element inside '
-        + treeName(mode, connectedToDocument)
-        + ' when another slot\'s assigned nodes change');
-
-    var host;
-    var defaultSlotEventCount = 0;
-    var namedSlotEventCount = 0;
-
-    test.step(function () {
-        host = document.createElement('div');
-        if (connectedToDocument)
-            document.body.appendChild(host);
-
-        var shadowRoot = host.attachShadow({'mode': mode});
-        var defaultSlot = document.createElement('slot');
-        defaultSlot.addEventListener('slotchange', function (event) {
-            test.step(function () {
-                assert_equals(event.target, defaultSlot, 'slotchange event\'s target must be the slot element');
-            });
-            defaultSlotEventCount++;
-        });
-
-        var namedSlot = document.createElement('slot');
-        namedSlot.name = 'slotName';
-        namedSlot.addEventListener('slotchange', function (event) {
-            test.step(function () {
-                assert_equals(event.target, namedSlot, 'slotchange event\'s target must be the slot element');
-            });
-            namedSlotEventCount++;
-        });
-
-        shadowRoot.appendChild(defaultSlot);
-        shadowRoot.appendChild(namedSlot);
-
-        host.appendChild(document.createElement('span'));
-
-        assert_equals(defaultSlotEventCount, 0, 'slotchange event must not be fired synchronously');
-        assert_equals(namedSlotEventCount, 0, 'slotchange event must not be fired synchronously');
-    });
-
-    setTimeout(function () {
-        test.step(function () {
-            assert_equals(defaultSlotEventCount, 1,
-                'slotchange must be fired exactly once after the assigned nodes change on a default slot');
-            assert_equals(namedSlotEventCount, 0,
-                'slotchange must not be fired on a named slot after the assigned nodes change on a default slot');
-
-            var span = document.createElement('span');
-            span.slot = 'slotName';
-            host.appendChild(span);
-        });
-
-        setTimeout(function () {
-            test.step(function () {
-                assert_equals(defaultSlotEventCount, 1,
-                    'slotchange must not be fired on a default slot after the assigned nodes change on a named slot');
-                assert_equals(namedSlotEventCount, 1,
-                    'slotchange must be fired exactly once after the assigned nodes change on a default slot');
-            });
-            test.done();
-        }, 1);
-    }, 1);
-}
-
-testSlotchangeDoesNotFireWhenOtherSlotsChange('open', true);
-testSlotchangeDoesNotFireWhenOtherSlotsChange('closed', true);
-testSlotchangeDoesNotFireWhenOtherSlotsChange('open', false);
-testSlotchangeDoesNotFireWhenOtherSlotsChange('closed', false);
-
-function testSlotchangeDoesNotFireForMutationBeforeOrAfterSlotWasPresent(mode, connectedToDocument)
-{
-    var test = async_test('slotchange event must not fire on a slot element inside '
-        + treeName(mode, connectedToDocument)
-        + ' when the shadow host was mutated before the slot was inserted or after the slot was removed');
-
-    var host;
-    var slot;
-    var eventCount = 0;
-
-    test.step(function () {
-        host = document.createElement('div');
-        if (connectedToDocument)
-            document.body.appendChild(host);
-
-        var shadowRoot = host.attachShadow({'mode': mode});
-        slot = document.createElement('slot');
-        slot.addEventListener('slotchange', function (event) {
-            test.step(function () {
-                assert_equals(event.target, slot, 'slotchange event\'s target must be the slot element');
-            });
-            eventCount++;
-        });
-
-        host.appendChild(document.createElement('span'));
-        shadowRoot.appendChild(slot);
-
-        assert_equals(eventCount, 0, 'slotchange event must not be fired synchronously');
-    });
-
-    setTimeout(function () {
-        test.step(function () {
-            assert_equals(eventCount, 0,
-                'slotchange must not be fired on a slot element if the assigned nodes changed before the slot was inserted');
-            host.removeChild(host.firstChild);
-        });
-
-        setTimeout(function () {
-            test.step(function () {
-                assert_equals(eventCount, 1,
-                    'slotchange must be fired exactly once after the assigned nodes change on a slot while the slot element was in the tree');
-                slot.parentNode.removeChild(slot);
-                host.appendChild(document.createElement('span'));
-            });
-
-            setTimeout(function () {
-                assert_equals(eventCount, 1,
-                    'slotchange must not be fired on a slot element if the assigned nodes changed after the slot was removed');
-                test.done();
-            }, 1);
-        }, 1);
-    }, 1);
-}
-
-testSlotchangeDoesNotFireForMutationBeforeOrAfterSlotWasPresent('open', true);
-testSlotchangeDoesNotFireForMutationBeforeOrAfterSlotWasPresent('closed', true);
-testSlotchangeDoesNotFireForMutationBeforeOrAfterSlotWasPresent('open', false);
-testSlotchangeDoesNotFireForMutationBeforeOrAfterSlotWasPresent('closed', false);
-
-function testSlotchangeFiresOnTransientlyPresentSlot(mode, connectedToDocument)
-{
-    var test = async_test('slotchange event must fire on a slot element inside '
-        + treeName(mode, connectedToDocument)
-        + ' even if the slot was removed immediately after the assigned nodes were mutated');
-
-    var host;
-    var slot;
-    var anotherSlot;
-    var slotEventCount = 0;
-    var anotherSlotEventCount = 0;
-
-    test.step(function () {
-        host = document.createElement('div');
-        if (connectedToDocument)
-            document.body.appendChild(host);
-
-        var shadowRoot = host.attachShadow({'mode': mode});
-        slot = document.createElement('slot');
-        slot.name = 'someSlot';
-        slot.addEventListener('slotchange', function (event) {
-            test.step(function () {
-                assert_equals(event.target, slot, 'slotchange event\'s target must be the slot element');
-            });
-            slotEventCount++;
-        });
-
-        anotherSlot = document.createElement('slot');
-        anotherSlot.name = 'someSlot';
-        anotherSlot.addEventListener('slotchange', function (event) {
-            test.step(function () {
-                assert_equals(event.target, anotherSlot, 'slotchange event\'s target must be the slot element');
-            });
-            anotherSlotEventCount++;
-        });
-
-        shadowRoot.appendChild(slot);
-
-        var span = document.createElement('span');
-        span.slot = 'someSlot';
-        host.appendChild(span);
-
-        shadowRoot.removeChild(slot);
-        shadowRoot.appendChild(anotherSlot);
-
-        var span = document.createElement('span');
-        span.slot = 'someSlot';
-        host.appendChild(span);
-
-        shadowRoot.removeChild(anotherSlot);
-
-        assert_equals(slotEventCount, 0, 'slotchange event must not be fired synchronously');
-        assert_equals(anotherSlotEventCount, 0, 'slotchange event must not be fired synchronously');
-    });
-
-    setTimeout(function () {
-        test.step(function () {
-            assert_equals(slotEventCount, 1,
-                'slotchange must be fired on a slot element if the assigned nodes changed while the slot was present');
-            assert_equals(anotherSlotEventCount, 1,
-                'slotchange must be fired on a slot element if the assigned nodes changed while the slot was present');
-        });
-        test.done();
-    }, 1);
-}
-
-testSlotchangeFiresOnTransientlyPresentSlot('open', true);
-testSlotchangeFiresOnTransientlyPresentSlot('closed', true);
-testSlotchangeFiresOnTransientlyPresentSlot('open', false);
-testSlotchangeFiresOnTransientlyPresentSlot('closed', false);
-
-function testSlotchangeFiresOnInnerHTML(mode, connectedToDocument)
-{
-    var test = async_test('slotchange event must fire on a slot element inside '
-        + treeName(mode, connectedToDocument)
-        + ' when innerHTML modifies the children of the shadow host');
-
-    var host;
-    var defaultSlot;
-    var namedSlot;
-    var defaultSlotEventCount = 0;
-    var namedSlotEventCount = 0;
-
-    test.step(function () {
-        host = document.createElement('div');
-        if (connectedToDocument)
-            document.body.appendChild(host);
-
-        var shadowRoot = host.attachShadow({'mode': mode});
-        defaultSlot = document.createElement('slot');
-        defaultSlot.addEventListener('slotchange', function (event) {
-            test.step(function () {
-                assert_equals(event.target, defaultSlot, 'slotchange event\'s target must be the slot element');
-            });
-            defaultSlotEventCount++;
-        });
-
-        namedSlot = document.createElement('slot');
-        namedSlot.name = 'someSlot';
-        namedSlot.addEventListener('slotchange', function (event) {
-            test.step(function () {
-                assert_equals(event.target, namedSlot, 'slotchange event\'s target must be the slot element');
-            });
-            namedSlotEventCount++;
-        });
-        shadowRoot.appendChild(namedSlot);
-        shadowRoot.appendChild(defaultSlot);
-        host.innerHTML = 'foo &lt;b&gt;bar&lt;/b&gt;';
-
-        assert_equals(defaultSlotEventCount, 0, 'slotchange event must not be fired synchronously');
-        assert_equals(namedSlotEventCount, 0, 'slotchange event must not be fired synchronously');
-    });
-
-    setTimeout(function () {
-        test.step(function () {
-            assert_equals(defaultSlotEventCount, 1,
-                'slotchange must be fired on a slot element if the assigned nodes are changed by innerHTML');
-            assert_equals(namedSlotEventCount, 0,
-                'slotchange must not be fired on a slot element if the assigned nodes are not changed by innerHTML');
-            host.innerHTML = 'baz';
-        });
-        setTimeout(function () {
-            test.step(function () {
-                assert_equals(defaultSlotEventCount, 2,
-                    'slotchange must be fired on a slot element if the assigned nodes are changed by innerHTML');
-                assert_equals(namedSlotEventCount, 0,
-                    'slotchange must not be fired on a slot element if the assigned nodes are not changed by innerHTML');
-                host.innerHTML = '';
-            });
-            setTimeout(function () {
-                test.step(function () {
-                    assert_equals(defaultSlotEventCount, 3,
-                        'slotchange must be fired on a slot element if the assigned nodes are changed by innerHTML');
-                    assert_equals(namedSlotEventCount, 0,
-                        'slotchange must not be fired on a slot element if the assigned nodes are not changed by innerHTML');
-                    host.innerHTML = '&lt;b slot=&quot;someSlot&quot;&gt;content&lt;/b&gt;';
-                });
-                setTimeout(function () {
-                    test.step(function () {
-                        assert_equals(defaultSlotEventCount, 3,
-                            'slotchange must not be fired on a slot element if the assigned nodes are not changed by innerHTML');
-                        assert_equals(namedSlotEventCount, 1,
-                            'slotchange must not be fired on a slot element if the assigned nodes are changed by innerHTML');
-                        host.innerHTML = '';
-                    });
-                    setTimeout(function () {
-                        test.step(function () {
-                            // FIXME: This test would fail in the current implementation because we can't tell
-                            // whether a text node was removed in AllChildrenRemoved or not.
-//                            assert_equals(defaultSlotEventCount, 3,
-//                                'slotchange must not be fired on a slot element if the assigned nodes are not changed by innerHTML');
-                            assert_equals(namedSlotEventCount, 2,
-                                'slotchange must not be fired on a slot element if the assigned nodes are changed by innerHTML');
-                        });
-                        test.done();
-                    }, 1);
-                }, 1);
-            }, 1);
-        }, 1);
-    }, 1);
-}
-
-testSlotchangeFiresOnInnerHTML('open', true);
-testSlotchangeFiresOnInnerHTML('closed', true);
-testSlotchangeFiresOnInnerHTML('open', false);
-testSlotchangeFiresOnInnerHTML('closed', false);
-
-function testSlotchangeFiresWhenNestedSlotChange(mode, connectedToDocument)
-{
-    var test = async_test('slotchange event must fire on a slot element inside '
-        + treeName(mode, connectedToDocument)
-        + ' when nested slots\'s contents change');
-
-    var outerHost;
-    var innerHost;
-    var outerSlot;
-    var innerSlot;
-    var outerSlotEventCount = 0;
-    var innerSlotEventCount = 0;
-
-    test.step(function () {
-        outerHost = document.createElement('div');
-        if (connectedToDocument)
-            document.body.appendChild(outerHost);
-
-        var outerShadow = outerHost.attachShadow({'mode': mode});
-        outerShadow.appendChild(document.createElement('span'));
-        outerSlot = document.createElement('slot');
-        outerSlot.addEventListener('slotchange', function (event) {
-            event.stopPropagation();
-            test.step(function () {
-                assert_equals(event.target, outerSlot, 'slotchange event\'s target must be the slot element');
-            });
-            outerSlotEventCount++;
-        });
-
-        innerHost = document.createElement('div');
-        innerHost.appendChild(outerSlot);
-        outerShadow.appendChild(innerHost);
-
-        var innerShadow = innerHost.attachShadow({'mode': mode});
-        innerShadow.appendChild(document.createElement('span'));
-        innerSlot = document.createElement('slot');
-        innerSlot.addEventListener('slotchange', function (event) {
-            event.stopPropagation();
-            test.step(function () {
-                assert_equals(event.target, innerSlot, 'slotchange event\'s target must be the slot element');
-            });
-            innerSlotEventCount++;
-        });
-        innerShadow.appendChild(innerSlot);
-
-        outerHost.appendChild(document.createElement('span'));
-
-        assert_equals(innerSlotEventCount, 0, 'slotchange event must not be fired synchronously');
-        assert_equals(outerSlotEventCount, 0, 'slotchange event must not be fired synchronously');
-    });
-
-    setTimeout(function () {
-        test.step(function () {
-            assert_equals(innerSlotEventCount, 1,
-                'slotchange must be fired on a slot element if the assigned nodes changed');
-            assert_equals(outerSlotEventCount, 1,
-                'slotchange must be fired on a slot element if the assigned nodes of an inner slot changed');
-        });
-        test.done();
-    }, 1);
-}
-
-testSlotchangeFiresWhenNestedSlotChange('open', true);
-testSlotchangeFiresWhenNestedSlotChange('closed', true);
-testSlotchangeFiresWhenNestedSlotChange('open', false);
-testSlotchangeFiresWhenNestedSlotChange('closed', false);
-
-function testSlotchangeFiresAtEndOfMicroTask(mode, connectedToDocument)
-{
-    var test = async_test('slotchange event must fire at the end of current microtask after mutation observers are invoked inside '
-        + treeName(mode, connectedToDocument) + ' when slots\'s contents change');
-
-    var outerHost;
-    var innerHost;
-    var outerSlot;
-    var innerSlot;
-    var slotchangeEvents = [];
-
-    test.step(function () {
-        outerHost = document.createElement('div');
-        if (connectedToDocument)
-            document.body.appendChild(outerHost);
-
-        var outerShadow = outerHost.attachShadow({'mode': mode});
-        outerShadow.appendChild(document.createElement('span'));
-        outerSlot = document.createElement('slot');
-        outerSlot.addEventListener('slotchange', function (event) {
-            event.stopPropagation();
-            test.step(function () {
-                assert_equals(event.target, outerSlot, 'slotchange event\'s target must be the slot element');
-            });
-            slotchangeEvents.push('outer');
-        });
-
-        innerHost = document.createElement('div');
-        innerHost.appendChild(outerSlot);
-        outerShadow.appendChild(innerHost);
-
-        var innerShadow = innerHost.attachShadow({'mode': mode});
-        innerShadow.appendChild(document.createElement('span'));
-        innerSlot = document.createElement('slot');
-        innerSlot.addEventListener('slotchange', function (event) {
-            event.stopPropagation();
-            test.step(function () {
-                assert_equals(event.target, innerSlot, 'slotchange event\'s target must be the slot element');
-            });
-            slotchangeEvents.push('inner');
-        });
-        innerShadow.appendChild(innerSlot);
-
-        outerHost.appendChild(document.createElement('span'));
-
-        assert_equals(slotchangeEvents.length, 0, 'slotchange event must not be fired synchronously');
-    });
-
-    var element = document.createElement('div');
-
-    new MutationObserver(function () {
-        test.step(function () {
-            assert_equals(slotchangeEvents.length, 0, 'slotchange event must not be fired before mutation records are delivered');
-        });
-        element.setAttribute('title', 'bar');
-        innerHost.appendChild(document.createElement('span'));
-    }).observe(element, {attributes: true, attributeFilter: ['id']});
-
-    new MutationObserver(function () {
-        test.step(function () {
-            assert_array_equals(slotchangeEvents, ['outer', 'inner'], 'slotchange event must be fired during a single compound microtask');
-        });
-    }).observe(element, {attributes: true, attributeFilter: ['title']});
-
-    element.setAttribute('id', 'foo');
-
-    setTimeout(function () {
-        test.step(function () {
-            assert_array_equals(slotchangeEvents, ['outer', 'inner', 'inner'],
-                'a distinct slotchange event must be enqueued for changes made during a mutation observer delivery');
-        });
-        test.done();
-    }, 0);
-}
-
-testSlotchangeFiresAtEndOfMicroTask('open', true);
-testSlotchangeFiresAtEndOfMicroTask('closed', true);
-testSlotchangeFiresAtEndOfMicroTask('open', false);
-testSlotchangeFiresAtEndOfMicroTask('closed', false);
-
-&lt;/script&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,3 +1,74 @@
</span><ins>+2016-09-27  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Import w3c shadow DOM tests and fix one assertion
+        https://bugs.webkit.org/show_bug.cgi?id=162629
+
+        Reviewed by Chris Dumez.
+
+        Import shadow DOM tests in web-platform-tests as of 7163d6eeed81e9e020545fbe0c4b11fc2c5963cd
+        except untriaged tests for v0 API, which we obviously don't implement.
+
+        Most of these tests are the ones we upstreamed from fast/shadow-dom/.
+
+        * web-platform-tests/shadow-dom/Document-prototype-adoptNode-expected.txt: Renamed from LayoutTests/fast/shadow-dom/Document-prototype-adoptNode-expected.txt.
+        * web-platform-tests/shadow-dom/Document-prototype-adoptNode.html: Renamed from LayoutTests/fast/shadow-dom/Document-prototype-adoptNode.html.
+        * web-platform-tests/shadow-dom/Document-prototype-currentScript-expected.txt: Renamed from LayoutTests/fast/shadow-dom/Document-prototype-currentScript-expected.txt.
+        * web-platform-tests/shadow-dom/Document-prototype-currentScript.html: Renamed from LayoutTests/fast/shadow-dom/Document-prototype-currentScript.html.
+        * web-platform-tests/shadow-dom/Document-prototype-importNode-expected.txt: Renamed from LayoutTests/fast/shadow-dom/Document-prototype-importNode-expected.txt.
+        * web-platform-tests/shadow-dom/Document-prototype-importNode.html: Renamed from LayoutTests/fast/shadow-dom/Document-prototype-importNode.html.
+        * web-platform-tests/shadow-dom/Element-interface-attachShadow-expected.txt: Added.
+        * web-platform-tests/shadow-dom/Element-interface-attachShadow.html: Renamed from LayoutTests/fast/shadow-dom/Element-interface-attachShadow.html.
+        * web-platform-tests/shadow-dom/Element-interface-shadowRoot-attribute-expected.txt: Renamed from LayoutTests/fast/shadow-dom/Element-interface-shadowRoot-attribute-expected.txt.
+        * web-platform-tests/shadow-dom/Element-interface-shadowRoot-attribute.html: Renamed from LayoutTests/fast/shadow-dom/Element-interface-shadowRoot-attribute.html.
+        * web-platform-tests/shadow-dom/Extensions-to-Event-Interface-expected.txt: Renamed from LayoutTests/fast/shadow-dom/Extensions-to-Event-Interface-expected.txt.
+        * web-platform-tests/shadow-dom/Extensions-to-Event-Interface.html: Renamed from LayoutTests/fast/shadow-dom/Extensions-to-Event-Interface.html.
+        * web-platform-tests/shadow-dom/HTMLSlotElement-interface-expected.txt: Renamed from LayoutTests/fast/shadow-dom/HTMLSlotElement-interface-expected.txt.
+        * web-platform-tests/shadow-dom/HTMLSlotElement-interface.html: Renamed from LayoutTests/fast/shadow-dom/HTMLSlotElement-interface.html.
+        * web-platform-tests/shadow-dom/MouseEvent-prototype-offsetX-offsetY-expected.txt: Renamed from LayoutTests/fast/shadow-dom/MouseEvent-prototype-offsetX-offsetY-expected.txt.
+        * web-platform-tests/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html: Renamed from LayoutTests/fast/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html.
+        * web-platform-tests/shadow-dom/Node-prototype-cloneNode-expected.txt: Added.
+        * web-platform-tests/shadow-dom/Node-prototype-cloneNode.html: Renamed from LayoutTests/fast/shadow-dom/Node-prototype-cloneNode.html.
+        * web-platform-tests/shadow-dom/OWNERS: Added.
+        * web-platform-tests/shadow-dom/ShadowRoot-interface-expected.txt: Renamed from LayoutTests/fast/shadow-dom/ShadowRoot-interface-expected.txt.
+        * web-platform-tests/shadow-dom/ShadowRoot-interface.html: Renamed from LayoutTests/fast/shadow-dom/ShadowRoot-interface.html.
+        * web-platform-tests/shadow-dom/Slotable-interface-expected.txt: Renamed from LayoutTests/fast/shadow-dom/Slotable-interface-assignedSlot-expected.txt.
+        * web-platform-tests/shadow-dom/Slotable-interface.html: Renamed from LayoutTests/fast/shadow-dom/Slotable-interface-assignedSlot.html.
+        * web-platform-tests/shadow-dom/event-composed-expected.txt: Added.
+        * web-platform-tests/shadow-dom/event-composed-path-expected.txt: Added.
+        * web-platform-tests/shadow-dom/event-composed-path-with-related-target-expected.txt: Added.
+        * web-platform-tests/shadow-dom/event-composed-path-with-related-target.html: Added.
+        * web-platform-tests/shadow-dom/event-composed-path.html: Added.
+        * web-platform-tests/shadow-dom/event-composed.html: Added.
+        * web-platform-tests/shadow-dom/event-inside-shadow-tree-expected.txt: Renamed from LayoutTests/fast/shadow-dom/event-inside-shadow-tree-expected.txt.
+        * web-platform-tests/shadow-dom/event-inside-shadow-tree.html: Renamed from LayoutTests/fast/shadow-dom/event-inside-shadow-tree.html.
+        * web-platform-tests/shadow-dom/event-inside-slotted-node-expected.txt: Renamed from LayoutTests/fast/shadow-dom/event-inside-slotted-node-expected.txt.
+        * web-platform-tests/shadow-dom/event-inside-slotted-node.html: Renamed from LayoutTests/fast/shadow-dom/event-inside-slotted-node.html.
+        * web-platform-tests/shadow-dom/event-with-related-target-expected.txt: Renamed from LayoutTests/fast/shadow-dom/event-with-related-target-expected.txt.
+        * web-platform-tests/shadow-dom/event-with-related-target.html: Renamed from LayoutTests/fast/shadow-dom/event-with-related-target.html.
+        * web-platform-tests/shadow-dom/leaktests/get-elements-expected.txt: Added.
+        * web-platform-tests/shadow-dom/leaktests/get-elements.html: Added.
+        * web-platform-tests/shadow-dom/leaktests/html-collection-expected.txt: Added.
+        * web-platform-tests/shadow-dom/leaktests/html-collection.html: Added.
+        * web-platform-tests/shadow-dom/leaktests/w3c-import.log: Added.
+        * web-platform-tests/shadow-dom/leaktests/window-frames-expected.txt: Added.
+        * web-platform-tests/shadow-dom/leaktests/window-frames.html: Added.
+        * web-platform-tests/shadow-dom/resources/Document-prototype-currentScript-helper.js: Renamed from LayoutTests/fast/shadow-dom/resources/Document-prototype-currentScript-helper.js.
+        * web-platform-tests/shadow-dom/resources/event-path-test-helpers.js: Added.
+        * web-platform-tests/shadow-dom/resources/shadow-dom-utils.js: Added.
+        * web-platform-tests/shadow-dom/resources/shadow-dom.js: Added.
+        * web-platform-tests/shadow-dom/resources/w3c-import.log: Added.
+        * web-platform-tests/shadow-dom/scroll-to-the-fragment-in-shadow-tree-expected.txt: Added.
+        * web-platform-tests/shadow-dom/scroll-to-the-fragment-in-shadow-tree.html: Added.
+        * web-platform-tests/shadow-dom/slotchange-event-expected.txt: Renamed from LayoutTests/fast/shadow-dom/slotchange-event-expected.txt.
+        * web-platform-tests/shadow-dom/slotchange-event.html: Renamed from LayoutTests/fast/shadow-dom/slotchange-event.html.
+        * web-platform-tests/shadow-dom/slotchange-expected.txt: Added.
+        * web-platform-tests/shadow-dom/slotchange.html: Added.
+        * web-platform-tests/shadow-dom/slots-expected.txt: Added.
+        * web-platform-tests/shadow-dom/slots-fallback-expected.txt: Added.
+        * web-platform-tests/shadow-dom/slots-fallback.html: Added.
+        * web-platform-tests/shadow-dom/slots.html: Added.
+        * web-platform-tests/shadow-dom/w3c-import.log: Added.
+
</ins><span class="cx"> 2016-09-27  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         It should be possible to dispatch events on documents that do not have a browsing context
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomDocumentprototypeadoptNodeexpectedtxtfromrev206462trunkLayoutTestsfastshadowdomDocumentprototypeadoptNodeexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-adoptNode-expected.txt (from rev 206462, trunk/LayoutTests/fast/shadow-dom/Document-prototype-adoptNode-expected.txt) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-adoptNode-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-adoptNode-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+
+PASS adoptNode on a shadow root in open mode must throw a HierarchyRequestError 
+PASS adoptNode on a shadow root in closed mode must throw a HierarchyRequestError 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomDocumentprototypeadoptNodehtmlfromrev206462trunkLayoutTestsfastshadowdomDocumentprototypeadoptNodehtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-adoptNode.html (from rev 206462, trunk/LayoutTests/fast/shadow-dom/Document-prototype-adoptNode.html) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-adoptNode.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-adoptNode.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;DOM and Shadow DOM: Document.prototype.adoptNode&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;The adoptNode(node) method must throw a HierarchyRequestError exception if node is a shadow root.&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;https://dom.spec.whatwg.org/#dom-document-adoptnode&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+function testAdoptNode(mode) {
+    test(function () {
+        var newDocument = document.implementation.createHTMLDocument();
+        assert_throws({'name': 'HierarchyRequestError'}, function () {
+            var element = document.createElement('div');
+            var shadowRoot = element.attachShadow({mode: mode});
+            newDocument.adoptNode(shadowRoot);
+        });
+    }, 'adoptNode on a shadow root in ' + mode + ' mode must throw a HierarchyRequestError');
+}
+
+testAdoptNode('open');
+testAdoptNode('closed');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomDocumentprototypecurrentScriptexpectedtxtfromrev206462trunkLayoutTestsfastshadowdomDocumentprototypecurrentScriptexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-currentScript-expected.txt (from rev 206462, trunk/LayoutTests/fast/shadow-dom/Document-prototype-currentScript-expected.txt) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-currentScript-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-currentScript-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+CONSOLE MESSAGE: line 2422: Error: assert_equals: expected null but got Element node &lt;script id=&quot;outerScriptElement&quot;&gt;
+
+var outerScriptElement ...
+CONSOLE MESSAGE: line 2422: Error: assert_equals: expected null but got Element node &lt;script id=&quot;outerScriptElement&quot;&gt;
+
+var outerScriptElement ...
+
+Harness Error (FAIL), message = Error: assert_equals: expected null but got Element node &lt;script id=&quot;outerScriptElement&quot;&gt;
+
+var outerScriptElement ...
+
+PASS document.currentScript must not to be set to a script element in a shadow tree in open mode 
+PASS document.currentScript must not to be set to a script element in a shadow tree in closed mode 
+PASS document.currentScript must be set to a script element that loads an external script in a document tree 
+PASS document.currentScript must be set to a script element that loads an external script in a document tree 
+PASS document.currentScript must not be set to a script element that loads an external script in an open shadow tree 
+PASS document.currentScript must not be set to a script element that loads an external script in a closed shadow tree 
+PASS document.currentScript must be set to a script element that loads an external script that was in an open shadow tree and then removed 
+PASS document.currentScript must be set to a script element that loads an external script that was in a closed shadow tree and then removed 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomDocumentprototypecurrentScripthtmlfromrev206462trunkLayoutTestsfastshadowdomDocumentprototypecurrentScripthtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-currentScript.html (from rev 206462, trunk/LayoutTests/fast/shadow-dom/Document-prototype-currentScript.html) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-currentScript.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-currentScript.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,98 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;HTML: Document.prototype.currentScript&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;If the script element is in a document, then set the script element's node document's currentScript attribute to the script element.&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;https://html.spec.whatwg.org/multipage/scripting.html#execute-the-script-block&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script id=&quot;outerScriptElement&quot;&gt;
+
+var outerScriptElement = document.currentScript;
+
+function testInlineScript(mode)
+{
+    test(function () {
+        var host = document.createElement('div');
+        var shadowRoot = host.attachShadow({mode: mode});
+        var scriptElement = document.createElement('script');
+        scriptElement.textContent = 'assert_equals(document.currentScript, null)';
+        shadowRoot.appendChild(scriptElement);
+
+        assert_equals(document.currentScript, outerScriptElement,
+            'document.currentScript must be set to the currently excusing script element in a document tree before executing a script in a shadow tree');
+        document.body.appendChild(host);
+        assert_equals(document.currentScript, outerScriptElement,
+            'document.currentScript must be set to the currently excusing script element in a document tree after executing a script in a shadow tree');
+
+    }, 'document.currentScript must not to be set to a script element in a shadow tree in ' + mode + ' mode');
+}
+
+testInlineScript('open');
+testInlineScript('closed');
+
+var executeExternalScript = null;
+var testedScriptElement = null;
+function executeNextTest()
+{
+    var testCase = asyncScriptTests.shift();
+    var mode = testCase.mode;
+    if (!testCase)
+        return;
+
+    testCase.test.step(function () {
+        testedScriptElement = document.createElement('script');
+        testedScriptElement.src = 'resources/Document-prototype-currentScript-helper.js';
+
+        if (mode !== null) {
+            var host = document.createElement('div');
+            var shadowRoot = host.attachShadow({mode: mode});
+            shadowRoot.appendChild(testedScriptElement);
+            document.body.appendChild(host);
+        } else {
+            document.body.appendChild(testedScriptElement);
+        }
+
+        if (testCase.remove)
+            testedScriptElement.parentNode.removeChild(testedScriptElement);
+    });
+
+    executeExternalScript = function () {
+        testCase.test.step(function () {
+            assert_equals(document.currentScript, testCase.expected());
+        });
+        testCase.test.done();
+        setTimeout(executeNextTest, 1);
+    }
+}
+
+var asyncScriptTests = [
+    {
+        test: async_test('document.currentScript must be set to a script element that loads an external script in a document tree'),
+        mode: null, remove: false, expected: function () { return testedScriptElement; }},
+    {
+        test: async_test('document.currentScript must be set to a script element that loads an external script in a document tree'),
+        mode: null, remove: true, expected: function () { return testedScriptElement; }},
+    {
+        test: async_test('document.currentScript must not be set to a script element that loads an external script in an open shadow tree'),
+        mode: 'open', remove: false, expected: function () { return null; }},
+    {
+        test: async_test('document.currentScript must not be set to a script element that loads an external script in a closed shadow tree'),
+        mode: 'closed', remove: false, expected: function () { return null; }},
+    {
+        test: async_test('document.currentScript must be set to a script element that loads an external script that was in an open shadow tree and then removed'),
+        mode: 'open', remove: true, expected: function () { return testedScriptElement; }},
+    {
+        test: async_test('document.currentScript must be set to a script element that loads an external script that was in a closed shadow tree and then removed'),
+        mode: 'closed', remove: true, expected: function () { return testedScriptElement; }},
+];
+
+executeNextTest();
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomDocumentprototypeimportNodeexpectedtxtfromrev206462trunkLayoutTestsfastshadowdomDocumentprototypeimportNodeexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-importNode-expected.txt (from rev 206462, trunk/LayoutTests/fast/shadow-dom/Document-prototype-importNode-expected.txt) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-importNode-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-importNode-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+
+PASS importNode on a shadow root in open mode must throw a NotSupportedError 
+PASS importNode on a shadow root in closed mode must throw a NotSupportedError 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomDocumentprototypeimportNodehtmlfromrev206462trunkLayoutTestsfastshadowdomDocumentprototypeimportNodehtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-importNode.html (from rev 206462, trunk/LayoutTests/fast/shadow-dom/Document-prototype-importNode.html) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-importNode.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-importNode.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;DOM and Shadow DOM: Document.prototype.importNode&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;The importNode(node, deep) method must throw a NotSupportedError exception if node is a shadow root.&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;https://dom.spec.whatwg.org/#dom-document-importnode&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+function testImportNode(mode) {
+    test(function () {
+        var newDocument = document.implementation.createHTMLDocument();
+        assert_throws({'name': 'NotSupportedError'}, function () {
+            var element = document.createElement('div');
+            var shadowRoot = element.attachShadow({mode: mode});
+            newDocument.importNode(shadowRoot);
+        });
+    }, 'importNode on a shadow root in ' + mode + ' mode must throw a NotSupportedError');
+}
+
+testImportNode('open');
+testImportNode('closed');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomElementinterfaceattachShadowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-attachShadow-expected.txt (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-attachShadow-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-attachShadow-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+
+PASS Check the existence of Element.attachShadow 
+PASS Nodes other than Element should not have attachShadow 
+PASS Element.attachShadow must throw a TypeError if mode is not &quot;open&quot; or &quot;closed&quot; 
+PASS Element.attachShadow must create an instance of ShadowRoot 
+PASS Element.attachShadow must throw a InvalidStateError if the context object already hosts a shadow tree 
+PASS Element.attachShadow must throw a NotSupportedError for button, details, input, marquee, meter, progress, select, textarea, and keygen elements 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomElementinterfaceattachShadowhtmlfromrev206462trunkLayoutTestsfastshadowdomElementinterfaceattachShadowhtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-attachShadow.html (from rev 206462, trunk/LayoutTests/fast/shadow-dom/Element-interface-attachShadow.html) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-attachShadow.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-attachShadow.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,94 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;Shadow DOM: Attaching a ShadowRoot&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;Element.prototype.attachShadow should create an instance of ShadowRoot&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;https://w3c.github.io/webcomponents/spec/shadow/#widl-Element-attachShadow-ShadowRoot-ShadowRootInit-shadowRootInitDict&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+test(function () {
+    assert_true('attachShadow' in Element.prototype, 'Element.prototype.attachShadow must exist');
+    assert_equals(typeof(document.createElement('div').attachShadow), 'function', 'An instance of div must have attachShadow which is a function');
+}, 'Check the existence of Element.attachShadow');
+
+test(function () {
+    assert_false('attachShadow' in Node.prototype, 'Node.prototype.attachShadow must not exist');
+    assert_false('attachShadow' in CharacterData.prototype, 'CharacterData.prototype.attachShadow must not exist');
+    assert_false('attachShadow' in Comment.prototype, 'Comment.prototype.attachShadow must not exist');
+    assert_equals(typeof(document.createComment('').attachShadow), 'undefined', 'An instance of comment must not have attachShadow');
+    assert_false('attachShadow' in Document.prototype, 'Document.prototype.attachShadow must not exist');
+    assert_equals(typeof(document.attachShadow), 'undefined', 'An instance of document must not have attachShadow which is a function');
+    assert_false('attachShadow' in DocumentFragment.prototype, 'DocumentFragment.prototype.attachShadow must not exist');
+    assert_equals(typeof((new DOMParser()).parseFromString('', 'text/html').attachShadow), 'undefined', 'An instance of document must not have attachShadow which is a function');
+    assert_false('attachShadow' in Text.prototype, 'Text.prototype.attachShadow must not exist');
+    assert_equals(typeof(document.createTextNode('').attachShadow), 'undefined', 'An instance of text node must not have attachShadow');
+}, 'Nodes other than Element should not have attachShadow');
+
+test(function () {
+    assert_throws({'name': 'TypeError'}, function () {
+        document.createElement('div').attachShadow({})
+    }, 'attachShadow must throw a TypeError when mode is omitted');
+
+    assert_throws({'name': 'TypeError'}, function () {
+        document.createElement('div').attachShadow({mode: true})
+    }, 'attachShadow must throw a TypeError when mode is a boolean');
+
+    assert_throws({'name': 'TypeError'}, function () {
+        document.createElement('div').attachShadow({mode: 1})
+    }, 'attachShadow must throw a TypeError when mode is 1');
+}, 'Element.attachShadow must throw a TypeError if mode is not &quot;open&quot; or &quot;closed&quot;');
+
+test(function () {
+    assert_true(document.createElement('div').attachShadow({mode: &quot;open&quot;}) instanceof ShadowRoot,
+        'attachShadow({mode: &quot;open&quot;}) should create an instance of ShadowRoot');
+    assert_true(document.createElement('div').attachShadow({mode: &quot;closed&quot;}) instanceof ShadowRoot,
+        'attachShadow({mode: &quot;closed&quot;}) should create an instance of ShadowRoot');
+}, 'Element.attachShadow must create an instance of ShadowRoot');
+
+test(function () {
+    assert_throws({'name': 'InvalidStateError'}, function () {
+        var div = document.createElement('div');
+        div.attachShadow({mode: &quot;open&quot;});
+        div.attachShadow({mode: &quot;open&quot;});
+    }, 'Calling attachShadow({mode: &quot;open&quot;}) twice on the same element must throw');
+
+    assert_throws({'name': 'InvalidStateError'}, function () {
+        var div = document.createElement('div');
+        div.attachShadow({mode: &quot;closed&quot;});
+        div.attachShadow({mode: &quot;closed&quot;});
+    }, 'Calling attachShadow({mode: &quot;closed&quot;}) twice on the same element must throw');
+
+    assert_throws({'name': 'InvalidStateError'}, function () {
+        var div = document.createElement('div');
+        div.attachShadow({mode: &quot;open&quot;});
+        div.attachShadow({mode: &quot;closed&quot;});
+    }, 'Calling attachShadow({mode: &quot;closed&quot;}) after attachShadow({mode: &quot;open&quot;}) on the same element must throw');
+
+    assert_throws({'name': 'InvalidStateError'}, function () {
+        var div = document.createElement('div');
+        div.attachShadow({mode: &quot;closed&quot;});
+        div.attachShadow({mode: &quot;open&quot;});
+    }, 'Calling attachShadow({mode: &quot;open&quot;}) after attachShadow({mode: &quot;closed&quot;}) on the same element must throw');
+}, 'Element.attachShadow must throw a InvalidStateError if the context object already hosts a shadow tree');
+
+test(function () {
+    for (var elementName of ['button', 'details', 'input', 'marquee', 'meter', 'progress', 'select', 'textarea', 'keygen']) {
+        assert_throws({'name': 'NotSupportedError'}, function () {
+            document.createElement(elementName).attachShadow({mode: &quot;open&quot;});
+        }, 'Calling attachShadow({mode: &quot;open&quot;}) on ' + elementName + ' element must throw');
+
+        assert_throws({'name': 'NotSupportedError'}, function () {
+            document.createElement(elementName).attachShadow({mode: &quot;closed&quot;});
+        }, 'Calling attachShadow({mode: &quot;closed&quot;}) on ' + elementName + ' element must throw');
+    }
+}, 'Element.attachShadow must throw a NotSupportedError for button, details, input, marquee, meter, progress, select, textarea, and keygen elements');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomElementinterfaceshadowRootattributeexpectedtxtfromrev206462trunkLayoutTestsfastshadowdomElementinterfaceshadowRootattributeexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-shadowRoot-attribute-expected.txt (from rev 206462, trunk/LayoutTests/fast/shadow-dom/Element-interface-shadowRoot-attribute-expected.txt) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-shadowRoot-attribute-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-shadowRoot-attribute-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+
+PASS shadowRoot must be defined on Element prototype 
+PASS shadowRoot attribute must return the open shadow root associated with the element 
+PASS shadowRoot attribute must return null if the shadow root attached to the element is closed 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomElementinterfaceshadowRootattributehtmlfromrev206462trunkLayoutTestsfastshadowdomElementinterfaceshadowRootattributehtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-shadowRoot-attribute.html (from rev 206462, trunk/LayoutTests/fast/shadow-dom/Element-interface-shadowRoot-attribute.html) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-shadowRoot-attribute.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-shadowRoot-attribute.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,45 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;Shadow DOM: Element interface shadowRoot attribute&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;shadowRoot attribute on Element interface must return the associated open shadow tree if there is one&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;https://w3c.github.io/webcomponents/spec/shadow/#the-shadowroot-interface&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+test(function () {
+    assert_true('shadowRoot' in Element.prototype, 'shadowRoot must be defined on Element prototype');
+    assert_true('shadowRoot' in document.createElement('div'), 'shadowRoot must be defined on an instance of div element');
+    assert_false('shadowRoot' in Node.prototype, 'shadowRoot must not be defined on Node prototype');
+    assert_false('shadowRoot' in Text.prototype, 'shadowRoot must not be defined on Text prototype');
+    assert_false('shadowRoot' in document.createTextNode(''), 'shadowRoot must not be defined on an instance of Text node');
+    assert_false('shadowRoot' in Comment.prototype, 'shadowRoot must not be defined on Comment prototype');
+    assert_false('shadowRoot' in document.createComment(''), 'shadowRoot must not be defined on an instance of Comment node');
+    assert_false('shadowRoot' in Document.prototype, 'shadowRoot must not be defined on Document prototype');
+    assert_false('shadowRoot' in document, 'shadowRoot must not be defined on an instance of Document');
+    assert_false('shadowRoot' in DocumentFragment.prototype, 'shadowRoot must not be defined on DocumentFragment prototype');
+    assert_false('shadowRoot' in (new DOMParser).parseFromString('', 'text/html'), 'shadowRoot must not be defined on an instance of DocumentFragment node');
+}, 'shadowRoot must be defined on Element prototype');
+
+test(function () {
+    var host = document.createElement('div');
+    assert_equals(host.shadowRoot, null, 'shadowRoot must return null when the host does not have a shadow tree attached to it');
+
+    var openShadowRoot = host.attachShadow({mode: 'open'});
+    assert_equals(host.shadowRoot, openShadowRoot, 'shadowRoot must return the open shadow root attachShadow attached');
+}, 'shadowRoot attribute must return the open shadow root associated with the element');
+
+test(function () {
+    var host = document.createElement('div');
+    host.attachShadow({mode: 'closed'});
+    assert_equals(host.shadowRoot, null);
+}, 'shadowRoot attribute must return null if the shadow root attached to the element is closed');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomExtensionstoEventInterfaceexpectedtxtfromrev206462trunkLayoutTestsfastshadowdomExtensionstoEventInterfaceexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Extensions-to-Event-Interface-expected.txt (from rev 206462, trunk/LayoutTests/fast/shadow-dom/Extensions-to-Event-Interface-expected.txt) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Extensions-to-Event-Interface-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Extensions-to-Event-Interface-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+
+PASS composedPath() must exist on Event 
+PASS composedPath() must return an empty array when the event has not been dispatched 
+PASS composedPath() must return an empty array when the event is no longer dispatched 
+PASS composed must exist on Event 
+PASS composed on EventInit must default to false 
+PASS composed on EventInit must set the composed flag 
+PASS The event must propagate out of open mode shadow boundaries when the composed flag is set 
+PASS The event must propagate out of closed mode shadow boundaries when the composed flag is set 
+PASS The event must not propagate out of open mode shadow boundaries when the composed flag is unset 
+PASS The event must not propagate out of closed mode shadow boundaries when the composed flag is unset 
+PASS The event must not propagate out of open mode shadow boundaries when the composed flag is unset on an event with relatedTarget 
+PASS The event must not propagate out of closed mode shadow boundaries when the composed flag is unset on an event with relatedTarget 
+PASS The event must not propagate out of open mode shadow tree of the target but must propagate out of inner shadow trees when the scoped flag is set 
+PASS The event must not propagate out of closed mode shadow tree of the target but must propagate out of inner shadow trees when the scoped flag is set 
+PASS The event must propagate out of open mode shadow tree in which the relative target and the relative related target are the same 
+PASS The event must propagate out of closed mode shadow tree in which the relative target and the relative related target are the same 
+PASS composedPath() must contain and only contain the unclosed nodes of target in open mode shadow trees 
+PASS composedPath() must contain and only contain the unclosed nodes of target in closed mode shadow trees 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomExtensionstoEventInterfacehtmlfromrev206462trunkLayoutTestsfastshadowdomExtensionstoEventInterfacehtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Extensions-to-Event-Interface.html (from rev 206462, trunk/LayoutTests/fast/shadow-dom/Extensions-to-Event-Interface.html) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Extensions-to-Event-Interface.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Extensions-to-Event-Interface.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,234 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;Shadow DOM: Extensions to Event Interface&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;Event interface must have composedPath() as a method&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;http://w3c.github.io/webcomponents/spec/shadow/#extensions-to-event-interface&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/event-path-test-helpers.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+test(function () {
+    assert_true('composedPath' in Event.prototype);
+    assert_true('composedPath' in new Event('my-event'));
+}, 'composedPath() must exist on Event');
+
+test(function () {
+    var event = new Event('my-event');
+    assert_array_equals(event.composedPath(), []);
+}, 'composedPath() must return an empty array when the event has not been dispatched');
+
+test(function () {
+    var event = new Event('my-event');
+    document.body.dispatchEvent(event);
+    assert_array_equals(event.composedPath(), []);
+}, 'composedPath() must return an empty array when the event is no longer dispatched');
+
+test(function () {
+    assert_true('composed' in Event.prototype);
+    assert_true('composed' in new Event('my-event'));
+}, 'composed must exist on Event');
+
+test(function () {
+    var event = new Event('my-event');
+    assert_false(event.composed);
+}, 'composed on EventInit must default to false');
+
+test(function () {
+    var event = new Event('my-event', {composed: true});
+    assert_true(event.composed);
+
+    event = new Event('my-event', {composed: false});
+    assert_false(event.composed);
+}, 'composed on EventInit must set the composed flag');
+
+/*
+-SR: ShadowRoot  -S: Slot  target: (~)  *: indicates start  digit: event path order
+A (4) --------------------------- A-SR (3)
++ B ------------ B-SR             + A1 (2) --- A1-SR (1)
+  + C            + B1 --- B1-SR   + A2-S       + A1a (*; 0)
+  + D --- D-SR     + B1a    + B1b --- B1b-SR
+          + D1              + B1c-S   + B1b1
+                                      + B1b2
+*/
+
+function testComposedEvent(mode) {
+    test(function () {
+        var nodes = createTestTree(mode);
+        var log = dispatchEventWithLog(nodes, nodes.A1a, new Event('my-event', {composed: true, bubbles: true}));
+
+        var expectedPath = ['A1a', 'A1-SR', 'A1', 'A-SR', 'A'];
+        assert_array_equals(log.eventPath, expectedPath);
+        assert_array_equals(log.eventPath.length, log.pathAtTargets.length);
+        assert_array_equals(log.pathAtTargets[0], expectedPath);
+        assert_array_equals(log.pathAtTargets[1], expectedPath);
+        assert_array_equals(log.pathAtTargets[2], mode == 'open' ? expectedPath : ['A1', 'A-SR', 'A'],
+            'composedPath must only contain unclosed nodes of the current target.');
+    }, 'The event must propagate out of ' + mode + ' mode shadow boundaries when the composed flag is set');
+}
+
+testComposedEvent('open');
+testComposedEvent('closed');
+
+/*
+-SR: ShadowRoot  -S: Slot  target: (~)  *: indicates start  digit: event path order
+A ------------------------------- A-SR
++ B ------------ B-SR             + A1 --- A1-SR (1)
+  + C            + B1 --- B1-SR   + A2-S   + A1a (*; 0)
+  + D --- D-SR     + B1a  + B1b --- B1b-SR
+          + D1            + B1c-S   + B1b1
+                                    + B1b2
+*/
+
+function testNonComposedEvent(mode) {
+    test(function () {
+        var nodes = createTestTree(mode);
+        var log = dispatchEventWithLog(nodes, nodes.A1a, new Event('my-event', {composed: false, bubbles: true}));
+
+        var expectedPath = ['A1a', 'A1-SR'];
+        assert_array_equals(log.eventPath, expectedPath);
+        assert_array_equals(log.eventPath.length, log.pathAtTargets.length);
+        assert_array_equals(log.pathAtTargets[0], expectedPath);
+        assert_array_equals(log.pathAtTargets[1], expectedPath);
+    }, 'The event must not propagate out of ' + mode + ' mode shadow boundaries when the composed flag is unset');
+}
+
+testNonComposedEvent('open');
+testNonComposedEvent('closed');
+
+/*
+-SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
+A ------------------------------- A-SR
++ B ------------ B-SR             + A1 ----------- A1-SR (1)
+  + C            + B1 --- B1-SR   + A2-S [*; 0-1]  + A1a (*; 0)
+  + D --- D-SR     + B1a  + B1b --- B1b-SR
+          + D1            + B1c-S   + B1b1
+                                    + B1b2
+*/
+
+function testNonComposedEventWithRelatedTarget(mode) {
+    test(function () {
+        var nodes = createTestTree(mode);
+        var log = dispatchEventWithLog(nodes, nodes.A1a, new MouseEvent('foo', {composed: false, bubbles: true, relatedTarget: nodes['A2-S']}));
+
+        var expectedPath = ['A1a', 'A1-SR'];
+        assert_array_equals(log.eventPath, expectedPath);
+        assert_array_equals(log.eventPath.length, log.pathAtTargets.length);
+        assert_array_equals(log.pathAtTargets[0], expectedPath);
+        assert_array_equals(log.pathAtTargets[1], expectedPath);
+        assert_array_equals(log.relatedTargets, ['A2-S', 'A2-S']);
+    }, 'The event must not propagate out of ' + mode + ' mode shadow boundaries when the composed flag is unset on an event with relatedTarget');
+}
+
+testNonComposedEventWithRelatedTarget('open');
+testNonComposedEventWithRelatedTarget('closed');
+
+/*
+-SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
+A ------------------------------------------------ A-SR
++ B ------------ B-SR (4)                          + A1 --- A1-SR
+  + C            + B1 (3) [0,3-4] --- B1-SR (2)    + A2-S   + A1a
+  + D --- D-SR     + B1a (*; 0)       + B1b [1-2] --- B1b-SR
+          + D1                        + B1c-S (1)     + B1b1
+                                                      + B1b2 [*]
+*/
+
+function testScopedEventWithUnscopedRelatedTargetThroughSlot(mode) {
+    test(function () {
+        var nodes = createTestTree(mode);
+        var log = dispatchEventWithLog(nodes, nodes.B1a, new MouseEvent('foo', {scoped: true, relatedTargetScoped: false, bubbles: true, relatedTarget: nodes['B1b2']}));
+
+        var expectedPath = ['B1a', 'B1c-S', 'B1-SR', 'B1', 'B-SR'];
+        var pathExposedToB1a = ['B1a', 'B1', 'B-SR'];
+        assert_array_equals(log.eventPath, expectedPath);
+        assert_array_equals(log.eventPath.length, log.pathAtTargets.length);
+        assert_array_equals(log.pathAtTargets[0], mode == 'open' ? expectedPath : pathExposedToB1a);
+        assert_array_equals(log.pathAtTargets[1], expectedPath);
+        assert_array_equals(log.pathAtTargets[2], expectedPath);
+        assert_array_equals(log.pathAtTargets[3], mode == 'open' ? expectedPath : pathExposedToB1a);
+        assert_array_equals(log.pathAtTargets[4], mode == 'open' ? expectedPath : pathExposedToB1a);
+        assert_array_equals(log.relatedTargets, ['B1', 'B1b', 'B1b', 'B1', 'B1']);
+    }, 'The event must not propagate out of ' + mode + ' mode shadow tree of the target but must propagate out of inner shadow trees when the scoped flag is set');
+}
+
+testScopedEventWithUnscopedRelatedTargetThroughSlot('open');
+testScopedEventWithUnscopedRelatedTargetThroughSlot('closed');
+
+/*
+-SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
+A ------------------------------- A-SR (3)
++ B ------------ B-SR             + A1 (2) ------- A1-SR (1)
+  + C            + B1 --- B1-SR   + A2-S [*; 0-3]  + A1a (*; 0)
+  + D --- D-SR     + B1a  + B1b --- B1b-SR
+          + D1            + B1c-S   + B1b1
+                                    + B1b2
+*/
+
+function testComposedEventWithRelatedTarget(mode) {
+    test(function () {
+        var nodes = createTestTree(mode);
+        log = dispatchEventWithLog(nodes, nodes.A1a, new MouseEvent('foo', {composed: true, bubbles: true, relatedTarget: nodes['A2-S']}));
+
+        var expectedPath = ['A1a', 'A1-SR', 'A1', 'A-SR'];
+        var pathExposedToA1 = ['A1', 'A-SR'];
+        assert_array_equals(log.eventPath, expectedPath);
+        assert_array_equals(log.eventPath.length, log.pathAtTargets.length);
+        assert_array_equals(log.pathAtTargets[0], expectedPath);
+        assert_array_equals(log.pathAtTargets[1], expectedPath);
+        assert_array_equals(log.pathAtTargets[2], mode == 'open' ? expectedPath : pathExposedToA1);
+        assert_array_equals(log.pathAtTargets[3], mode == 'open' ? expectedPath : pathExposedToA1);
+        assert_array_equals(log.relatedTargets, ['A2-S', 'A2-S', 'A2-S', 'A2-S']);
+    }, 'The event must propagate out of ' + mode + ' mode shadow tree in which the relative target and the relative related target are the same');
+}
+
+testComposedEventWithRelatedTarget('open');
+testComposedEventWithRelatedTarget('closed');
+
+/*
+-SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
+A (8) [0-5,8] ---------------------------------------- A-SR (7)
++ B (5)  ------- B-SR (4)                              + A1 [6,7] --- A1-SR
+  + C            + B1 (3) ------- B1-SR (2)            + A2-S (6)     + A1a [*]
+  + D --- D-SR     + B1a (*; 0)   + B1b ------- B1b-SR
+          + D1                    + B1c-S (1)   + B1b1
+                                                + B1b2
+*/
+
+function testComposedEventThroughSlot(mode) {
+    test(function () {
+        var nodes = createTestTree(mode);
+        log = dispatchEventWithLog(nodes, nodes.B1a, new MouseEvent('foo', {composed: true, bubbles: true, relatedTarget: nodes.A1a}));
+
+        var expectedPath =          ['B1a', 'B1c-S', 'B1-SR', 'B1', 'B-SR', 'B', 'A2-S', 'A-SR', 'A'];
+        var expectedRelatedTarget = ['A',   'A',     'A',     'A',   'A',   'A', 'A1',   'A1',   'A'];
+        var pathExposedToB1a =      ['B1a',                   'B1', 'B-SR', 'B',                 'A'];
+        var pathExposedToB1cS =     ['B1a', 'B1c-S', 'B1-SR', 'B1', 'B-SR', 'B',                 'A'];
+        var pathExposedToB =        [                                       'B',                 'A'];
+        var pathExposedToA1 =       [                                       'B', 'A2-S', 'A-SR', 'A'];
+
+        assert_array_equals(log.eventPath, expectedPath);
+        assert_array_equals(log.eventPath.length, log.pathAtTargets.length);
+        assert_array_equals(log.pathAtTargets[0], mode == 'open' ? expectedPath : pathExposedToB1a);
+        assert_array_equals(log.pathAtTargets[1], mode == 'open' ? expectedPath : pathExposedToB1cS);
+        assert_array_equals(log.pathAtTargets[2], mode == 'open' ? expectedPath : pathExposedToB1cS);
+        assert_array_equals(log.pathAtTargets[3], mode == 'open' ? expectedPath : pathExposedToB1a);
+        assert_array_equals(log.pathAtTargets[4], mode == 'open' ? expectedPath : pathExposedToB1a);
+        assert_array_equals(log.pathAtTargets[5], mode == 'open' ? expectedPath : pathExposedToB);
+        assert_array_equals(log.pathAtTargets[6], mode == 'open' ? expectedPath : pathExposedToA1);
+        assert_array_equals(log.pathAtTargets[7], mode == 'open' ? expectedPath : pathExposedToA1);
+        assert_array_equals(log.pathAtTargets[8], mode == 'open' ? expectedPath : pathExposedToB);
+        assert_array_equals(log.relatedTargets, expectedRelatedTarget);
+    }, 'composedPath() must contain and only contain the unclosed nodes of target in ' + mode + ' mode shadow trees');
+}
+
+testComposedEventThroughSlot('open');
+testComposedEventThroughSlot('closed');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomHTMLSlotElementinterfaceexpectedtxtfromrev206462trunkLayoutTestsfastshadowdomHTMLSlotElementinterfaceexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/HTMLSlotElement-interface-expected.txt (from rev 206462, trunk/LayoutTests/fast/shadow-dom/HTMLSlotElement-interface-expected.txt) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/HTMLSlotElement-interface-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/HTMLSlotElement-interface-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+
+PASS HTMLSlotElement must be defined on window 
+PASS &quot;name&quot; attribute on HTMLSlotElement must reflect &quot;name&quot; attribute 
+PASS assignedNodes() on a HTMLSlotElement must return an empty array when the slot element is not in a tree or in a document tree 
+PASS assignedNodes({&quot;flattened&quot;:false}) on a HTMLSlotElement must return an empty array when the slot element is not in a tree or in a document tree 
+PASS assignedNodes({&quot;flattened&quot;:true}) on a HTMLSlotElement must return an empty array when the slot element is not in a tree or in a document tree 
+PASS assignedNodes() must return the list of assigned nodes when none of the assigned nodes themselves are slots 
+PASS assignedNodes({&quot;flattened&quot;:false}) must return the list of assigned nodes when none of the assigned nodes themselves are slots 
+PASS assignedNodes({&quot;flattened&quot;:true}) must return the list of assigned nodes when none of the assigned nodes themselves are slots 
+PASS assignedNodes() must update when slot and name attributes are modified 
+PASS assignedNodes({&quot;flattened&quot;:false}) must update when slot and name attributes are modified 
+PASS assignedNodes({&quot;flattened&quot;:true}) must update when slot and name attributes are modified 
+PASS assignedNodes must update when a default slot is introduced dynamically by a slot rename 
+PASS assignedNodes must update when a default slot is introduced dynamically by a slot rename 
+PASS assignedNodes must update when a default slot is introduced dynamically by a slot rename 
+PASS assignedNodes must update when slot elements are inserted or removed 
+PASS assignedNodes must update when slot elements are inserted or removed 
+PASS assignedNodes must update when slot elements are inserted or removed 
+PASS assignedNodes({flatten: true}) must return the distributed nodes, and assignedNodes() and assignedNodes({flatten: false}) must returned the assigned nodes 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomHTMLSlotElementinterfacehtmlfromrev206462trunkLayoutTestsfastshadowdomHTMLSlotElementinterfacehtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/HTMLSlotElement-interface.html (from rev 206462, trunk/LayoutTests/fast/shadow-dom/HTMLSlotElement-interface.html) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/HTMLSlotElement-interface.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/HTMLSlotElement-interface.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,269 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;Shadow DOM: HTMLSlotElement interface&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;HTMLSlotElement must exist on window with name attribute and getAssignedNode() method&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;https://w3c.github.io/webcomponents/spec/shadow/#the-slot-element&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+test(function () {
+    assert_true('HTMLSlotElement' in window, 'HTMLSlotElement must be defined on window');
+    assert_equals(HTMLSlotElement.prototype.__proto__, HTMLElement.prototype, 'HTMLSlotElement should inherit from HTMLElement');
+    assert_true(document.createElement('slot') instanceof HTMLSlotElement, 'slot element should be an instance of HTMLSlotElement');
+    assert_true(document.createElement('slot') instanceof HTMLElement, 'slot element should be an instance of HTMLElement');
+}, 'HTMLSlotElement must be defined on window');
+
+test(function () {
+    assert_true('name' in HTMLSlotElement.prototype, '&quot;name&quot; attribute must be defined on HTMLSlotElement.prototype');
+
+    var slotElement = document.createElement('slot');
+    assert_equals(slotElement.name, '', '&quot;name&quot; attribute must return the empty string when &quot;name&quot; content attribute is not set');
+
+    slotElement.setAttribute('name', 'foo');
+    assert_equals(slotElement.name, 'foo', '&quot;name&quot; attribute must return the value of the &quot;name&quot; content attribute');
+
+    slotElement.name = 'bar';
+    assert_equals(slotElement.name, 'bar', '&quot;name&quot; attribute must return the assigned value');
+    assert_equals(slotElement.getAttribute('name'), 'bar', '&quot;name&quot; attribute must update the &quot;name&quot; content attribute');
+}, '&quot;name&quot; attribute on HTMLSlotElement must reflect &quot;name&quot; attribute');
+
+function testSlotOutsideShadowTree(options)
+{
+    test(function () {
+        assert_true('assignedNodes' in HTMLSlotElement.prototype, '&quot;assignedNodes&quot; method must be defined on HTMLSlotElement.prototype');
+
+        var slotElement = document.createElement('slot');
+        assert_array_equals(slotElement.assignedNodes(options), [], 'assignedNodes() must return an empty array when the slot element is not in any tree');
+
+        document.body.appendChild(slotElement);
+        assert_array_equals(slotElement.assignedNodes(options), [], 'assignedNodes() must return an empty array when the slot element is in a document tree');
+
+    }, 'assignedNodes(' + (options ? JSON.stringify(options) : '')
+        + ') on a HTMLSlotElement must return an empty array when the slot element is not in a tree or in a document tree');
+}
+
+testSlotOutsideShadowTree(null);
+testSlotOutsideShadowTree({flattened: false});
+testSlotOutsideShadowTree({flattened: true});
+
+function testSingleLevelOfSlotting(options)
+{
+    test(function () {
+        assert_true('assignedNodes' in HTMLSlotElement.prototype, '&quot;assignedNodes&quot; method must be defined on HTMLSlotElement.prototype');
+
+        var shadowHost = document.createElement('div');
+        var child = document.createElement('p');
+
+        var shadowRoot = shadowHost.attachShadow({mode: 'open'});
+        var slotElement = document.createElement('slot');
+        shadowRoot.appendChild(slotElement);
+
+        assert_array_equals(slotElement.assignedNodes(options), [], 'assignedNodes() must return an empty array when there are no nodes in the shadow tree');
+
+        shadowHost.appendChild(child);
+        assert_array_equals(slotElement.assignedNodes(options), [child], 'assignedNodes() on a default slot must return an element without slot element');
+
+        child.setAttribute('slot', 'foo');
+        assert_array_equals(slotElement.assignedNodes(options), [], 'assignedNodes() on a default slot must not return an element with non-empty slot attribute');
+
+        child.setAttribute('slot', '');
+        assert_array_equals(slotElement.assignedNodes(options), [child], 'assignedNodes() on a default slot must return an element with empty slot attribute');
+
+        slotElement.setAttribute('name', 'bar');
+        assert_array_equals(slotElement.assignedNodes(options), [], 'assignedNodes() on a named slot must not return an element with empty slot attribute');
+
+        slotElement.setAttribute('name', '');
+        assert_array_equals(slotElement.assignedNodes(options), [child], 'assignedNodes() on an empty name slot must return an element with empty slot attribute');
+
+    }, 'assignedNodes(' + (options ? JSON.stringify(options) : '') + ') must return the list of assigned nodes when none of the assigned nodes themselves are slots');
+}
+
+testSingleLevelOfSlotting(null);
+testSingleLevelOfSlotting({flattened: false});
+testSingleLevelOfSlotting({flattened: true});
+
+function testMutatingSlottedContents(options)
+{
+    test(function () {
+        var shadowHost = document.createElement('div');
+        var p = document.createElement('p');
+        var b = document.createElement('b');
+        shadowHost.appendChild(p);
+        shadowHost.appendChild(b);
+
+        var shadowRoot = shadowHost.attachShadow({mode: 'open'});
+        var slotElement = document.createElement('slot');
+        shadowRoot.appendChild(slotElement);
+
+        assert_array_equals(slotElement.assignedNodes(options), [p, b], 'assignedNodes must return the distributed nodes');
+
+        slotElement.name = 'foo';
+        assert_array_equals(slotElement.assignedNodes(options), [], 'assignedNodes must be empty when there are no matching elements for the slot name');
+
+        b.slot = 'foo';
+        assert_array_equals(slotElement.assignedNodes(options), [b], 'assignedNodes must return the nodes with the matching slot name');
+
+        p.slot = 'foo';
+        assert_array_equals(slotElement.assignedNodes(options), [p, b], 'assignedNodes must return the nodes with the matching slot name in the tree order');
+
+        slotElement.removeAttribute('name');
+        assert_array_equals(slotElement.assignedNodes(options), [], 'assignedNodes must be empty for a default slot when all elements have &quot;slot&quot; attributes specified');
+
+    }, 'assignedNodes(' + (options ? JSON.stringify(options) : '') + ') must update when slot and name attributes are modified');
+}
+
+testMutatingSlottedContents(null);
+testMutatingSlottedContents({flattened: false});
+testMutatingSlottedContents({flattened: true});
+
+function testMutatingSlotName(options)
+{
+    test(function () {
+        var shadowHost = document.createElement('div');
+        var child = document.createElement('span');
+        shadowHost.appendChild(child);
+
+        var shadowRoot = shadowHost.attachShadow({mode: 'open'});
+        var slotElement = document.createElement('slot');
+        slotElement.name = 'foo';
+        shadowRoot.appendChild(slotElement);
+
+        assert_array_equals(slotElement.assignedNodes(options), [], 'assignedNodes must be empty when there are no matching elements for the slot name');
+
+        slotElement.removeAttribute('name');
+        assert_array_equals(slotElement.assignedNodes(options), [child], 'assignedNodes must be empty when there are no matching elements for the slot name');
+
+    }, 'assignedNodes must update when a default slot is introduced dynamically by a slot rename');
+}
+
+testMutatingSlotName(null);
+testMutatingSlotName({flattened: false});
+testMutatingSlotName({flattened: true});
+
+function testInsertingAndRemovingSlots(options)
+{
+    test(function () {
+        var shadowHost = document.createElement('div');
+        var p = document.createElement('p');
+        var text = document.createTextNode('');
+        var comment = document.createComment('');
+        var processingInstruction = document.createProcessingInstruction('target', 'data');
+        var b = document.createElement('b');
+        shadowHost.appendChild(p);
+        shadowHost.appendChild(text);
+        shadowHost.appendChild(comment);
+        shadowHost.appendChild(processingInstruction);
+        shadowHost.appendChild(b);
+
+        var shadowRoot = shadowHost.attachShadow({mode: 'open'});
+
+        var firstSlotElement = document.createElement('slot');
+        shadowRoot.appendChild(firstSlotElement);
+
+        var secondSlotElement = document.createElement('slot');
+        shadowRoot.appendChild(secondSlotElement);
+
+        assert_array_equals(firstSlotElement.assignedNodes(options), [p, text, b],
+            'assignedNodes on a default slot must return the elements without slot attributes and text nodes');
+        assert_array_equals(secondSlotElement.assignedNodes(options), [],
+            'assignedNodes on the second unnamed slot element must return an empty array');
+
+        shadowRoot.removeChild(firstSlotElement);
+        assert_array_equals(firstSlotElement.assignedNodes(options), [],
+            'assignedNodes on a detached formerly-default slot must return an empty array');
+        assert_array_equals(secondSlotElement.assignedNodes(options), [p, text, b],
+            'assignedNodes on the second unnamed slot element after removing the first must return the elements without slot attributes and text nodes');
+
+        shadowRoot.removeChild(secondSlotElement);
+        shadowRoot.appendChild(secondSlotElement);
+        assert_array_equals(firstSlotElement.assignedNodes(options), [],
+            'Removing and re-inserting a default slot must not change the result of assignedNodes on a detached slot');
+        assert_array_equals(secondSlotElement.assignedNodes(options), [p, text, b],
+            'Removing and re-inserting a default slot must not change the result of assignedNodes');
+
+        shadowRoot.insertBefore(firstSlotElement, secondSlotElement);
+        assert_array_equals(firstSlotElement.assignedNodes(options), [p, text, b],
+            'assignedNodes on a newly inserted unnamed slot element must return the elements without slot attributes and text nodes');
+        assert_array_equals(secondSlotElement.assignedNodes(options), [],
+            'assignedNodes on formerly-first but now second unnamed slot element must return an empty array');
+
+    }, 'assignedNodes must update when slot elements are inserted or removed');
+}
+
+testInsertingAndRemovingSlots(null);
+testInsertingAndRemovingSlots({flattened: false});
+testInsertingAndRemovingSlots({flattened: true});
+
+test(function () {
+    var outerHost = document.createElement('div');
+    var outerChild = document.createElement('span');
+    outerHost.appendChild(outerChild);
+
+    var outerShadow = outerHost.attachShadow({mode: 'closed'});
+    var innerHost = document.createElement('div');
+    var outerSlot = document.createElement('slot');
+    var innerChild = document.createElement('b');
+    outerShadow.appendChild(innerHost);
+    innerHost.appendChild(outerSlot);
+    innerHost.appendChild(innerChild);
+
+    var innerShadow = innerHost.attachShadow({mode: 'closed'});
+    var innerSlot = document.createElement('slot');
+    innerShadow.appendChild(innerSlot);
+
+    assert_array_equals(outerSlot.assignedNodes(), [outerChild], 'assignedNodes() on a default slot must return the assigned nodes');
+    assert_array_equals(outerSlot.assignedNodes({flatten: false}), [outerChild], 'assignedNodes({flatten: false}) on a default slot must return the assigned nodes');
+    assert_array_equals(outerSlot.assignedNodes({flatten: true}), [outerChild], 'assignedNodes({flatten: true}) on a default slot must return the assigned nodes if they are not themselves slots');
+
+    assert_array_equals(innerSlot.assignedNodes(), [outerSlot, innerChild], 'assignedNodes() on a default slot must return the assigned nodes');
+    assert_array_equals(innerSlot.assignedNodes({flatten: false}), [outerSlot, innerChild], 'assignedNodes({flatten: false}) on a default slot must return the assigned nodes');
+    assert_array_equals(innerSlot.assignedNodes({flatten: true}), [outerChild, innerChild], 'assignedNodes({flatten: true}) on a default slot must return the distributed nodes');
+
+    outerSlot.name = 'foo';
+    assert_array_equals(outerSlot.assignedNodes(), [], 'assignedNodes() on a named slot must return an empty array if there are no matching elements');
+    assert_array_equals(outerSlot.assignedNodes({flatten: false}), [], 'assignedNodes({flatten: false}) on a named slot must return an empty array if there are no matching elements');
+    assert_array_equals(outerSlot.assignedNodes({flatten: true}), [], 'assignedNodes({flatten: true}) on a named slot must return an empty array if there are no matching elements');
+
+    assert_array_equals(innerSlot.assignedNodes(), [outerSlot, innerChild], 'assignedNodes() on a default slot must return the assigned nodes');
+    assert_array_equals(innerSlot.assignedNodes({flatten: false}), [outerSlot, innerChild], 'assignedNodes({flatten: false}) on a default slot must return the assigned nodes');
+    assert_array_equals(innerSlot.assignedNodes({flatten: true}), [innerChild], 'assignedNodes({flatten: true}) on a default slot must return the distributed nodes');
+
+    outerChild.slot = 'foo';
+    assert_array_equals(outerSlot.assignedNodes(), [outerChild], 'assignedNodes() on a named slot must return matching elements');
+    assert_array_equals(outerSlot.assignedNodes({flatten: false}), [outerChild], 'assignedNodes({flatten: false}) on a named slot must return matching elements');
+    assert_array_equals(outerSlot.assignedNodes({flatten: true}), [outerChild], 'assignedNodes({flatten: true}) on a named slot must return matching elements');
+
+    assert_array_equals(innerSlot.assignedNodes(), [outerSlot, innerChild], 'assignedNodes() on a default slot must return the assigned nodes');
+    assert_array_equals(innerSlot.assignedNodes({flatten: false}), [outerSlot, innerChild], 'assignedNodes({flatten: false}) on a default slot must return the assigned nodes');
+    assert_array_equals(innerSlot.assignedNodes({flatten: true}), [outerChild, innerChild], 'assignedNodes({flatten: true}) on a default slot must return the distributed nodes');
+
+    var newInnerSlot = document.createElement('slot');
+    innerShadow.insertBefore(newInnerSlot, innerSlot);
+    assert_array_equals(newInnerSlot.assignedNodes(), [outerSlot, innerChild], 'assignedNodes() on a default slot must return the assigned nodes');
+    assert_array_equals(newInnerSlot.assignedNodes({flatten: false}), [outerSlot, innerChild], 'assignedNodes({flatten: false}) on a default slot must return the assigned nodes');
+    assert_array_equals(newInnerSlot.assignedNodes({flatten: true}), [outerChild, innerChild], 'assignedNodes({flatten: true}) on a default slot must return the distributed nodes');
+
+    assert_array_equals(innerSlot.assignedNodes(), [], 'assignedNodes() on a nameless slot element which appears after a default slot must return an empty array');
+    assert_array_equals(innerSlot.assignedNodes({flatten: false}), [], 'assignedNodes({flatten: false}) on a nameless slot element which appears after a default slot must return an empty array');
+    assert_array_equals(innerSlot.assignedNodes({flatten: true}), [], 'assignedNodes({flatten: true}) on a nameless slot element which appears after a default slot must return an empty array');
+
+    innerShadow.removeChild(newInnerSlot);
+    assert_array_equals(newInnerSlot.assignedNodes(), [], 'assignedNodes() must return an empty array when the slot element is not in any tree');
+    assert_array_equals(newInnerSlot.assignedNodes({flatten: false}), [], 'assignedNodes({flatten: false}) must return an empty array when the slot element is not in any tree');
+    assert_array_equals(newInnerSlot.assignedNodes({flatten: true}), [], 'assignedNodes({flatten: true}) must return an empty array when the slot element is not in any tree');
+
+    assert_array_equals(innerSlot.assignedNodes(), [outerSlot, innerChild], 'assignedNodes() on a default slot must return the assigned nodes');
+    assert_array_equals(innerSlot.assignedNodes({flatten: false}), [outerSlot, innerChild], 'assignedNodes({flatten: false}) on a default slot must return the assigned nodes');
+    assert_array_equals(innerSlot.assignedNodes({flatten: true}), [outerChild, innerChild], 'assignedNodes({flatten: true}) on a default slot must return the distributed nodes');
+
+}, 'assignedNodes({flatten: true}) must return the distributed nodes, and assignedNodes() and assignedNodes({flatten: false}) must returned the assigned nodes');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomMouseEventprototypeoffsetXoffsetYexpectedtxtfromrev206462trunkLayoutTestsfastshadowdomMouseEventprototypeoffsetXoffsetYexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/MouseEvent-prototype-offsetX-offsetY-expected.txt (from rev 206462, trunk/LayoutTests/fast/shadow-dom/MouseEvent-prototype-offsetX-offsetY-expected.txt) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/MouseEvent-prototype-offsetX-offsetY-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/MouseEvent-prototype-offsetX-offsetY-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+Click here
+
+PASS MouseEvent's offsetX and offsetY attributes must be relative to the target. 
+PASS MouseEvent's offsetX and offsetY attributes must be relative to the shadow host when an event is dispatched inside its shadow tree. 
+PASS MouseEvent's offsetX and offsetY attributes must be relative to the target when an event is dispatched on a slotted content. 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomMouseEventprototypeoffsetXoffsetYhtmlfromrev206462trunkLayoutTestsfastshadowdomMouseEventprototypeoffsetXoffsetYhtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html (from rev 206462, trunk/LayoutTests/fast/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,154 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;Shadow DOM: MouseEvent's offsetX and offsetY attributes must be relative to the relative target.&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;The MouseEvent offsetX and offsetY attributes must return the coordinates relative to the origin of the padding edge of the relative target&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;http://w3c.github.io/webcomponents/spec/shadow/#event-dispatch&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/event-path-test-helpers.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;style&gt;
+html, body { padding: 0; margin: 0; }
+my-host { display: block; width: 180px; height: 80px; margin: 10px 20px; padding: 10px; background: #ccc; }
+#log { margin: 1rem; }
+&lt;/style&gt;
+&lt;my-host&gt;&lt;/my-host&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+var shadowStyle = '#container { width: 160px; height: 60px; padding: 10px; background: yellow; } #target { margin-left: 5px; background: orange; }';
+var host = document.querySelector('my-host');
+
+function attachLoggers(targets)
+{
+    var eventLogs = [];
+    for (var i = 0; i &lt; targets.length; i++) {
+        targets[i].addEventListener('mousedown', function (event) {
+            eventLogs.push({current: this, target: event.target, offsetX: event.offsetX, offsetY: event.offsetY});
+        });
+    }
+    return eventLogs;
+}
+
+test(function () {
+    host.innerHTML = '&lt;style&gt;' + shadowStyle + '&lt;/style&gt;&lt;div id=&quot;container&quot;&gt;&lt;span id=&quot;target&quot;&gt;Click here&lt;/div&gt;&lt;/div&gt;';
+
+    var target = host.querySelector('#target');
+    var container = host.querySelector('#container');
+
+    var eventLogs = attachLoggers([target, container, host, document.body]);
+    var mouseEvent = new MouseEvent('mousedown', {clientX: 51, clientY: 37, composed: true, bubbles: true});
+    target.dispatchEvent(mouseEvent);
+
+    assert_equals(host.offsetLeft, 20, 'The host must be at (20px, 10px)');
+    assert_equals(host.offsetTop, 10, 'The host must be at (20px, 10px)');
+    assert_equals(target.offsetLeft, 45, 'The target must be at (45px, 30px)');
+    assert_equals(target.offsetTop, 30, 'The target must be at (45px, 30px)');
+
+    assert_equals(eventLogs[0].current, target);
+    assert_equals(eventLogs[0].target, target);
+    assert_equals(eventLogs[0].offsetX, 21); // Padding edge of target is at (30px, 20px)
+    assert_equals(eventLogs[0].offsetY, 17);
+
+    assert_equals(eventLogs[1].current, container);
+    assert_equals(eventLogs[1].target, target);
+    assert_equals(eventLogs[1].offsetX, 21);
+    assert_equals(eventLogs[1].offsetY, 17);
+
+    assert_equals(eventLogs[2].current, host);
+    assert_equals(eventLogs[2].target, target);
+    assert_equals(eventLogs[2].offsetX, 21);
+    assert_equals(eventLogs[2].offsetY, 17);
+
+    assert_equals(eventLogs[3].current, document.body);
+    assert_equals(eventLogs[3].target, target);
+    assert_equals(eventLogs[3].offsetX, 21);
+    assert_equals(eventLogs[3].offsetY, 17);
+}, 'MouseEvent\'s offsetX and offsetY attributes must be relative to the target.');
+
+var shadowRoot = host.attachShadow({mode: 'closed'});
+test(function () {
+    shadowRoot.innerHTML = '&lt;style&gt;' + shadowStyle + '&lt;/style&gt;&lt;div id=&quot;container&quot;&gt;&lt;span id=&quot;target&quot;&gt;Click here&lt;/div&gt;&lt;/div&gt;';
+
+    var target = shadowRoot.querySelector('#target');
+    var container = shadowRoot.querySelector('#container');
+
+    var eventLogs = attachLoggers([target, container, shadowRoot, host, document.body]);
+    var mouseEvent = new MouseEvent('mousedown', {clientX: 51, clientY: 37, composed: true, bubbles: true});
+    target.dispatchEvent(mouseEvent);
+
+    assert_equals(host.offsetLeft, 20, 'The host must be at (20px, 10px)');
+    assert_equals(host.offsetTop, 10, 'The host must be at (20px, 10px)');
+    assert_equals(target.offsetLeft, 45, 'The target must be at (45px, 30px)');
+    assert_equals(target.offsetTop, 30, 'The target must be at (45px, 30px)');
+
+    assert_equals(eventLogs[0].current, target);
+    assert_equals(eventLogs[0].target, target);
+    assert_equals(eventLogs[0].offsetX, 21); // Padding edge of target is at (30px, 20px)
+    assert_equals(eventLogs[0].offsetY, 17);
+
+    assert_equals(eventLogs[1].current, container);
+    assert_equals(eventLogs[1].target, target);
+    assert_equals(eventLogs[1].offsetX, 21);
+    assert_equals(eventLogs[1].offsetY, 17);
+
+    assert_equals(eventLogs[3].current, host);
+    assert_equals(eventLogs[3].target, host);
+    assert_equals(eventLogs[3].offsetX, 31); // Padding edge of host is at (20px, 10px)
+    assert_equals(eventLogs[3].offsetY, 27);
+
+    assert_equals(eventLogs[4].current, document.body);
+    assert_equals(eventLogs[4].target, host);
+    assert_equals(eventLogs[4].offsetX, 31);
+    assert_equals(eventLogs[4].offsetY, 27);
+}, 'MouseEvent\'s offsetX and offsetY attributes must be relative to the shadow host when an event is dispatched inside its shadow tree.');
+
+test(function () {
+    shadowRoot.innerHTML = '&lt;style&gt;' + shadowStyle + '&lt;/style&gt;&lt;div id=&quot;container&quot;&gt;&lt;slot&gt;&lt;/slot&gt;&lt;/div&gt;';
+    host.innerHTML = '&lt;style&gt;' + shadowStyle + '&lt;/style&gt;&lt;div id=&quot;target&quot;&gt;Click here&lt;/div&gt;';
+
+    var target = host.querySelector('#target');
+    var container = shadowRoot.querySelector('#container');
+
+    var eventLogs = attachLoggers([target, container, shadowRoot, host, document.body]);
+    var mouseEvent = new MouseEvent('mousedown', {clientX: 51, clientY: 37, composed: true, bubbles: true});
+    target.dispatchEvent(mouseEvent);
+
+    assert_equals(host.offsetLeft, 20, 'The host must be at (20px, 10px)');
+    assert_equals(host.offsetTop, 10, 'The host must be at (20px, 10px)');
+    assert_equals(target.offsetLeft, 45, 'The target must be at (45px, 30px)');
+    assert_equals(target.offsetTop, 30, 'The target must be at (45px, 30px)');
+
+    assert_equals(eventLogs[0].current, target);
+    assert_equals(eventLogs[0].target, target);
+    assert_equals(eventLogs[0].target.offsetParent, document.body);
+    assert_equals(eventLogs[0].offsetX, 6); // Padding edge of target is at (45px, 30px)
+    assert_equals(eventLogs[0].offsetY, 7);
+
+    assert_equals(eventLogs[1].current, container);
+    assert_equals(eventLogs[1].target, target);
+    assert_equals(eventLogs[1].offsetX, 6);
+    assert_equals(eventLogs[1].offsetY, 7);
+
+    assert_equals(eventLogs[2].current, shadowRoot);
+    assert_equals(eventLogs[2].target, target);
+    assert_equals(eventLogs[2].offsetX, 6);
+    assert_equals(eventLogs[2].offsetY, 7);
+
+    assert_equals(eventLogs[3].current, host);
+    assert_equals(eventLogs[3].target, target);
+    assert_equals(eventLogs[3].offsetX, 6);
+    assert_equals(eventLogs[3].offsetY, 7);
+
+    assert_equals(eventLogs[4].current, document.body);
+    assert_equals(eventLogs[4].target, target);
+    assert_equals(eventLogs[4].offsetX, 6);
+    assert_equals(eventLogs[4].offsetY, 7);
+}, 'MouseEvent\'s offsetX and offsetY attributes must be relative to the target when an event is dispatched on a slotted content.');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomNodeprototypecloneNodeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Node-prototype-cloneNode-expected.txt (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Node-prototype-cloneNode-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Node-prototype-cloneNode-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+
+PASS cloneNode on a shadow root in open mode must throw a NotSupportedError 
+PASS cloneNode on a shadow root in closed mode must throw a NotSupportedError 
+PASS cloneNode on an element with an open shadow root should not clone its shadow root 
+PASS cloneNode on an element with a closed shadow root should not clone its shadow root 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomNodeprototypecloneNodehtmlfromrev206462trunkLayoutTestsfastshadowdomNodeprototypecloneNodehtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Node-prototype-cloneNode.html (from rev 206462, trunk/LayoutTests/fast/shadow-dom/Node-prototype-cloneNode.html) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Node-prototype-cloneNode.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Node-prototype-cloneNode.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;DOM: cloneNode(deep)&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;If context object is a shadow root, then it must throw a NotSupportedError.&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;https://dom.spec.whatwg.org/#dom-node-clonenode&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+function testCloneNode(mode) {
+    test(function () {
+        assert_throws({'name': 'NotSupportedError'}, function () {
+            var element = document.createElement('div');
+            var shadowRoot = element.attachShadow({mode: mode});
+            shadowRoot.cloneNode(false);
+        }, 'cloneNode(false) on a shadow root in ' + mode + ' mode must throw a NotSupportedError');
+
+        assert_throws({'name': 'NotSupportedError'}, function () {
+            var element = document.createElement('div');
+            var shadowRoot = element.attachShadow({mode: mode});
+            shadowRoot.cloneNode(false);
+        }, 'cloneNode(true) on a closed shadow root must throw a NotSupportedError');
+
+    }, 'cloneNode on a shadow root in ' + mode + ' mode must throw a NotSupportedError');
+}
+
+testCloneNode('open');
+testCloneNode('closed');
+
+test(function () {
+    var element = document.createElement('div');
+    var shadowRoot = element.attachShadow({mode: 'open'});
+
+    assert_equals(element.cloneNode(false).shadowRoot, null, 'cloneNode(false) on an element with an open shadow root should not clone its shadow root');
+    assert_equals(element.cloneNode(true).shadowRoot, null, 'cloneNode(true) on an element with an open shadow root should not clone its shadow root');
+}, 'cloneNode on an element with an open shadow root should not clone its shadow root');
+
+test(function () {
+    var element = document.createElement('div');
+    var shadowRoot = element.attachShadow({mode: 'closed'});
+
+    assert_true(element.cloneNode(false).attachShadow({mode: 'closed'}) instanceof ShadowRoot,
+        'An element returned by cloneNode(false) on an element with a closed shadow root should allow attachShadow');
+
+    assert_true(element.cloneNode(true).attachShadow({mode: 'closed'}) instanceof ShadowRoot,
+        'An element returned by cloneNode(true) on an element with a closed shadow root should allow attachShadow');
+
+}, 'cloneNode on an element with a closed shadow root should not clone its shadow root');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomOWNERS"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/OWNERS (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/OWNERS                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/OWNERS        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+@kojiishi
+@rniwa
+@sideshowbarker
+@sizuhiko
+@yutak
+@takayoshikochi
+@hayatoito
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomShadowRootinterfaceexpectedtxtfromrev206462trunkLayoutTestsfastshadowdomShadowRootinterfaceexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/ShadowRoot-interface-expected.txt (from rev 206462, trunk/LayoutTests/fast/shadow-dom/ShadowRoot-interface-expected.txt) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/ShadowRoot-interface-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/ShadowRoot-interface-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+
+PASS Check the existence of ShadowRoot interface 
+PASS ShadowRoot must inherit from DocumentFragment 
+PASS ShadowRoot must not be a constructor 
+PASS ShadowRoot.activeElement must return the focused element of the context object when shadow root is open. 
+PASS ShadowRoot.activeElement must return the focused element of the context object when shadow root is closed. 
+PASS ShadowRoot.host must return the shadow host of the context object. 
+PASS ShadowRoot.innerHTML must return the result of the HTML fragment serialization algorithm when shadow root is open. 
+PASS ShadowRoot.innerHTML must return the result of the HTML fragment serialization algorithm when shadow root is closed. 
+PASS ShadowRoot.innerHTML must replace all with the result of invoking the fragment parsing algorithm when shadow root is open. 
+PASS ShadowRoot.innerHTML must replace all with the result of invoking the fragment parsing algorithm when shadow root is closed. 
+FAIL ShadowRoot.styleSheets must return a StyleSheetList sequence containing the shadow root style sheets when shadow root is open. undefined is not an object (evaluating 'shadowRoot.styleSheets.length')
+FAIL ShadowRoot.styleSheets must return a StyleSheetList sequence containing the shadow root style sheets when shadow root is closed. undefined is not an object (evaluating 'shadowRoot.styleSheets.length')
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomShadowRootinterfacehtmlfromrev206462trunkLayoutTestsfastshadowdomShadowRootinterfacehtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/ShadowRoot-interface.html (from rev 206462, trunk/LayoutTests/fast/shadow-dom/ShadowRoot-interface.html) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/ShadowRoot-interface.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/ShadowRoot-interface.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,111 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;Shadow DOM: ShadowRoot interface&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;ShadowRoot interface and its attributes must be defined&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;https://w3c.github.io/webcomponents/spec/shadow/#the-shadowroot-interface&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+test(function () {
+    assert_true('ShadowRoot' in window, '&quot;ShadowRoot&quot; exists on window');
+}, 'Check the existence of ShadowRoot interface');
+
+test(function () {
+    assert_equals(ShadowRoot.prototype.__proto__, DocumentFragment.prototype, 'ShadowRoot must inherit from DocumentFragment');
+}, 'ShadowRoot must inherit from DocumentFragment');
+
+test(function () {
+    assert_throws({'name': 'TypeError'}, function () { new ShadowRoot(); }, 'new ShadowRoot() must throw a TypeError');
+}, 'ShadowRoot must not be a constructor');
+
+function testActiveElement(mode) {
+    test(function () {
+        var host = document.createElement('div');
+        document.body.appendChild(host);
+        var shadowRoot = host.attachShadow({'mode': mode});
+        shadowRoot.appendChild(document.createElement('input'));
+        assert_equals(shadowRoot.activeElement, null, 'ShadowRoot.host must return null if an ' + mode + ' shadow tree does not have a focused element');
+        shadowRoot.firstChild.focus();
+        assert_equals(shadowRoot.activeElement, shadowRoot.firstChild, 'ShadowRoot.host must return the focused element of an ' + mode + ' shadow tree');
+        host.remove();
+        assert_equals(shadowRoot.activeElement, null, 'ShadowRoot.host must return null if an ' + mode + ' shadow tree lost focus');
+    }, 'ShadowRoot.activeElement must return the focused element of the context object when shadow root is ' + mode + '.');
+}
+
+testActiveElement('open');
+testActiveElement('closed');
+
+test(function () {
+    var host1 = document.createElement('div');
+    assert_equals(host1.attachShadow({'mode': 'open'}).host, host1, 'ShadowRoot.host must return the shadow host of an open shadow tree')
+
+    var host2 = document.createElement('div');
+    assert_equals(host2.attachShadow({'mode': 'closed'}).host, host2, 'ShadowRoot.host must return the shadow host of a closed shadow tree');
+}, 'ShadowRoot.host must return the shadow host of the context object.');
+
+function testInnerHTML(mode) {
+    test(function () {
+        var host = document.createElement('div');
+        var shadowRoot = host.attachShadow({'mode': mode});
+        assert_equals(shadowRoot.innerHTML, '', 'ShadowRoot.innerHTML must be an empty string when the shadow root does not have any children');
+
+        shadowRoot.appendChild(document.createTextNode('hello'));
+        assert_equals(shadowRoot.innerHTML, 'hello', 'ShadowRoot.innerHTML must serialize a text node child');
+
+        shadowRoot.appendChild(document.createElement('span'));
+        assert_equals(shadowRoot.innerHTML, 'hello&lt;span&gt;&lt;/span&gt;', 'ShadowRoot.innerHTML must serialize a HTML element child');
+    }, 'ShadowRoot.innerHTML must return the result of the HTML fragment serialization algorithm when shadow root is ' + mode + '.');
+}
+
+testInnerHTML('open');
+testInnerHTML('closed');
+
+function testSetInnerHTML(mode) {
+    test(function () {
+        var host = document.createElement('div');
+        var shadowRoot = host.attachShadow({'mode': mode});
+        shadowRoot.innerHTML = 'hello';
+        assert_equals(shadowRoot.childNodes.length, 1, 'ShadowRoot.innerHTML = &quot;hello&quot; must insert a single child (text node)');
+        assert_true(shadowRoot.firstChild instanceof Text, 'The first child of the shadow root after ShadowRoot.innerHTML = &quot;hello&quot; must be a Text node');
+        assert_equals(shadowRoot.firstChild.data, 'hello', 'The first Text node should contain the string &quot;hello&quot; after ShadowRoot.innerHTML = &quot;hello&quot;');
+
+        shadowRoot.innerHTML = '&lt;b&gt;hello&lt;/b&gt;';
+        assert_equals(shadowRoot.childNodes.length, 1, 'ShadowRoot.innerHTML = &quot;&lt;b&gt;hello&lt;/b&gt;&quot; must insert a single child (b)');
+        assert_true(shadowRoot.firstChild instanceof HTMLElement, 'The first child of the shadow root after ShadowRoot.innerHTML = &quot;&lt;b&gt;hello&lt;/b&gt;&quot; must be a HTML element');
+        assert_equals(shadowRoot.firstChild.localName, 'b', 'The local name of the shadow root\'s first child after ShadowRoot.innerHTML = &quot;&lt;b&gt;hello&lt;/b&gt;&quot; must be &quot;b&quot;');
+        assert_equals(shadowRoot.innerHTML, '&lt;b&gt;hello&lt;/b&gt;', 'ShadowRoot.innerHTML must be &quot;&lt;b&gt;hello&lt;/b&gt;&quot; after ShadowRoot.innerHTML = &quot;&lt;b&gt;hello&lt;/b&gt;&quot;');
+
+        shadowRoot.innerHTML = '';
+        assert_equals(shadowRoot.childNodes.length, 0, 'ShadowRoot.innerHTML = &quot;&quot; must remove all its children');
+    }, 'ShadowRoot.innerHTML must replace all with the result of invoking the fragment parsing algorithm when shadow root is ' + mode + '.');
+}
+
+testSetInnerHTML('open');
+testSetInnerHTML('closed');
+
+function testStyleSheets(mode) {
+    test(function () {
+        var host = document.createElement('div');
+        var shadowRoot = host.attachShadow({'mode': mode});
+
+        assert_equals(shadowRoot.styleSheets.length, 0, 'shadowRoot.styleSheets must be empty when the shadow root does not contain any stylesheets');
+        shadowRoot.innerHTML = '&lt;span&gt;&lt;/span&gt;&lt;style&gt; a.rule {} &lt;/style&gt;&lt;style&gt; b.rule {} &lt;/style&gt;';
+        assert_equals(shadowRoot.styleSheets.length, 2, 'shadowRoot.styleSheets must contain two items when the shadow root has two style elements');
+        var styles = shadowRoot.querySelectorAll('style');
+        assert_equals(shadowRoot.styleSheets[0], styles[0].sheet, 'shadowRoot.styleSheets[0] must be the first style element in the shadow root');
+        assert_equals(shadowRoot.styleSheets[1], styles[1].sheet, 'shadowRoot.styleSheets[1] must be the second style element in the shadow root');
+    }, 'ShadowRoot.styleSheets must return a StyleSheetList sequence containing the shadow root style sheets when shadow root is ' + mode + '.');
+}
+
+testStyleSheets('open');
+testStyleSheets('closed');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomSlotableinterfaceexpectedtxtfromrev206462trunkLayoutTestsfastshadowdomSlotableinterfaceassignedSlotexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Slotable-interface-expected.txt (from rev 206462, trunk/LayoutTests/fast/shadow-dom/Slotable-interface-assignedSlot-expected.txt) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Slotable-interface-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Slotable-interface-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+
+PASS assignedSlot attribute must be defined on Element and Text interfaces 
+PASS assignedSlot must return null when the node does not have an assigned node 
+PASS assignedSlot must return the assigned slot 
+PASS assignedSlot must return null when the assigned slot element is inside a closed shadow tree 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomSlotableinterfacehtmlfromrev206462trunkLayoutTestsfastshadowdomSlotableinterfaceassignedSlothtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Slotable-interface.html (from rev 206462, trunk/LayoutTests/fast/shadow-dom/Slotable-interface-assignedSlot.html) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Slotable-interface.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Slotable-interface.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,94 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;Shadow DOM: Slotable interface&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;Element and Text interfaces must implement Slotable interface&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;https://dom.spec.whatwg.org/#slotable&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+test(function () {
+    assert_true('assignedSlot' in Element.prototype, 'assignedSlot must be defined on Element.prototype');
+    assert_true('assignedSlot' in document.createElement('div'), 'assignedSlot must be defined on a div element');
+
+    assert_true('assignedSlot' in Text.prototype, 'assignedSlot must be defined on Text.prototype');
+    assert_true('assignedSlot' in document.createTextNode(''), 'assignedSlot must be defined on a text node');
+    assert_false('assignedSlot' in document.createComment(''), 'assignedSlot must not be defined on a comment node');
+    assert_false('assignedSlot' in document.createProcessingInstruction('target', 'data'), 'assignedSlot must not be defined on a processing instruction node');
+
+}, 'assignedSlot attribute must be defined on Element and Text interfaces');
+
+test(function () {
+    assert_equals(document.createElement('div').assignedSlot, null, 'assignedSlot must be null when the element is not in any tree');
+
+    var shadowHost = document.createElement('div');
+    var shadowRoot = shadowHost.attachShadow({mode: 'open'});
+
+    var childElement = document.createElement('b');
+    shadowHost.appendChild(childElement);
+    assert_equals(childElement.assignedSlot, null, 'assignedSlot on an element must be null when a node is not assigned of any slot');
+
+    var childTextNode = document.createTextNode('');
+    shadowHost.appendChild(childTextNode);
+    assert_equals(childTextNode.assignedSlot, null, 'assignedSlot on a text node must be null when a node is not assigned of any slot');
+
+    var slot = document.createElement('slot');
+    slot.name = 'foo';
+    shadowRoot.appendChild(slot);
+    assert_equals(childElement.assignedSlot, null, 'assignedSlot on an element must be null when a node does not match any slot');
+    assert_equals(childTextNode.assignedSlot, null, 'assignedSlot on a text node must be null when a node does not match any slot');
+
+}, 'assignedSlot must return null when the node does not have an assigned node');
+
+test(function () {
+    var shadowHost = document.createElement('div');
+    var childElement = document.createElement('b');
+    shadowHost.appendChild(childElement);
+
+    var childTextNode = document.createTextNode('');
+    shadowHost.appendChild(childTextNode);
+
+    var shadowRoot = shadowHost.attachShadow({mode: 'open'});
+    var slot = document.createElement('slot');
+    shadowRoot.appendChild(slot);
+
+    assert_equals(childElement.assignedSlot, slot, 'assignedSlot on an element must return the assigned default slot element');
+    assert_equals(childTextNode.assignedSlot, slot, 'assignedSlot on a text node must return the assigned default slot element');
+
+    slot.name = 'foo';
+    assert_equals(childElement.assignedSlot, null, 'assignedSlot on an element must null when the element is unassigned from a slot element');
+    assert_equals(childTextNode.assignedSlot, null, 'assignedSlot on a text node must null when the node is unassigned from a slot element');
+
+    childElement.slot = 'foo';
+    assert_equals(childElement.assignedSlot, slot, 'assignedSlot on an element must return the re-assigned slot element');
+
+    slot.removeAttribute('name');
+    assert_equals(childTextNode.assignedSlot, slot, 'assignedSlot on a text node must return the re-assigned slot element');
+
+}, 'assignedSlot must return the assigned slot');
+
+test(function () {
+    var shadowHost = document.createElement('div');
+    var childElement = document.createElement('b');
+    shadowHost.appendChild(childElement);
+
+    var childTextNode = document.createTextNode('');
+    shadowHost.appendChild(childTextNode);
+
+    var shadowRoot = shadowHost.attachShadow({mode: 'closed'});
+    var slot = document.createElement('slot');
+    shadowRoot.appendChild(slot);
+
+    assert_equals(childElement.assignedSlot, null, 'assignedSlot on an element must return null if the slot is inside a closed shadow tree.');
+    assert_equals(childTextNode.assignedSlot, null, 'assignedSlot on a text node must return null if the slot is inside a closed shadow tree.');
+
+}, 'assignedSlot must return null when the assigned slot element is inside a closed shadow tree');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventcomposedexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-expected.txt (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+
+PASS A new events composed value should be set to false by default. 
+PASS Users should be able to set a composed value. 
+PASS An event should be scoped by default 
+PASS An event should not be scoped if composed is specified 
+PASS A synthetic MouseEvent should be scoped by default 
+PASS A synthetic MouseEvent with composed=true should not be scoped 
+PASS A synthetic FocusEvent should be scoped by default 
+PASS A synthetic FocusEvent with composed=true should not be scoped 
+FAIL A UA click event should not be scoped assert_equals: expected 3 but got 2
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventcomposedpathexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path-expected.txt (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+
+PASS Event Path without ShadowRoots. 
+PASS Event Path with an open ShadowRoot. 
+PASS Event Path with a closed ShadowRoot. 
+PASS Event Path with nested ShadowRoots: open &gt; open. 
+PASS Event Path with nested ShadowRoots: open &gt; closed. 
+PASS Event Path with nested ShadowRoots: closed &gt; open. 
+PASS Event Path with nested ShadowRoots: closed &gt; closed. 
+PASS Event Path with a slot in an open Shadow Root. 
+PASS Event Path with a slot in a closed Shadow Root. 
+PASS Event Path with slots in nested ShadowRoots: open &gt; open. 
+PASS Event Path with slots in nested ShadowRoots: closed &gt; closed. 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventcomposedpathwithrelatedtargetexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path-with-related-target-expected.txt (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path-with-related-target-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path-with-related-target-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+
+PASS Event path for an event with a relatedTarget. relatedTarget != target. 
+PASS Event path for an event with a relatedTarget. Event shoul be dispatched if 1) target and relatedTarget are same, and 2) they are not in a shadow tree. 
+PASS Event path for an event with a relatedTarget. Event should stop at the shadow root 
+FAIL Event path for an event with a relatedTarget. Event should not be dispatched if 1) target and relatedTarget are same, and 2) both are in a shadow tree. assert_equals: expected 0 but got 2
+PASS Event path for an event with a relatedTarget. target and relaterTarget do not share any shadow-including ancestor. target is in a shadow tree. 
+PASS Event path for an event with a relatedTarget. target and relaterTarget do not share any shadow-including ancestor. target is not in a shadow tree 
+PASS Event path for an event with a relatedTarget. target and relaterTarget share the same shadow-including ancestor. Both are in shadow trees. 
+PASS Event path for an event with a relatedTarget. relaterTarget is a shadow-including ancestor of target. 
+PASS Event path for an event with a relatedTarget. target is a shadow-including ancestor of relatedTarget. 
+PASS Event path for an event with a relatedTarget. target is assigned to a slot. 
+PASS Event path for an event with a relatedTarget. relatedTarget is assigned to a slot. 
+PASS Event path for an event with a relatedTarget. Event should be dispatched at every slots. 
+PASS Event path for an event with a relatedTarget. Event should be dispatched at every slots. relatedTarget should be correctly retargeted. 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventcomposedpathwithrelatedtargethtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path-with-related-target.html (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path-with-related-target.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path-with-related-target.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,256 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;title&gt;Shadow DOM: Event path and Event.composedPath() (with related target)&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Hayato Ito&quot; href=&quot;mailto:hayato@google.com&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/shadow-dom.js&quot;&gt;&lt;/script&gt;
+
+&lt;div id=&quot;test1&quot;&gt;
+  &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+  &lt;div id=&quot;related&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test1);
+  let log = dispatchEventWithLog(n, n.target, new FocusEvent('my-focus', { bubbles: true, composed: true, relatedTarget: n.related }));
+  let path = ['target', 'test1'];
+  assert_event_path_equals(log, [['target', 'target', 'related', path],
+                                 ['test1', 'target', 'related', path]]);
+}, 'Event path for an event with a relatedTarget. relatedTarget != target.');
+&lt;/script&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test1);
+  let log = dispatchEventWithLog(n, n.target, new FocusEvent('my-focus', { bubbles: true, composed: true, relatedTarget: n.target }));
+  let path = ['target', 'test1'];
+  assert_event_path_equals(log, [['target', 'target', 'target', path],
+                                 ['test1', 'target', 'target', path]]);
+}, 'Event path for an event with a relatedTarget. Event shoul be dispatched if 1) target and relatedTarget are same, and 2) they are not in a shadow tree.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test2&quot;&gt;
+  &lt;div id=&quot;host&quot;&gt;
+    &lt;template id=&quot;sr&quot; data-mode=&quot;open&quot;&gt;
+      &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+      &lt;div id=&quot;related&quot;&gt;&lt;/div&gt;
+    &lt;/template&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test2);
+  let log = dispatchEventWithLog(n, n.target, new FocusEvent('my-focus', { bubbles: true, composed: true, relatedTarget: n.related }));
+  let path = ['target', 'sr'];
+  assert_event_path_equals(log, [['target', 'target', 'related', path],
+                                 ['sr', 'target', 'related', path]]);
+}, 'Event path for an event with a relatedTarget. Event should stop at the shadow root');
+
+test(() =&gt; {
+  let n = createTestTree(test2);
+  let log = dispatchEventWithLog(n, n.target, new FocusEvent('my-focus', { bubbles: true, composed: true, relatedTarget: n.target }));
+  assert_event_path_equals(log, []);
+}, 'Event path for an event with a relatedTarget. Event should not be dispatched if 1) target and relatedTarget are same, and 2) both are in a shadow tree.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test3_1&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template id=&quot;sr1&quot; data-mode=&quot;open&quot;&gt;
+      &lt;div id=&quot;target1&quot;&gt;&lt;/div&gt;
+    &lt;/template&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div id=&quot;test3_2&quot;&gt;
+  &lt;div id=&quot;host2&quot;&gt;
+    &lt;template id=&quot;sr2&quot; data-mode=&quot;open&quot;&gt;
+      &lt;div id=&quot;target2&quot;&gt;&lt;/div&gt;
+    &lt;/template&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n1 = createTestTree(test3_1);
+  let n2 = createTestTree(test3_2);
+  let log = dispatchEventWithLog(n1, n1.target1, new FocusEvent('my-focus', { bubbles: true, composed: true, relatedTarget: n2.target2 }));
+  let path = ['target1', 'sr1', 'host1', 'test3_1'];
+  assert_event_path_equals(log, [['target1', 'target1', 'host2', path],
+                                 ['sr1',     'target1', 'host2', path],
+                                 ['host1',   'host1',   'host2', path],
+                                 ['test3_1', 'host1',   'host2', path]]);
+}, 'Event path for an event with a relatedTarget. target and relaterTarget do not share any shadow-including ancestor. target is in a shadow tree.');
+
+test(() =&gt; {
+  let n1 = createTestTree(test3_1);
+  let n2 = createTestTree(test3_2);
+  let log = dispatchEventWithLog(n1, n1.host1, new FocusEvent('my-focus', { bubbles: true, composed: true, relatedTarget: n2.target2 }));
+  let path = ['host1', 'test3_1'];
+  assert_event_path_equals(log, [['host1',   'host1',   'host2', path],
+                                 ['test3_1', 'host1',   'host2', path]]);
+}, 'Event path for an event with a relatedTarget. target and relaterTarget do not share any shadow-including ancestor. target is not in a shadow tree');
+&lt;/script&gt;
+
+&lt;div id=&quot;test4&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template id=&quot;sr1&quot; data-mode=&quot;open&quot;&gt;
+      &lt;div id=&quot;host2&quot;&gt;
+        &lt;template id=&quot;sr2&quot; data-mode=&quot;open&quot;&gt;
+          &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+        &lt;/template&gt;
+      &lt;/div&gt;
+      &lt;div id=&quot;host3&quot;&gt;
+        &lt;template id=&quot;sr3&quot; data-mode=&quot;open&quot;&gt;
+          &lt;div id=&quot;related&quot;&gt;&lt;/div&gt;
+        &lt;/template&gt;
+      &lt;/div&gt;
+    &lt;/template&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test4);
+  let log = dispatchEventWithLog(n, n.target, new FocusEvent('my-focus', { bubbles: true, composed: true, relatedTarget: n.related }));
+  let path = ['target', 'sr2', 'host2', 'sr1'];
+  assert_event_path_equals(log, [['target', 'target', 'host3', path],
+                                 ['sr2', 'target', 'host3', path],
+                                 ['host2', 'host2', 'host3', path],
+                                 ['sr1', 'host2', 'host3', path]]);
+}, 'Event path for an event with a relatedTarget. target and relaterTarget share the same shadow-including ancestor. Both are in shadow trees.');
+
+test(() =&gt; {
+  let n = createTestTree(test4);
+  let log = dispatchEventWithLog(n, n.target, new FocusEvent('my-focus', { bubbles: true, composed: true, relatedTarget: n.host1 }));
+  let path = ['target', 'sr2', 'host2', 'sr1'];
+  assert_event_path_equals(log, [['target', 'target', 'host1', path],
+                                 ['sr2', 'target', 'host1', path],
+                                 ['host2', 'host2', 'host1', path],
+                                 ['sr1', 'host2', 'host1', path]]);
+}, 'Event path for an event with a relatedTarget. relaterTarget is a shadow-including ancestor of target.');
+
+test(() =&gt; {
+  let n = createTestTree(test4);
+  let log = dispatchEventWithLog(n, n.host1, new FocusEvent('my-focus', { bubbles: true, composed: true, relatedTarget: n.target }));
+  assert_event_path_equals(log, []);
+}, 'Event path for an event with a relatedTarget. target is a shadow-including ancestor of relatedTarget.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test5&quot;&gt;
+  &lt;div id=&quot;host&quot;&gt;
+    &lt;template id=&quot;sr&quot; data-mode=&quot;open&quot;&gt;
+      &lt;slot id=&quot;slot&quot;&gt;&lt;/slot&gt;
+      &lt;div id=&quot;related&quot;&gt;&lt;/div&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test5);
+  let log = dispatchEventWithLog(n, n.target, new FocusEvent('my-focus', { bubbles: true, composed: true, relatedTarget: n.related }));
+  let path = ['target', 'slot', 'sr', 'host', 'test5'];
+  assert_event_path_equals(log, [['target', 'target', 'host', path],
+                                 ['slot', 'target', 'related', path],
+                                 ['sr', 'target', 'related', path],
+                                 ['host', 'target', 'host', path],
+                                 ['test5', 'target', 'host', path]]);
+}, 'Event path for an event with a relatedTarget. target is assigned to a slot.');
+
+test(() =&gt; {
+  let n = createTestTree(test5);
+  let log = dispatchEventWithLog(n, n.related, new FocusEvent('my-focus', { bubbles: true, composed: true, relatedTarget: n.target }));
+  let path = ['related', 'sr', 'host', 'test5'];
+  assert_event_path_equals(log, [['related', 'related', 'target', path],
+                                 ['sr', 'related', 'target', path],
+                                 ['host', 'host', 'target', path],
+                                 ['test5', 'host', 'target', path]]);
+}, 'Event path for an event with a relatedTarget. relatedTarget is assigned to a slot.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test6&quot;&gt;
+  &lt;div id=&quot;host0&quot;&gt;
+    &lt;template id=&quot;sr0&quot; data-mode=&quot;open&quot;&gt;
+      &lt;div id=&quot;host1&quot;&gt;
+        &lt;template id=&quot;sr1&quot; data-mode=&quot;open&quot;&gt;
+          &lt;div id=&quot;host2&quot;&gt;
+            &lt;template id=&quot;sr2&quot; data-mode=&quot;open&quot;&gt;
+              &lt;slot id=&quot;slot2&quot;&gt;&lt;/slot&gt;
+              &lt;div id=&quot;related2&quot;&gt;&lt;/div&gt;
+            &lt;/template&gt;
+            &lt;div id=&quot;related1&quot;&gt;&lt;/div&gt;
+            &lt;div id=&quot;d1&quot;&gt;
+              &lt;slot id=&quot;slot1&quot;&gt;&lt;/slot&gt;
+            &lt;/div&gt;
+          &lt;/div&gt;
+        &lt;/template&gt;
+        &lt;div id=&quot;host3&quot;&gt;
+          &lt;template id=&quot;sr3&quot; data-mode=&quot;open&quot;&gt;
+            &lt;div id=&quot;host4&quot;&gt;
+              &lt;template id=&quot;sr4&quot; data-mode=&quot;open&quot;&gt;
+                &lt;div id=&quot;host5&quot;&gt;
+                  &lt;template id=&quot;sr5&quot; data-mode=&quot;open&quot;&gt;
+                    &lt;slot id=&quot;slot5&quot;&gt;&lt;/slot&gt;
+                  &lt;/template&gt;
+                  &lt;slot id=&quot;slot4&quot;&gt;&lt;/slot&gt;
+                &lt;/div&gt;
+              &lt;/template&gt;
+              &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+            &lt;/div&gt;
+          &lt;/template&gt;
+        &lt;/div&gt;
+      &lt;/div&gt;
+    &lt;/template&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test6);
+  let log = dispatchEventWithLog(n, n.target, new FocusEvent('my-focus', { bubbles: true, composed: true, relatedTarget: n.related1 }));
+  let path = ['target', 'slot4', 'slot5', 'sr5', 'host5', 'sr4', 'host4', 'sr3', 'host3', 'slot1', 'd1', 'slot2', 'sr2', 'host2', 'sr1', 'host1', 'sr0'];
+  assert_event_path_equals(log, [['target',  'target', 'host1',    path],
+                                 ['slot4',   'target', 'host1',    path],
+                                 ['slot5',   'target', 'host1',    path],
+                                 ['sr5',     'target', 'host1',    path],
+                                 ['host5',   'target', 'host1',    path],
+                                 ['sr4',     'target', 'host1',    path],
+                                 ['host4',   'target', 'host1',    path],
+                                 ['sr3',     'target', 'host1',    path],
+                                 ['host3',   'host3',  'host1',    path],
+                                 ['slot1',   'host3',  'related1', path],
+                                 ['d1'   ,   'host3',  'related1', path],
+                                 ['slot2',   'host3',  'related1', path],
+                                 ['sr2',     'host3',  'related1', path],
+                                 ['host2',   'host3',  'related1', path],
+                                 ['sr1',     'host3',  'related1', path],
+                                 ['host1',   'host3',  'host1',    path],
+                                 ['sr0',     'host3',  'host1'   , path]]);
+}, 'Event path for an event with a relatedTarget. Event should be dispatched at every slots.');
+
+test(() =&gt; {
+  let n = createTestTree(test6);
+  let log = dispatchEventWithLog(n, n.target, new FocusEvent('my-focus', { bubbles: true, composed: true, relatedTarget: n.related2 }));
+  let path = ['target', 'slot4', 'slot5', 'sr5', 'host5', 'sr4', 'host4', 'sr3', 'host3', 'slot1', 'd1', 'slot2', 'sr2', 'host2', 'sr1', 'host1', 'sr0'];
+  assert_event_path_equals(log, [['target',  'target', 'host1',    path],
+                                 ['slot4',   'target', 'host1',    path],
+                                 ['slot5',   'target', 'host1',    path],
+                                 ['sr5',     'target', 'host1',    path],
+                                 ['host5',   'target', 'host1',    path],
+                                 ['sr4',     'target', 'host1',    path],
+                                 ['host4',   'target', 'host1',    path],
+                                 ['sr3',     'target', 'host1',    path],
+                                 ['host3',   'host3',  'host1',    path],
+                                 ['slot1',   'host3',  'host2',    path],
+                                 ['d1'   ,   'host3',  'host2',    path],
+                                 ['slot2',   'host3',  'related2', path],
+                                 ['sr2',     'host3',  'related2', path],
+                                 ['host2',   'host3',  'host2',    path],
+                                 ['sr1',     'host3',  'host2',    path],
+                                 ['host1',   'host3',  'host1',    path],
+                                 ['sr0',     'host3',  'host1'   , path]]);
+}, 'Event path for an event with a relatedTarget. Event should be dispatched at every slots. relatedTarget should be correctly retargeted.');
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventcomposedpathhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path.html (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,281 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;title&gt;Shadow DOM: Event path and Event.composedPath()&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Hayato Ito&quot; href=&quot;mailto:hayato@google.com&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/shadow-dom.js&quot;&gt;&lt;/script&gt;
+
+&lt;div id=&quot;test1&quot;&gt;
+  &lt;div id=&quot;d1&quot;&gt;
+    &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test1);
+  let log = dispatchEventWithLog(n, n.target, new Event('my-event', { bubbles: true, composed: true }));
+  let path = ['target', 'd1', 'test1'];
+  assert_event_path_equals(log,
+                           [['target', 'target', null, path],
+                            ['d1', 'target', null, path],
+                            ['test1', 'target', null, path]]);
+}, 'Event Path without ShadowRoots.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test2&quot;&gt;
+  &lt;div id=&quot;host&quot;&gt;
+    &lt;template id=&quot;sr&quot; data-mode=&quot;open&quot;&gt;
+      &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+    &lt;/template&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test2);
+  let log = dispatchEventWithLog(n, n.target, new Event('my-event', { bubbles: true, composed: true }));
+  let path = ['target', 'sr', 'host', 'test2'];
+  assert_event_path_equals(log,
+                           [['target', 'target', null, path],
+                            ['sr', 'target', null, path],
+                            ['host', 'host', null, path],
+                            ['test2', 'host', null, path]]);
+}, 'Event Path with an open ShadowRoot.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test3&quot;&gt;
+  &lt;div id=&quot;host&quot;&gt;
+    &lt;template id=&quot;sr&quot; data-mode=&quot;closed&quot;&gt;
+      &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+    &lt;/template&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test3);
+  let log = dispatchEventWithLog(n, n.target, new Event('my-event', { bubbles: true, composed: true }));
+  let path = ['target','sr', 'host', 'test3'];
+  let path1 = ['host', 'test3'];
+  assert_event_path_equals(log, [['target', 'target', null, path],
+                                 ['sr', 'target', null, path],
+                                 ['host', 'host', null, path1],
+                                 ['test3', 'host', null, path1]]);
+}, 'Event Path with a closed ShadowRoot.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test4&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template id=&quot;sr1&quot; data-mode=&quot;open&quot;&gt;
+      &lt;div id=&quot;host2&quot;&gt;
+        &lt;template id=&quot;sr2&quot; data-mode=&quot;open&quot;&gt;
+          &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+        &lt;/template&gt;
+      &lt;/div&gt;
+    &lt;/template&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test4);
+  let log = dispatchEventWithLog(n, n.target, new Event('my-event', { bubbles: true, composed: true }));
+  let path = ['target', 'sr2', 'host2', 'sr1', 'host1', 'test4'];
+  assert_event_path_equals(log, [['target', 'target', null, path],
+                                 ['sr2', 'target', null, path],
+                                 ['host2', 'host2', null, path],
+                                 ['sr1', 'host2', null, path],
+                                 ['host1', 'host1', null, path],
+                                 ['test4', 'host1', null, path]]);
+}, 'Event Path with nested ShadowRoots: open &gt; open.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test5&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template id=&quot;sr1&quot; data-mode=&quot;open&quot;&gt;
+      &lt;div id=&quot;host2&quot;&gt;
+        &lt;template id=&quot;sr2&quot; data-mode=&quot;closed&quot;&gt;
+          &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+        &lt;/template&gt;
+      &lt;/div&gt;
+    &lt;/template&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test5);
+  let log = dispatchEventWithLog(n, n.target, new Event('my-event', { bubbles: true, composed: true }));
+  let path = ['target', 'sr2', 'host2', 'sr1', 'host1', 'test5'];
+  let path1 = ['host2', 'sr1', 'host1', 'test5'];
+  assert_event_path_equals(log, [['target', 'target', null, path],
+                                 ['sr2', 'target', null, path],
+                                 ['host2', 'host2', null, path1],
+                                 ['sr1', 'host2', null, path1],
+                                 ['host1', 'host1', null, path1],
+                                 ['test5', 'host1', null, path1]]);
+}, 'Event Path with nested ShadowRoots: open &gt; closed.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test6&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template id=&quot;sr1&quot; data-mode=&quot;closed&quot;&gt;
+      &lt;div id=&quot;host2&quot;&gt;
+        &lt;template id=&quot;sr2&quot; data-mode=&quot;open&quot;&gt;
+          &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+        &lt;/template&gt;
+      &lt;/div&gt;
+    &lt;/template&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test6);
+  let log = dispatchEventWithLog(n, n.target, new Event('my-event', { bubbles: true, composed: true }));
+  let path = ['target', 'sr2', 'host2', 'sr1', 'host1', 'test6'];
+  let path1 = ['host1', 'test6'];
+  assert_event_path_equals(log, [['target', 'target', null, path],
+                                 ['sr2', 'target', null, path],
+                                 ['host2', 'host2', null, path],
+                                 ['sr1', 'host2', null, path],
+                                 ['host1', 'host1', null, path1],
+                                 ['test6', 'host1', null, path1]]);
+}, 'Event Path with nested ShadowRoots: closed &gt; open.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test7&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template id=&quot;sr1&quot; data-mode=&quot;closed&quot;&gt;
+      &lt;div id=&quot;host2&quot;&gt;
+        &lt;template id=&quot;sr2&quot; data-mode=&quot;closed&quot;&gt;
+          &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+        &lt;/template&gt;
+      &lt;/div&gt;
+    &lt;/template&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test7);
+  let log = dispatchEventWithLog(n, n.target, new Event('my-event', { bubbles: true, composed: true }));
+  let path = ['target', 'sr2', 'host2', 'sr1', 'host1', 'test7'];
+  let path1 = ['host2', 'sr1', 'host1', 'test7'];
+  let path2 = ['host1', 'test7'];
+  assert_event_path_equals(log, [['target', 'target', null, path],
+                                 ['sr2', 'target', null, path],
+                                 ['host2', 'host2', null, path1],
+                                 ['sr1', 'host2', null, path1],
+                                 ['host1', 'host1', null, path2],
+                                 ['test7', 'host1', null, path2]]);
+}, 'Event Path with nested ShadowRoots: closed &gt; closed.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test8&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template id=&quot;sr1&quot; data-mode=&quot;open&quot;&gt;
+      &lt;slot id=&quot;slot&quot;&gt;&lt;/slot&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test8);
+  let log = dispatchEventWithLog(n, n.target, new Event('my-event', { bubbles: true, composed: true }));
+  let path = ['target','slot', 'sr1', 'host1', 'test8'];
+  assert_event_path_equals(log, [['target', 'target', null, path],
+                                 ['slot', 'target', null, path],
+                                 ['sr1', 'target', null, path],
+                                 ['host1', 'target', null, path],
+                                 ['test8', 'target', null, path]]);
+}, 'Event Path with a slot in an open Shadow Root.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test9&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template id=&quot;sr1&quot; data-mode=&quot;closed&quot;&gt;
+      &lt;slot id=&quot;slot&quot;&gt;&lt;/slot&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test9);
+  let log = dispatchEventWithLog(n, n.target, new Event('my-event', { bubbles: true, composed: true }));
+  let path = ['target', 'slot', 'sr1', 'host1', 'test9'];
+  let path1 = ['target', 'host1', 'test9'];
+  assert_event_path_equals(log, [['target', 'target', null, path1],
+                                 ['slot', 'target', null, path],
+                                 ['sr1', 'target', null, path],
+                                 ['host1', 'target', null, path1],
+                                 ['test9', 'target', null, path1]]);
+}, 'Event Path with a slot in a closed Shadow Root.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test10&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template id=&quot;sr1&quot; data-mode=&quot;open&quot;&gt;
+      &lt;div id=&quot;host2&quot;&gt;
+        &lt;template id=&quot;sr2&quot; data-mode=&quot;open&quot;&gt;
+          &lt;slot id=&quot;slot2&quot;&gt;&lt;/slot&gt;
+        &lt;/template&gt;
+        &lt;slot id=&quot;slot1&quot;&gt;&lt;/slot&gt;
+      &lt;/div&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test10);
+  let log = dispatchEventWithLog(n, n.target, new Event('my-event', { bubbles: true, composed: true }));
+  let path = ['target','slot1', 'slot2', 'sr2', 'host2', 'sr1', 'host1', 'test10'];
+  assert_event_path_equals(log, [['target', 'target', null, path],
+                                 ['slot1', 'target', null, path],
+                                 ['slot2', 'target', null, path],
+                                 ['sr2', 'target', null, path],
+                                 ['host2', 'target', null, path],
+                                 ['sr1', 'target', null, path],
+                                 ['host1', 'target', null, path],
+                                 ['test10', 'target', null, path]]);
+}, 'Event Path with slots in nested ShadowRoots: open &gt; open.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test11&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template id=&quot;sr1&quot; data-mode=&quot;closed&quot;&gt;
+      &lt;div id=&quot;host2&quot;&gt;
+        &lt;template id=&quot;sr2&quot; data-mode=&quot;closed&quot;&gt;
+          &lt;slot id=&quot;slot2&quot;&gt;&lt;/slot&gt;
+        &lt;/template&gt;
+        &lt;slot id=&quot;slot1&quot;&gt;&lt;/slot&gt;
+      &lt;/div&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test11);
+  let log = dispatchEventWithLog(n, n.target, new Event('my-event', { bubbles: true, composed: true }));
+  let path = ['target', 'slot1', 'slot2', 'sr2', 'host2', 'sr1', 'host1', 'test11'];
+  let path1 = ['target', 'slot1', 'host2', 'sr1', 'host1', 'test11'];
+  let path2 = ['target', 'host1', 'test11'];
+  assert_event_path_equals(log, [['target', 'target', null, path2],
+                                 ['slot1', 'target', null, path1],
+                                 ['slot2', 'target', null, path],
+                                 ['sr2', 'target', null, path],
+                                 ['host2', 'target', null, path1],
+                                 ['sr1', 'target', null, path1],
+                                 ['host1', 'target', null, path2],
+                                 ['test11', 'target', null, path2]]);
+}, 'Event Path with slots in nested ShadowRoots: closed &gt; closed.');
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventcomposedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed.html (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,81 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;title&gt;Shadow DOM: Event composed&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Hayato Ito&quot; href=&quot;mailto:hayato@google.com&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/shadow-dom.js&quot;&gt;&lt;/script&gt;
+&lt;div id=host&gt;
+  &lt;template id=shadowRoot data-mode=open&gt;
+    &lt;div id=target&gt;&lt;/div&gt;
+  &lt;/template&gt;
+&lt;/div&gt;
+&lt;script&gt;
+test(() =&gt; {
+  const e = new Event('test');
+  assert_equals(e.composed, false);
+}, 'A new events composed value should be set to false by default.');
+
+test(() =&gt; {
+  const e = new Event('test', { composed: true });
+  assert_equals(e.composed, true);
+}, 'Users should be able to set a composed value.');
+
+function assertScoped(event) {
+  let nodes = createTestTree(host);
+  let log = dispatchEventWithLog(nodes, nodes.target, event);
+  let expectedPath = ['target', 'shadowRoot'];
+  assert_event_path_equals(log,
+                           [['target', 'target', null, expectedPath],
+                            ['shadowRoot', 'target', null, expectedPath]]);
+}
+
+function assertComposed(event) {
+  let nodes = createTestTree(host);
+  let log = dispatchEventWithLog(nodes, nodes.target, event);
+  let expectedPath = ['target', 'shadowRoot', 'host'];
+  assert_event_path_equals(log,
+                           [['target', 'target', null, expectedPath],
+                            ['shadowRoot', 'target', null, expectedPath],
+                            ['host', 'host', null, expectedPath]]);
+}
+
+test(() =&gt; {
+  assertScoped(new Event('test', { bubbles: true }));
+}, 'An event should be scoped by default');
+
+test(() =&gt; {
+  assertComposed(new Event('test', { bubbles: true, composed: true }));
+}, 'An event should not be scoped if composed is specified');
+
+test(() =&gt; {
+  assertScoped(new MouseEvent('click', { bubbles: true }));
+}, 'A synthetic MouseEvent should be scoped by default');
+
+test(() =&gt; {
+  assertComposed(new MouseEvent('click', { bubbles: true, composed: true }));
+}, 'A synthetic MouseEvent with composed=true should not be scoped');
+
+test(() =&gt; {
+  assertScoped(new FocusEvent('focus', { bubbles: true }));
+}, 'A synthetic FocusEvent should be scoped by default');
+
+test(() =&gt; {
+  assertComposed(new FocusEvent('focus', { bubbles: true, composed: true }));
+}, 'A synthetic FocusEvent with composed=true should not be scoped');
+
+function assertUAComposed(eventType, callback) {
+  let nodes = createTestTree(host);
+  let log = dispatchUAEventWithLog(nodes, nodes.target, eventType, callback);
+  let expectedPath = ['target', 'shadowRoot', 'host'];
+  assert_event_path_equals(log,
+                           [['target', 'target', null, expectedPath],
+                            ['shadowRoot', 'target', null, expectedPath],
+                            ['host', 'host', null, expectedPath]]);
+}
+
+test(() =&gt; {
+  assertUAComposed('click', (target) =&gt; { target.click(); });
+}, 'A UA click event should not be scoped');
+
+// TODO(hayato): Test other UIEvents.
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventinsideshadowtreeexpectedtxtfromrev206462trunkLayoutTestsfastshadowdomeventinsideshadowtreeexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-shadow-tree-expected.txt (from rev 206462, trunk/LayoutTests/fast/shadow-dom/event-inside-shadow-tree-expected.txt) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-shadow-tree-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-shadow-tree-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+
+PASS Firing an event inside a grand child of a detached open mode shadow tree 
+PASS Firing an event inside a grand child of a detached closed mode shadow tree 
+PASS Firing an event inside a grand child of an in-document open mode shadow tree 
+PASS Firing an event inside a grand child of an in-document closed mode shadow tree 
+PASS Firing an event inside a detached open mode shadow tree inside open mode shadow tree 
+PASS Firing an event inside a detached open mode shadow tree inside closed mode shadow tree 
+PASS Firing an event inside a detached closed mode shadow tree inside open mode shadow tree 
+PASS Firing an event inside a detached closed mode shadow tree inside closed mode shadow tree 
+PASS Firing an event inside an in-document open mode shadow tree inside open mode shadow tree 
+PASS Firing an event inside an in-document open mode shadow tree inside closed mode shadow tree 
+PASS Firing an event inside an in-document closed mode shadow tree inside open mode shadow tree 
+PASS Firing an event inside an in-document closed mode shadow tree inside closed mode shadow tree 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventinsideshadowtreehtmlfromrev206462trunkLayoutTestsfastshadowdomeventinsideshadowtreehtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-shadow-tree.html (from rev 206462, trunk/LayoutTests/fast/shadow-dom/event-inside-shadow-tree.html) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-shadow-tree.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-shadow-tree.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,148 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;Shadow DOM: Firing an event inside a shadow tree&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;The event path calculation algorithm must be used to determine event path&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;https://w3c.github.io/webcomponents/spec/shadow/#event-paths&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+function dispatchEventWithLog(target, event) {
+    var log = [];
+
+    for (var node = target; node; node = node.parentNode || node.host) {
+        node.addEventListener(event.type, (function (event) {
+            log.push([this, event.target]);
+        }).bind(node));
+    }
+
+    target.dispatchEvent(event);
+
+    return log;
+}
+
+function createShadowRootWithGrandChild(mode) {
+    var host = document.createElement('div');
+    var root = host.attachShadow({mode: mode});
+
+    var parent = document.createElement('span');
+    root.appendChild(parent);
+
+    var target = document.createElement('b');
+    parent.appendChild(target);
+    return {target: target, parent: parent, root: root, host: host};
+}
+
+function testEventInDetachedShadowTree(mode) {
+    test(function () {
+        var shadow = createShadowRootWithGrandChild(mode);
+
+        log = dispatchEventWithLog(shadow.target, new Event('foo', {composed: true, bubbles: true}));
+
+        assert_array_equals(log.length, 4, 'EventPath must contain [target, parent, shadow root, shadow host]');
+        assert_array_equals(log[0], [shadow.target, shadow.target], 'EventPath[0] must be the target');
+        assert_array_equals(log[1], [shadow.parent, shadow.target], 'EventPath[1] must be the parent of the target');
+        assert_array_equals(log[2], [shadow.root, shadow.target], 'EventPath[2] must be the shadow root');
+        assert_array_equals(log[3], [shadow.host, shadow.host], 'EventPath[3] must be the shadow host');
+
+    }, 'Firing an event inside a grand child of a detached ' + mode + ' mode shadow tree');
+}
+
+testEventInDetachedShadowTree('open');
+testEventInDetachedShadowTree('closed');
+
+function testEventInShadowTreeInsideDocument(mode) {
+    test(function () {
+        var shadow = createShadowRootWithGrandChild(mode);
+        document.body.appendChild(shadow.host);
+
+        log = dispatchEventWithLog(shadow.target, new Event('foo', {composed: true, bubbles: true}));
+
+        assert_array_equals(log.length, 7, 'EventPath must contain [target, parent, shadow root, shadow host, body, html, document]');
+        assert_array_equals(log[0], [shadow.target, shadow.target], 'EventPath[0] must be the target');
+        assert_array_equals(log[1], [shadow.parent, shadow.target], 'EventPath[1] must be the parent of the target');
+        assert_array_equals(log[2], [shadow.root, shadow.target], 'EventPath[2] must be the shadow root');
+        assert_array_equals(log[3], [shadow.host, shadow.host], 'EventPath[3] must be the shadow host');
+        assert_array_equals(log[4], [document.body, shadow.host], 'EventPath[4] must be the body element (parent of shadow host)');
+        assert_array_equals(log[5], [document.documentElement, shadow.host], 'EventPath[5] must be the html element');
+        assert_array_equals(log[6], [document, shadow.host], 'EventPath[6] must be the document node');
+
+    }, 'Firing an event inside a grand child of an in-document ' + mode + ' mode shadow tree');
+}
+
+testEventInShadowTreeInsideDocument('open');
+testEventInShadowTreeInsideDocument('closed');
+
+function createNestedShadowRoot(innerMode, outerMode) {
+    var outerHost = document.createElement('div');
+    var outerRoot = outerHost.attachShadow({mode: outerMode});
+
+    var outerChild = document.createElement('p');
+    outerRoot.appendChild(outerChild);
+
+    var innerHost = document.createElement('span');
+    outerChild.appendChild(innerHost);
+
+    var innerRoot = innerHost.attachShadow({mode: innerMode});
+    var innerChild = document.createElement('span');
+    innerRoot.appendChild(innerChild);
+
+    return {target: innerChild, innerRoot: innerRoot, innerHost: innerHost, outerChild: outerChild, outerRoot: outerRoot, outerHost: outerHost};
+}
+
+function testEventInDetachedNestedShadowTree(innerMode, outerMode) {
+    test(function () {
+        var shadow = createNestedShadowRoot(innerMode, outerMode);
+
+        log = dispatchEventWithLog(shadow.target, new Event('bar', {composed: true, bubbles: true}));
+
+        assert_array_equals(log.length, 6, 'EventPath must contain [target, inner root, inner host, parent, outer root, outer host]');
+        assert_array_equals(log[0], [shadow.target, shadow.target], 'EventPath[0] must be the target');
+        assert_array_equals(log[1], [shadow.innerRoot, shadow.target], 'EventPath[1] must be the inner shadow root');
+        assert_array_equals(log[2], [shadow.innerHost, shadow.innerHost], 'EventPath[2] must be the inner shadow host');
+        assert_array_equals(log[3], [shadow.outerChild, shadow.innerHost], 'EventPath[3] must be the parent of the inner shadow host');
+        assert_array_equals(log[4], [shadow.outerRoot, shadow.innerHost], 'EventPath[4] must be the outer shadow root');
+        assert_array_equals(log[5], [shadow.outerHost, shadow.outerHost], 'EventPath[5] must be the outer shadow host');
+
+    }, 'Firing an event inside a detached ' + innerMode + ' mode shadow tree inside ' + outerMode + ' mode shadow tree');
+}
+
+testEventInDetachedNestedShadowTree('open',  'open');
+testEventInDetachedNestedShadowTree('open',  'closed');
+testEventInDetachedNestedShadowTree('closed', 'open');
+testEventInDetachedNestedShadowTree('closed', 'closed');
+
+function testEventInNestedShadowTreeInsideDocument(innerMode, outerMode) {
+    test(function () {
+        var shadow = createNestedShadowRoot(innerMode, outerMode);
+        document.body.appendChild(shadow.outerHost);
+
+        log = dispatchEventWithLog(shadow.target, new Event('bar', {composed: true, bubbles: true}));
+
+        assert_array_equals(log.length, 6, 'EventPath must contain [target, inner root, inner host, parent, outer root, outer host]');
+        assert_array_equals(log[0], [shadow.target, shadow.target], 'EventPath[0] must be the target');
+        assert_array_equals(log[1], [shadow.innerRoot, shadow.target], 'EventPath[1] must be the inner shadow root');
+        assert_array_equals(log[2], [shadow.innerHost, shadow.innerHost], 'EventPath[2] must be the inner shadow host');
+        assert_array_equals(log[3], [shadow.outerChild, shadow.innerHost], 'EventPath[3] must be the parent of the inner shadow host');
+        assert_array_equals(log[4], [shadow.outerRoot, shadow.innerHost], 'EventPath[4] must be the outer shadow root');
+        assert_array_equals(log[5], [shadow.outerHost, shadow.outerHost], 'EventPath[5] must be the outer shadow host');
+        assert_array_equals(log[6], [document.body, shadow.outerHost], 'EventPath[6] must be the body element');
+        assert_array_equals(log[7], [document.documentElement, shadow.outerHost], 'EventPath[7] must be the html element');
+        assert_array_equals(log[8], [document, shadow.outerHost], 'EventPath[8] must be the document node');
+
+    }, 'Firing an event inside an in-document ' + innerMode + ' mode shadow tree inside ' + outerMode + ' mode shadow tree');
+}
+
+testEventInNestedShadowTreeInsideDocument('open',  'open');
+testEventInNestedShadowTreeInsideDocument('open',  'closed');
+testEventInNestedShadowTreeInsideDocument('closed', 'open');
+testEventInNestedShadowTreeInsideDocument('closed', 'closed');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventinsideslottednodeexpectedtxtfromrev206462trunkLayoutTestsfastshadowdomeventinsideslottednodeexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-slotted-node-expected.txt (from rev 206462, trunk/LayoutTests/fast/shadow-dom/event-inside-slotted-node-expected.txt) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-slotted-node-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-slotted-node-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+
+PASS Firing an event inside a grand child of a detached open mode shadow host 
+PASS Firing an event inside a grand child of a detached closed mode shadow host 
+PASS Firing an event inside a grand child of an in-document open mode shadow host 
+PASS Firing an event inside a grand child of an in-document closed mode shadow host 
+PASS Firing an event on a node with two ancestors with a detached open and open shadow trees with an inner open shadow tree 
+PASS Firing an event on a node with two ancestors with a detached open and open shadow trees with an inner closed shadow tree 
+PASS Firing an event on a node with two ancestors with a detached open and closed shadow trees with an inner open shadow tree 
+PASS Firing an event on a node with two ancestors with a detached open and closed shadow trees with an inner closed shadow tree 
+PASS Firing an event on a node with two ancestors with a detached closed and open shadow trees with an inner open shadow tree 
+PASS Firing an event on a node with two ancestors with a detached closed and open shadow trees with an inner closed shadow tree 
+PASS Firing an event on a node with two ancestors with a detached closed and closed shadow trees with an inner open shadow tree 
+PASS Firing an event on a node with two ancestors with a detached closed and closed shadow trees with an inner closed shadow tree 
+PASS Firing an event on a node with two ancestors with a detached open and open shadow trees with an inner open shadow tree 
+PASS Firing an event on a node with two ancestors with a detached open and open shadow trees with an inner closed shadow tree 
+PASS Firing an event on a node with two ancestors with a detached open and closed shadow trees with an inner open shadow tree 
+PASS Firing an event on a node with two ancestors with a detached open and closed shadow trees with an inner closed shadow tree 
+PASS Firing an event on a node with two ancestors with a detached closed and open shadow trees with an inner open shadow tree 
+PASS Firing an event on a node with two ancestors with a detached closed and open shadow trees with an inner closed shadow tree 
+PASS Firing an event on a node with two ancestors with a detached closed and closed shadow trees with an inner open shadow tree 
+PASS Firing an event on a node with two ancestors with a detached closed and closed shadow trees with an inner closed shadow tree 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventinsideslottednodehtmlfromrev206462trunkLayoutTestsfastshadowdomeventinsideslottednodehtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-slotted-node.html (from rev 206462, trunk/LayoutTests/fast/shadow-dom/event-inside-slotted-node.html) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-slotted-node.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-slotted-node.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,258 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;title&gt;Shadow DOM: Firing an event inside a node assigned to a slot&lt;/title&gt;
+    &lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+    &lt;meta name=&quot;assert&quot; content=&quot;The event path calculation algorithm must be used to determine event path&quot;&gt;
+    &lt;link rel=&quot;help&quot; href=&quot;https://w3c.github.io/webcomponents/spec/shadow/#event-paths&quot;&gt;
+    &lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+    &lt;script&gt;
+
+        function dispatchEventWithLog(shadow, event) {
+            var log = [];
+
+            var attachedNodes = [];
+            for (var nodeKey in shadow) {
+                var startingNode = shadow[nodeKey];
+                for (var node = startingNode; node; node = node.parentNode) {
+                    if (attachedNodes.indexOf(node) &gt;= 0)
+                        continue;
+                    attachedNodes.push(node);
+                    node.addEventListener(event.type, (function (event) {
+                        log.push([this, event.target]);
+                    }).bind(node));
+                }
+            }
+
+            shadow.target.dispatchEvent(event);
+
+            return log;
+        }
+
+        function element(name, children, className) {
+            var element = document.createElement(name);
+            if (className)
+                element.className = className;
+            if (children) {
+                for (var child of children)
+                    element.appendChild(child);
+            }
+            return element;
+        }
+
+        function attachShadow(host, mode, children) {
+            var shadowRoot = host.attachShadow({mode: mode});
+            if (children) {
+                for (var child of children)
+                    shadowRoot.appendChild(child);
+            }
+            return shadowRoot;
+        }
+
+        function createShadowHostWithAssignedGrandChild(mode) {
+            var host = element('div', [
+                element('b', [
+                    element('i')
+                ])
+            ]);
+
+            var root = attachShadow(host, mode, [
+                element('span', [
+                    element('slot')
+                ])
+            ]);
+
+            return {target: host.querySelector('i'), targetParent: host.querySelector('b'), host: host,
+                    slot: root.querySelector('slot'), slotParent: root.querySelector('span'), root: root};
+        }
+
+        function testEventInDetachedShadowHostDescendant(mode) {
+            test(function () {
+                var shadow = createShadowHostWithAssignedGrandChild(mode);
+
+                log = dispatchEventWithLog(shadow, new Event('foo', {bubbles: true, composed: true}));
+
+                assert_equals(log.length, 6, 'EventPath must contain [target, target parent, slot, slot parent, shadow root, shadow host]');
+                assert_array_equals(log[0], [shadow.target, shadow.target], 'EventPath[0] must be the target');
+                assert_array_equals(log[1], [shadow.targetParent, shadow.target], 'EventPath[1] must be the parent of the target');
+                assert_array_equals(log[2], [shadow.slot, shadow.target], 'EventPath[2] must be the slot');
+                assert_array_equals(log[3], [shadow.slotParent, shadow.target], 'EventPath[3] must be the parent of the slot');
+                assert_array_equals(log[4], [shadow.root, shadow.target], 'EventPath[4] must be the shadow root');
+                assert_array_equals(log[5], [shadow.host, shadow.target], 'EventPath[5] must be the shadow host');
+
+            }, 'Firing an event inside a grand child of a detached ' + mode + ' mode shadow host');
+        }
+
+        testEventInDetachedShadowHostDescendant('open');
+        testEventInDetachedShadowHostDescendant('closed');
+
+        function testEventInShadowHostDescendantInsideDocument(mode) {
+            test(function () {
+                var shadow = createShadowHostWithAssignedGrandChild(mode);
+                document.body.appendChild(shadow.host);
+
+                log = dispatchEventWithLog(shadow, new Event('foo', {bubbles: true, composed: true}));
+
+                assert_equals(log.length, 9, 'EventPath must contain [target, target parent, slot, slot parent, shadow root, shadow host, body, html, document]');
+                assert_array_equals(log[0], [shadow.target, shadow.target], 'EventPath[0] must be the target');
+                assert_array_equals(log[1], [shadow.targetParent, shadow.target], 'EventPath[1] must be the parent of the target');
+                assert_array_equals(log[2], [shadow.slot, shadow.target], 'EventPath[2] must be the slot');
+                assert_array_equals(log[3], [shadow.slotParent, shadow.target], 'EventPath[3] must be the parent of the slot');
+                assert_array_equals(log[4], [shadow.root, shadow.target], 'EventPath[4] must be the shadow root');
+                assert_array_equals(log[5], [shadow.host, shadow.target], 'EventPath[5] must be the shadow host');
+                assert_array_equals(log[6], [document.body, shadow.target], 'EventPath[6] must be the body element');
+                assert_array_equals(log[7], [document.documentElement, shadow.target], 'EventPath[7] must be the html element');
+                assert_array_equals(log[8], [document, shadow.target], 'EventPath[8] must be the html element');
+
+            }, 'Firing an event inside a grand child of an in-document ' + mode + ' mode shadow host');
+        }
+
+        testEventInShadowHostDescendantInsideDocument('open');
+        testEventInShadowHostDescendantInsideDocument('closed');
+
+        function createNestedShadowTreesWithSlots(innerMode, outerUpperMode, outerLowerMode) {
+            var upperHost = element('upper-host', [
+                element('p', [
+                    element('lower-host', [
+                        element('a')
+                    ])
+                ])
+            ]);
+
+            var upperShadow = attachShadow(upperHost, outerUpperMode, [
+                element('b', [
+                    element('slot', [], 'upper-slot')
+                ])
+            ]);
+
+            var lowerHost = upperHost.querySelector('lower-host');
+            var lowerShadow = attachShadow(lowerHost, outerLowerMode, [
+                element('em', [
+                    element('inner-host', [
+                        element('span', [
+                            element('slot', [], 'lower-slot')
+                        ])
+                    ])
+                ])
+            ]);
+
+            innerShadow = attachShadow(lowerShadow.querySelector('inner-host'), innerMode, [
+                element('i', [
+                    element('slot', [], 'inner-slot')
+                ])
+            ]);
+
+            return {
+                host: upperHost,
+                target: upperHost.querySelector('a'),
+                upperShadow: upperShadow,
+                upperSlot: upperShadow.querySelector('slot'),
+                lowerShadow: lowerShadow,
+                lowerSlot: lowerShadow.querySelector('slot'),
+                innerShadow: innerShadow,
+                innerSlot: innerShadow.querySelector('slot'),
+            };
+        }
+
+        /*
+        upper-host (14) -- (upperShadow; 13)
+         + p (10)          + b (12)
+          |                  + slot (upperSlot; 11)
+          + lower-host (9) -- (lowerShadow; 8)
+            + a (target; 0)   + em (7)
+                                + inner-host (6) -------- (innerShadow; 5)
+                                  + span (2)              + i (4)
+                                    + slot (lowerSlot; 1) + slot (innerSlot; 3)
+        */
+
+        function testEventUnderTwoShadowRoots(outerUpperMode, outerLowerMode, innerMode) {
+            test(function () {
+                var shadow = createNestedShadowTreesWithSlots(innerMode, outerUpperMode, outerLowerMode);
+
+                log = dispatchEventWithLog(shadow, new Event('foo', {bubbles: true, composed: true}));
+
+                assert_equals(log.length, 15, 'EventPath must contain 15 targets');
+
+                assert_array_equals(log[0], [shadow.target, shadow.target], 'EventPath[0] must be the target');
+                assert_array_equals(log[1], [shadow.lowerSlot, shadow.target], 'EventPath[1] must be the slot inside the lower shadow tree');
+                assert_array_equals(log[2], [shadow.lowerSlot.parentNode, shadow.target], 'EventPath[2] must be the parent of the slot inside the lower shadow tree');
+                assert_array_equals(log[3], [shadow.innerSlot, shadow.target], 'EventPath[3] must be the slot inside the shadow tree inside the lower shadow tree');
+                assert_array_equals(log[4], [shadow.innerSlot.parentNode, shadow.target], 'EventPath[4] must be the child of the inner shadow root');
+                assert_array_equals(log[5], [shadow.innerShadow, shadow.target], 'EventPath[5] must be the inner shadow root');
+                assert_array_equals(log[6], [shadow.innerShadow.host, shadow.target], 'EventPath[6] must be the host of the inner shadow tree');
+                assert_array_equals(log[7], [shadow.lowerShadow.firstChild, shadow.target], 'EventPath[7] must be the parent of the inner shadow host');
+                assert_array_equals(log[8], [shadow.lowerShadow, shadow.target], 'EventPath[8] must be the lower shadow root');
+                assert_array_equals(log[9], [shadow.lowerShadow.host, shadow.target], 'EventPath[9] must be the lower shadow host');
+                assert_array_equals(log[10], [shadow.host.firstChild, shadow.target], 'EventPath[10] must be the parent of the grand parent of the target');
+                assert_array_equals(log[11], [shadow.upperSlot, shadow.target], 'EventPath[11] must be the slot inside the upper shadow tree');
+                assert_array_equals(log[12], [shadow.upperSlot.parentNode, shadow.target], 'EventPath[12] must be the parent of the slot inside the upper shadow tree');
+                assert_array_equals(log[13], [shadow.upperShadow, shadow.target], 'EventPath[13] must be the upper shadow root');
+                assert_array_equals(log[14], [shadow.host, shadow.target], 'EventPath[14] must be the host');
+
+            }, 'Firing an event on a node with two ancestors with a detached ' + outerUpperMode + ' and ' + outerLowerMode
+                + ' shadow trees with an inner ' + innerMode + ' shadow tree');
+        }
+
+        testEventUnderTwoShadowRoots('open', 'open', 'open');
+        testEventUnderTwoShadowRoots('open', 'open', 'closed');
+        testEventUnderTwoShadowRoots('open', 'closed', 'open');
+        testEventUnderTwoShadowRoots('open', 'closed', 'closed');
+        testEventUnderTwoShadowRoots('closed', 'open', 'open');
+        testEventUnderTwoShadowRoots('closed', 'open', 'closed');
+        testEventUnderTwoShadowRoots('closed', 'closed', 'open');
+        testEventUnderTwoShadowRoots('closed', 'closed', 'closed');
+
+        /*
+        upper-host (11) -- (upperShadow; 10)
+         + p (7)           + b (9)
+          |                  + slot (upperSlot; 8)
+          + lower-host (6) -- (lowerShadow; 5)
+            + a               + em (4)
+                                + inner-host (3) -- (innerShadow; 2)
+                                  + span            + i (1)
+                                    + slot            + slot (innerSlot, target; 0)
+        */
+
+        function testEventInsideNestedShadowsUnderAnotherShadow(outerUpperMode, outerLowerMode, innerMode) {
+            test(function () {
+                var shadow = createNestedShadowTreesWithSlots(innerMode, outerUpperMode, outerLowerMode);
+                shadow.deepestNodeInLightDOM = shadow.target; // Needed for dispatchEventWithLog to attach event listeners. 
+                shadow.target = shadow.innerSlot;
+
+                log = dispatchEventWithLog(shadow, new Event('foo', {bubbles: true, composed: true}));
+
+                assert_equals(log.length, 12, 'EventPath must contain 12 targets');
+
+                assert_array_equals(log[0], [shadow.target, shadow.target], 'EventPath[0] must be the target');
+                assert_array_equals(log[1], [shadow.target.parentNode, shadow.target], 'EventPath[1] must be the parent of the target');
+                assert_array_equals(log[2], [shadow.innerShadow, shadow.target], 'EventPath[2] must be the inner shadow root');
+                assert_array_equals(log[3], [shadow.innerShadow.host, shadow.innerShadow.host], 'EventPath[3] must be the inner shadow host');
+                assert_array_equals(log[4], [shadow.lowerShadow.firstChild, shadow.innerShadow.host], 'EventPath[4] must be the parent of the inner shadow host');
+                assert_array_equals(log[5], [shadow.lowerShadow, shadow.innerShadow.host], 'EventPath[5] must be the lower (but outer) shadow root');
+                assert_array_equals(log[6], [shadow.lowerShadow.host, shadow.lowerShadow.host], 'EventPath[6] must be the lower (but outer) shadow root');
+                assert_array_equals(log[7], [shadow.host.firstChild, shadow.lowerShadow.host], 'EventPath[7] must be the slot inside the upper shadow tree');
+                assert_array_equals(log[8], [shadow.upperSlot, shadow.lowerShadow.host], 'EventPath[8] must be the slot inside the upper shadow tree');
+                assert_array_equals(log[9], [shadow.upperSlot.parentNode, shadow.lowerShadow.host], 'EventPath[9] must be the parent of the slot inside the upper shadow tree');
+                assert_array_equals(log[10], [shadow.upperShadow, shadow.lowerShadow.host], 'EventPath[10] must be the upper shadow root');
+                assert_array_equals(log[11], [shadow.upperShadow.host, shadow.lowerShadow.host], 'EventPath[11] must be the host');
+
+            }, 'Firing an event on a node with two ancestors with a detached ' + outerUpperMode + ' and ' + outerLowerMode
+                + ' shadow trees with an inner ' + innerMode + ' shadow tree');
+        }
+
+        testEventInsideNestedShadowsUnderAnotherShadow('open', 'open', 'open');
+        testEventInsideNestedShadowsUnderAnotherShadow('open', 'open', 'closed');
+        testEventInsideNestedShadowsUnderAnotherShadow('open', 'closed', 'open');
+        testEventInsideNestedShadowsUnderAnotherShadow('open', 'closed', 'closed');
+        testEventInsideNestedShadowsUnderAnotherShadow('closed', 'open', 'open');
+        testEventInsideNestedShadowsUnderAnotherShadow('closed', 'open', 'closed');
+        testEventInsideNestedShadowsUnderAnotherShadow('closed', 'closed', 'open');
+        testEventInsideNestedShadowsUnderAnotherShadow('closed', 'closed', 'closed');
+
+    &lt;/script&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventwithrelatedtargetexpectedtxtfromrev206462trunkLayoutTestsfastshadowdomeventwithrelatedtargetexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-with-related-target-expected.txt (from rev 206462, trunk/LayoutTests/fast/shadow-dom/event-with-related-target-expected.txt) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-with-related-target-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-with-related-target-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+
+PASS Firing an event at B1a with relatedNode at B1 with open mode shadow trees 
+PASS Firing an event at B1a with relatedNode at B1 with closed mode shadow trees 
+PASS Firing an event at B1a with relatedNode at B1b1 with open mode shadow trees 
+PASS Firing an event at B1a with relatedNode at B1b1 with closed mode shadow trees 
+PASS Firing an event at B1b1 with relatedNode at B1a with open mode shadow trees 
+PASS Firing an event at B1b1 with relatedNode at B1a with closed mode shadow trees 
+PASS Firing an event at B1a with relatedNode at D1 with open mode shadow trees 
+PASS Firing an event at B1a with relatedNode at D1 with closed mode shadow trees 
+PASS Firing an event at D1 with relatedNode at B1a with open mode shadow trees 
+PASS Firing an event at D1 with relatedNode at B1a with closed mode shadow trees 
+PASS Firing an event at B1a with relatedNode at A1a with open mode shadow trees 
+PASS Firing an event at B1a with relatedNode at A1a with closed mode shadow trees 
+PASS Firing an event at B1a with relatedNode at A1a with open mode shadow trees 
+PASS Firing an event at B1a with relatedNode at A1a with closed mode shadow trees 
+PASS Firing an event at B1a with relatedNode at A1a with open mode shadow trees 
+PASS Firing an event at B1a with relatedNode at A1a with closed mode shadow trees 
+PASS Firing an event at B1a with relatedNode at A1a with open mode shadow trees 
+PASS Firing an event at B1a with relatedNode at A1a with closed mode shadow trees 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomeventwithrelatedtargethtmlfromrev206462trunkLayoutTestsfastshadowdomeventwithrelatedtargethtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-with-related-target.html (from rev 206462, trunk/LayoutTests/fast/shadow-dom/event-with-related-target.html) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-with-related-target.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-with-related-target.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,256 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;title&gt;Shadow DOM: Firing an event with relatedTarget inside a shadow tree&lt;/title&gt;
+    &lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+    &lt;meta name=&quot;assert&quot; content=&quot;The retargeting algorithm is used to determine relative targets&quot;&gt;
+    &lt;link rel=&quot;help&quot; href=&quot;https://w3c.github.io/webcomponents/spec/shadow/#retargeting-relatedtarget&quot;&gt;
+    &lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;resources/event-path-test-helpers.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+    &lt;script&gt;
+
+        /*
+        -SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
+        A ----------------------------------------------- A-SR
+        + B ----------- B-SR (4)                          + A1 --- A1-SR
+          + C           + B1 (3) [*; 0-4] --- B1-SR (2)   + A2-S   + A1a
+          + D --- D-SR    + B1a (*; 0)        + B1b [1,2] --- B1b-SR
+                  + D1                        + B1c-S (1)     + B1b1
+                                                              + B1b2
+        */
+        function testEventAtB1aWithB1a(mode) {
+            test(function () {
+                var nodes = createTestTree(mode);
+
+                log = dispatchEventWithLog(nodes, nodes.B1a, new MouseEvent('foo', {bubbles: true, composed: true, relatedTarget: nodes.B1}));
+
+                assert_array_equals(log.eventPath,
+                    ['B1a', 'B1c-S', 'B1-SR', 'B1', 'B-SR'], 'The event path must be correct.');
+                assert_array_equals(log.relatedTargets,
+                    ['B1',  'B1',    'B1',    'B1', 'B1'], 'The related targets must be correct.');
+
+            }, 'Firing an event at B1a with relatedNode at B1 with ' + mode + ' mode shadow trees');
+        }
+
+        testEventAtB1aWithB1a('open');
+        testEventAtB1aWithB1a('closed');
+
+        /*
+        -SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
+        A ------------------------------------------------- A-SR
+        + B ----------- B-SR (4)                            + A1 --- A1-SR
+          + C           + B1 (3) [0,3-4] --- B1-SR (2)      + A2-S   + A1a
+          + D --- D-SR    + B1a (*; 0)       + B1b [1,2] --- B1b-SR
+                  + D1                       + B1c-S (1)     + B1b1 [*]
+                                                             + B1b2
+        */
+        function testEventAtB1aWithB1b1(mode) {
+            test(function () {
+                var nodes = createTestTree(mode);
+
+                log = dispatchEventWithLog(nodes, nodes.B1a, new MouseEvent('foo', {bubbles: true, composed: true, relatedTarget: nodes.B1b1}));
+
+                assert_array_equals(log.eventPath,
+                    ['B1a', 'B1c-S', 'B1-SR', 'B1', 'B-SR'], 'The event path must be correct.');
+                assert_array_equals(log.relatedTargets,
+                    ['B1',  'B1b',   'B1b',   'B1', 'B1'], 'The related targets must be correct.');
+
+            }, 'Firing an event at B1a with relatedNode at B1b1 with ' + mode + ' mode shadow trees');
+        }
+
+        testEventAtB1aWithB1b1('open');
+        testEventAtB1aWithB1b1('closed');
+
+        /*
+        -SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
+        A -------------------------------------------------- A-SR
+        + B ------------- B-SR (5)                           + A1 --- A1-SR
+          + C             + B1 (4) ------- B1-SR (3)         + A2-S   + A1a
+          + D --- D-SR    + B1a [*; 0-5]   + B1b (2) --- B1b-SR (1)
+                  + D1                     + B1c-S       + B1b1 (*; 0)
+                                                         + B1b2
+        */
+        function testEventAtB1b1WithB1a(mode) {
+            test(function () {
+                var nodes = createTestTree(mode);
+
+                log = dispatchEventWithLog(nodes, nodes.B1b1, new MouseEvent('foo', {bubbles: true, composed: true, relatedTarget: nodes.B1a}));
+
+                assert_array_equals(log.eventPath,
+                    ['B1b1', 'B1b-SR', 'B1b', 'B1-SR', 'B1', 'B-SR'], 'The event path must be correct.');
+                assert_array_equals(log.relatedTargets,
+                    ['B1a',  'B1a',    'B1a', 'B1a',   'B1a', 'B1a'], 'The related targets must be correct.');
+
+            }, 'Firing an event at B1b1 with relatedNode at B1a with ' + mode + ' mode shadow trees');
+        }
+
+        testEventAtB1b1WithB1a('open');
+        testEventAtB1b1WithB1a('closed');
+
+        /*
+        -SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
+        A (8) -------------------------------------------------- A-SR (7)
+        + B (5) -------------- B-SR (4)                          + A1 -------- A1-SR
+          + C                  + B1 (3) [*; 0-4] --- B1-SR (2)   + A2-S (6)    + A1a
+          + D [0-8] --- D-SR     + B1a (*; 0)        + B1b ------ B1b-SR
+                        + D1 [*]                     + B1c-S (1)  + B1b1
+                                                                  + B1b2
+        */
+        function testEventAtB1aWithD1(mode) {
+            test(function () {
+                var nodes = createTestTree(mode);
+
+                log = dispatchEventWithLog(nodes, nodes.B1a, new MouseEvent('foo', {bubbles: true, composed: true, relatedTarget: nodes.D1}));
+
+                assert_array_equals(log.eventPath,
+                    ['B1a', 'B1c-S', 'B1-SR', 'B1', 'B-SR', 'B', 'A2-S', 'A-SR', 'A'], 'The event path must be correct.');
+                assert_array_equals(log.relatedTargets,
+                    ['D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D'], 'The related targets must be correct.');
+
+            }, 'Firing an event at B1a with relatedNode at D1 with ' + mode + ' mode shadow trees');
+        }
+
+        testEventAtB1aWithD1('open');
+        testEventAtB1aWithD1('closed');
+
+        /*
+        -SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
+        A (6) ----------------------------------- A-SR (5)
+        + B (3) [0] ----------- B-SR              + A1 ------ A1-SR
+          + C                   + B1 ----- B1-SR  + A2-S (4)  + A1a
+          + D (2) --- D-SR (1)  + B1a [*]  + B1b --- B1b-SR
+                        + D1 (*; 0)         + B1c-S   + B1b1
+                                                      + B1b2
+        */
+        function testEventAtD1WithB1a(mode) {
+            test(function () {
+                var nodes = createTestTree(mode);
+
+                log = dispatchEventWithLog(nodes, nodes.D1, new MouseEvent('foo', {bubbles: true, composed: true, relatedTarget: nodes.B1a}));
+
+                assert_array_equals(log.eventPath,
+                    ['D1', 'D-SR', 'D', 'B', 'A2-S', 'A-SR', 'A'], 'The event path must be correct.');
+                assert_array_equals(log.relatedTargets,
+                    ['B', 'B', 'B', 'B', 'B', 'B', 'B'], 'The related targets must be correct.');
+
+            }, 'Firing an event at D1 with relatedNode at B1a with ' + mode + ' mode shadow trees');
+        }
+
+        testEventAtD1WithB1a('open');
+        testEventAtD1WithB1a('closed');
+
+        /*
+        -SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
+        A (8) [0-5,8] ---------------------------------------- A-SR (7)
+        + B (5)  ------- B-SR (4)                              + A1 [6,7] --- A1-SR
+          + C            + B1 (3) ----- B1-SR (2)              + A2-S (6)     + A1a [*]
+          + D --- D-SR   + B1a (*; 0)   + B1b ------- B1b-SR
+                  + D1                  + B1c-S (1)   + B1b1
+                                                      + B1b2
+        */
+        function testEventAtB1aWithA1a(mode) {
+            test(function () {
+                var nodes = createTestTree(mode);
+
+                log = dispatchEventWithLog(nodes, nodes.B1a, new MouseEvent('foo', {bubbles: true, composed: true, relatedTarget: nodes.A1a}));
+
+                assert_array_equals(log.eventPath,
+                    ['B1a', 'B1c-S', 'B1-SR', 'B1', 'B-SR', 'B', 'A2-S', 'A-SR', 'A'], 'The event path must be correct.');
+                assert_array_equals(log.relatedTargets,
+                    ['A',   'A',     'A',     'A',   'A',   'A', 'A1',   'A1',   'A'], 'The related targets must be correct.');
+
+            }, 'Firing an event at B1a with relatedNode at A1a with ' + mode + ' mode shadow trees');
+        }
+
+        testEventAtB1aWithA1a('open');
+        testEventAtB1aWithA1a('closed');
+
+        /*
+        -SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
+        A (4) ----------------------------------------- A-SR (3)
+        + B [0-4]  ----- B-SR                           + A1 (2) --- A1-SR (1)
+          + C            + B1 ------- B1-SR             + A2-S       + A1a (*; 0)
+          + D --- D-SR     + B1a [*]  + B1b --- B1b-SR
+                  + D1                + B1c-S   + B1b1
+                                                + B1b2
+        */
+        function testEventAtA1aWithB1a(mode) {
+            test(function () {
+                var nodes = createTestTree(mode);
+
+                log = dispatchEventWithLog(nodes, nodes.A1a, new MouseEvent('foo', {bubbles: true, composed: true, relatedTarget: nodes.B1a}));
+
+                assert_array_equals(log.eventPath,
+                    ['A1a', 'A1-SR', 'A1', 'A-SR', 'A'], 'The event path must be correct.');
+                assert_array_equals(log.relatedTargets,
+                    ['B', 'B', 'B', 'B', 'B'], 'The related targets must be correct.');
+
+            }, 'Firing an event at B1a with relatedNode at A1a with ' + mode + ' mode shadow trees');
+        }
+
+        testEventAtA1aWithB1a('open');
+        testEventAtA1aWithB1a('closed');
+
+        /*
+        -SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
+        A (8) ----------------------------------- A-SR (7)
+        + B (5)  ----- B-SR (4)                   + A2-S (6)
+          + C          + B1 (3) ----- B1-SR (2)
+          + D --- D-SR   + B1a (*; 0) + B1b ------- B1b-SR
+                  + D1                + B1c-S (1)   + B1b1
+                                                    + B1b2
+        A1 [0-6] --- A1-SR
+                   + A1a [*]
+        */
+        function testEventAtB1aWithDetachedA1a(mode) {
+            test(function () {
+                var nodes = createTestTree(mode);
+
+                nodes['A-SR'].removeChild(nodes.A1);
+                log = dispatchEventWithLog(nodes, nodes.B1a, new MouseEvent('foo', {bubbles: true, composed: true, relatedTarget: nodes.A1a}));
+
+                assert_array_equals(log.eventPath,
+                    ['B1a', 'B1c-S', 'B1-SR', 'B1', 'B-SR', 'B', 'A2-S', 'A-SR', 'A'], 'The event path must be correct.');
+                assert_array_equals(log.relatedTargets,
+                    ['A1', 'A1', 'A1', 'A1', 'A1', 'A1', 'A1', 'A1', 'A1'], 'The related targets must be correct.');
+
+            }, 'Firing an event at B1a with relatedNode at A1a with ' + mode + ' mode shadow trees');
+        }
+
+        testEventAtB1aWithDetachedA1a('open');
+        testEventAtB1aWithDetachedA1a('closed');
+
+        /*
+        -SR: ShadowRoot  -S: Slot  target: (~)  relatedTarget: [~]  *: indicates start  digit: event path order
+        A ----------------------------------- A-SR
+        + B [0-3]  ----- B-SR                 + A2-S
+          + C            + B1 -------- B1-SR
+          + D --- D-SR     + B1a [*]   + B1b --- B1b-SR
+                  + D1                 + B1c-S   + B1b1
+                                                 + B1b2
+        A1 (2) --- A1-SR (1)
+                   + A1a (*; 0)
+        */
+        function testEventAtA1aWithDetachedB1a(mode) {
+            test(function () {
+                var nodes = createTestTree(mode);
+
+                nodes['A-SR'].removeChild(nodes.A1);
+                log = dispatchEventWithLog(nodes, nodes.A1a, new MouseEvent('foo', {bubbles: true, composed: true, relatedTarget: nodes.B1a}));
+
+                assert_array_equals(log.eventPath,      ['A1a', 'A1-SR', 'A1'], 'The event path must be correct.');
+                assert_array_equals(log.relatedTargets, ['B',   'B',     'B' ], 'The related targets must be correct.');
+
+            }, 'Firing an event at B1a with relatedNode at A1a with ' + mode + ' mode shadow trees');
+        }
+
+        testEventAtA1aWithDetachedB1a('open');
+        testEventAtA1aWithDetachedB1a('closed');
+
+    &lt;/script&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomleaktestsgetelementsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/get-elements-expected.txt (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/get-elements-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/get-elements-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+
+PASS getElementsById() should not leak nodes in shadow tree 
+PASS getElementsByClassName() should not leak nodes in shadow tree 
+PASS getElementsByName() should not leak nodes in shadow tree 
+PASS getElementsByTagName() should not leak nodes in shadow tree 
+PASS getElementsByTagNameNS() should not leak nodes in shadow tree 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomleaktestsgetelementshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/get-elements.html (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/get-elements.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/get-elements.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,174 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta name='author' title='Google' href='http://www.google.com'&gt;
+&lt;meta name='assert' content='getElement* API in document should not leak any node in shadow tree.'&gt;
+&lt;link rel='help' href='https://w3c.github.io/webcomponents/spec/shadow/'&gt;
+&lt;script src='../../../../../resources/testharness.js'&gt;&lt;/script&gt;
+&lt;script src='../../../../../resources/testharnessreport.js'&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+
+&lt;!--  This template will be filled in '#doc', '#host-open', and '#host-closed' below  --&gt;
+&lt;template id='domtree-template'&gt;
+  &lt;span id='foo'&gt;&lt;/span&gt;
+  &lt;div class='bar'&gt;&lt;/div&gt;
+  &lt;form name='baz'&gt;&lt;/form&gt;
+  &lt;my-element&gt;&lt;/my-element&gt;
+&lt;/template&gt;
+
+&lt;div id='doc'&gt;
+  &lt;div id='host-open'&gt;&lt;/div&gt;
+  &lt;div id='host-closed'&gt;&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;/body&gt;
+&lt;script&gt;
+'use strict';
+
+function fillTemplate(root, prefix) {
+    var tmpl = document.getElementById('domtree-template');
+    root.appendChild(document.importNode(tmpl.content, true));
+    for (var i = 0; i &lt; root.childNodes.length; ++i) {
+        var el = root.childNodes[i];
+        if (el.nodeType != 1)
+            continue;
+        el.setAttribute('label', prefix + el.tagName.toLowerCase());
+    }
+
+    root.appendChild(document.createElementNS('http://www.w3.org/2000/svg', 'linearGradient'));
+}
+
+// Construct subtree with 'doc-*' ids.
+var doc = document.getElementById('doc');
+fillTemplate(doc, 'doc-');
+
+// Construct shadow subtree with 'shadow-*' ids.
+var hostOpen = document.getElementById('host-open');
+var shadowOpen = hostOpen.attachShadow({mode: 'open'});
+fillTemplate(shadowOpen, 'shadow-open-');
+
+var hostClosed = document.getElementById('host-closed');
+var shadowClosed = hostClosed.attachShadow({mode: 'closed'});
+fillTemplate(shadowClosed, 'shadow-closed-');
+
+test(function() {
+    // getElementById() (NonElementParentNode)
+    assert_equals(document.querySelectorAll('#foo').length, 1);
+    assert_equals(document.getElementById('foo').getAttribute('label'), 'doc-span');
+    assert_equals(document.querySelector('#foo').getAttribute('label'), 'doc-span');
+
+    assert_equals(doc.querySelectorAll('#foo').length, 1);
+    assert_equals(doc.querySelector('#foo').getAttribute('label'), 'doc-span');
+
+    assert_equals(hostOpen.querySelectorAll('#foo').length, 0);
+
+    assert_equals(shadowOpen.querySelectorAll('#foo').length, 1);
+    assert_equals(shadowOpen.getElementById('foo').getAttribute('label'), 'shadow-open-span');
+    assert_equals(shadowOpen.querySelector('#foo').getAttribute('label'), 'shadow-open-span');
+
+    assert_equals(hostClosed.querySelectorAll('#foo').length, 0);
+
+    assert_equals(shadowClosed.querySelectorAll('#foo').length, 1);
+    assert_equals(shadowClosed.getElementById('foo').getAttribute('label'), 'shadow-closed-span');
+    assert_equals(shadowClosed.querySelector('#foo').getAttribute('label'), 'shadow-closed-span');
+}, 'getElementsById() should not leak nodes in shadow tree');
+
+test(function() {
+    // getElementsByClassName() (Element, Document)
+    assert_equals(document.getElementsByClassName('bar').length, 1);
+    assert_equals(document.getElementsByClassName('bar')[0].getAttribute('label'), 'doc-div');
+    assert_equals(document.getElementsByClassName('bar').length, 1);
+    assert_equals(document.getElementsByClassName('bar')[0].getAttribute('label'), 'doc-div');
+    assert_equals(document.querySelectorAll('.bar').length, 1);
+
+    assert_equals(doc.querySelectorAll('.bar').length, 1);
+    assert_equals(doc.getElementsByClassName('bar')[0].getAttribute('label'), 'doc-div');
+
+    assert_array_equals(hostOpen.querySelectorAll('.bar').length, 0);
+
+    assert_equals(shadowOpen.querySelectorAll('.bar').length, 1);
+    assert_equals(shadowOpen.querySelectorAll('.bar')[0].getAttribute('label'), 'shadow-open-div');
+
+    assert_array_equals(hostClosed.querySelectorAll('.bar').length, 0);
+
+    assert_equals(shadowClosed.querySelectorAll('.bar').length, 1);
+    assert_equals(shadowClosed.querySelectorAll('.bar')[0].getAttribute('label'), 'shadow-closed-div');
+}, 'getElementsByClassName() should not leak nodes in shadow tree');
+
+test(function() {
+    // getElementsByName (Document)
+    assert_equals(document.getElementsByName('baz').length, 1);
+    assert_equals(document.getElementsByName('baz')[0].getAttribute('label'), 'doc-form');
+    assert_equals(document.getElementsByName('baz').length, 1);
+    assert_equals(document.getElementsByName('baz')[0].getAttribute('label'), 'doc-form');
+    assert_equals(document.querySelectorAll('[name=baz]').length, 1);
+
+    assert_equals(doc.querySelectorAll('[name=baz]').length, 1);
+
+    assert_array_equals(hostOpen.querySelectorAll('[name=baz]').length, 0);
+    assert_equals(shadowOpen.querySelectorAll('[name=baz]').length, 1);
+    assert_equals(shadowOpen.querySelectorAll('[name=baz]')[0].getAttribute('label'), 'shadow-open-form');
+
+    assert_array_equals(hostClosed.querySelectorAll('[name=baz]').length, 0);
+    assert_equals(shadowClosed.querySelectorAll('[name=baz]').length, 1);
+    assert_equals(shadowClosed.querySelectorAll('[name=baz]')[0].getAttribute('label'), 'shadow-closed-form');
+}, 'getElementsByName() should not leak nodes in shadow tree');
+
+test(function() {
+    // getElementsByTagName (Element, Document)
+    assert_equals(document.getElementsByTagName('my-element').length, 1);
+    assert_equals(document.getElementsByTagName('my-element')[0].getAttribute('label'), 'doc-my-element');
+    assert_equals(document.getElementsByTagName('my-element').length, 1);
+    assert_equals(document.getElementsByTagName('my-element')[0].getAttribute('label'), 'doc-my-element');
+    assert_equals(document.querySelectorAll('my-element').length, 1);
+
+    assert_equals(doc.querySelectorAll('my-element').length, 1);
+    assert_equals(doc.getElementsByTagName('my-element')[0].getAttribute('label'), 'doc-my-element');
+
+    assert_array_equals(hostOpen.querySelectorAll('my-element').length, 0);
+    // ShadowRoot isn't an Element, does not have getElementsByTagName().
+    assert_equals(shadowOpen.querySelectorAll('my-element').length, 1);
+    assert_equals(shadowOpen.querySelectorAll('my-element')[0].getAttribute('label'), 'shadow-open-my-element');
+
+    assert_array_equals(hostClosed.querySelectorAll('my-element').length, 0);
+    assert_equals(shadowClosed.querySelectorAll('my-element').length, 1);
+    assert_equals(shadowClosed.querySelectorAll('my-element')[0].getAttribute('label'), 'shadow-closed-my-element');
+}, 'getElementsByTagName() should not leak nodes in shadow tree');
+
+test(function() {
+    // getElementsByTagNameNS (Element, Document)
+    assert_equals(document.getElementsByTagName('lineargradient').length, 0);
+    assert_equals(document.getElementsByTagNameNS('*', 'lineargradient').length, 0);
+    assert_equals(document.getElementsByTagNameNS('http://www.w3.org/2000/svg', 'lineargradient').length, 0);
+    assert_equals(document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'lineargradient').length, 0);
+
+    assert_equals(document.getElementsByTagName('linearGradient').length, 1);
+    assert_equals(document.getElementsByTagNameNS('*', 'linearGradient').length, 1);
+    assert_equals(document.getElementsByTagNameNS('http://www.w3.org/2000/svg', 'linearGradient').length, 1);
+    assert_equals(document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'linearGradient').length, 0);
+
+    assert_equals(doc.getElementsByTagName('lineargradient').length, 0);
+    assert_equals(doc.getElementsByTagNameNS('*', 'lineargradient').length, 0);
+    assert_equals(doc.getElementsByTagNameNS('http://www.w3.org/2000/svg', 'lineargradient').length, 0);
+    assert_equals(doc.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'lineargradient').length, 0);
+
+    assert_equals(doc.getElementsByTagName('linearGradient').length, 1);
+    assert_equals(doc.getElementsByTagNameNS('*', 'linearGradient').length, 1);
+    assert_equals(doc.getElementsByTagNameNS('http://www.w3.org/2000/svg', 'linearGradient').length, 1);
+    assert_equals(doc.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'linearGradient').length, 0);
+
+    assert_equals(hostOpen.getElementsByTagName('linearGradient').length, 0);
+    assert_equals(hostOpen.getElementsByTagNameNS('*', 'linearGradient').length, 0);
+    assert_equals(hostOpen.getElementsByTagNameNS('http://www.w3.org/2000/svg', 'linearGradient').length, 0);
+    assert_equals(hostOpen.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'linearGradient').length, 0);
+
+    assert_equals(hostClosed.getElementsByTagName('linearGradient').length, 0);
+    assert_equals(hostClosed.getElementsByTagNameNS('*', 'linearGradient').length, 0);
+    assert_equals(hostClosed.getElementsByTagNameNS('http://www.w3.org/2000/svg', 'linearGradient').length, 0);
+    assert_equals(hostClosed.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'linearGradient').length, 0);
+
+    // ShadowRoot isn't an Element, does not have getElementsByTagNameNS().
+}, 'getElementsByTagNameNS() should not leak nodes in shadow tree');
+&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomleaktestshtmlcollectionexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/html-collection-expected.txt (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/html-collection-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/html-collection-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+  
+
+PASS document.scripts should not contain shadow nodes 
+PASS document.all should not contain shadow nodes 
+PASS document.forms should not contain shadow nodes 
+PASS document.images should not contain shadow nodes 
+PASS document.links should not contain shadow nodes 
+PASS document.anchors should not contain shadow nodes 
+PASS document.embeds should not contain shadow nodes 
+PASS document.plugins should not contain shadow nodes 
+PASS document.applets should not contain shadow nodes 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomleaktestshtmlcollectionhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/html-collection.html (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/html-collection.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/html-collection.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,76 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta name='author' title='Google' href='http://www.google.com'&gt;
+&lt;meta name='assert' content='document attributes that returns HTMLCollection should not expose nodes in shadow tree.'&gt;
+&lt;link rel='help' href='https://w3c.github.io/webcomponents/spec/shadow/'&gt;
+&lt;script src='../../../../../resources/testharness.js'&gt;&lt;/script&gt;
+&lt;script src='../../../../../resources/testharnessreport.js'&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;template id='collection-template'&gt;
+  &lt;img&gt;
+  &lt;embed&gt;&lt;/embed&gt;
+  &lt;applet&gt;&lt;/applet&gt;
+  &lt;object type='application/x-java-applet'&gt;&lt;/object&gt;
+  &lt;a href='http://example.com'&gt;&lt;/a&gt;
+  &lt;a name='test'&gt;&lt;/a&gt;
+  &lt;form name='test'&gt;&lt;/form&gt;
+  &lt;script&gt;&lt;/script&gt;
+&lt;/template&gt;
+&lt;div id='doc'&gt;&lt;/div&gt;
+&lt;div id='host-open'&gt;&lt;/div&gt;
+&lt;div id='host-closed'&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+'use strict';
+
+function fillTemplate(root, prefix) {
+    var tmpl = document.getElementById('collection-template');
+    root.appendChild(document.importNode(tmpl.content, true));
+    for (var i = 0; i &lt; root.childNodes.length; ++i) {
+        var el = root.childNodes[i];
+        if (el.nodeType != 1)
+            continue;
+        el.id = prefix + el.tagName.toLowerCase();
+    }
+}
+
+// Construct subtree with 'doc-*' ids.
+var doc = document.getElementById('doc');
+fillTemplate(doc, 'doc-');
+
+// Construct shadow subtree with 'shadow-*' ids.
+var host = document.getElementById('host-open');
+var shadow = host.attachShadow({mode: 'open'});
+fillTemplate(shadow, 'shadow-open-');
+
+host = document.getElementById('host-closed');
+shadow = host.attachShadow({mode: 'closed'});
+fillTemplate(shadow, 'shadow-closed-');
+
+function testCollection(collection) {
+    var elements = document[collection];
+    assert_greater_than(elements.length, 0, 'document.' + collection + ' should have at least 1 element.');
+    for (var i = 0; i &lt; elements.length; ++i) {
+        if (elements[i].id) {
+            assert_equals(elements[i].id.indexOf('shadow-'), -1, 'document.' + collection + ' should not contain elements in shadow tree.');
+        }
+    }
+}
+
+var testParams = [
+    ['document.scripts should not contain shadow nodes', 'scripts'],
+    ['document.all should not contain shadow nodes', 'all'],
+    ['document.forms should not contain shadow nodes', 'forms'],
+    ['document.images should not contain shadow nodes', 'images'],
+    ['document.links should not contain shadow nodes', 'links'],
+    ['document.anchors should not contain shadow nodes', 'anchors'],
+    ['document.embeds should not contain shadow nodes', 'embeds'],
+    ['document.plugins should not contain shadow nodes', 'plugins'],
+    ['document.applets should not contain shadow nodes', 'applets']];
+
+generate_tests(testCollection, testParams);
+
+&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomleaktestsw3cimportlog"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/w3c-import.log (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/w3c-import.log                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/w3c-import.log        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+The tests in this directory were imported from the W3C repository.
+Do NOT modify these tests directly in WebKit.
+Instead, create a pull request on the W3C CSS or WPT github:
+        https://github.com/w3c/csswg-test
+        https://github.com/w3c/web-platform-tests
+
+Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
+
+Do NOT modify or remove this file.
+
+------------------------------------------------------------------------
+Properties requiring vendor prefixes:
+None
+Property values requiring vendor prefixes:
+None
+------------------------------------------------------------------------
+List of files:
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/get-elements.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/html-collection.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/window-frames.html
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomleaktestswindowframesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/window-frames-expected.txt (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/window-frames-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/window-frames-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+
+PASS window.frames should not leak frames in Shadow DOM. 
+
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomleaktestswindowframeshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/window-frames.html (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/window-frames.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/leaktests/window-frames.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,36 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta name='author' title='Google' href='http://www.google.com'&gt;
+&lt;meta name='assert' content='Shadow DOM should not leak via window.frames.'&gt;
+&lt;link rel='help' href='https://w3c.github.io/webcomponents/spec/shadow/'&gt;
+&lt;script src='../../../../../resources/testharness.js'&gt;&lt;/script&gt;
+&lt;script src='../../../../../resources/testharnessreport.js'&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id='log'&gt;&lt;/div&gt;
+&lt;iframe src='about:blank' name='mainFrame1'&gt;&lt;/iframe&gt;
+&lt;div id='host-open'&gt;&lt;/div&gt;
+&lt;div id='host-closed'&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;script&gt;
+'use strict';
+
+var host_open = document.getElementById('host-open');
+var root_open = host_open.attachShadow({mode: 'open'});
+root_open.innerHTML = '&lt;iframe src=&quot;about:blank&quot; name=&quot;shadowFrame1&quot;&gt;&lt;/iframe&gt;';
+
+var host_closed = document.getElementById('host-closed');
+var root_closed = host_closed.attachShadow({mode: 'closed'});
+root_closed.innerHTML = '&lt;iframe src=&quot;about:blank&quot; name=&quot;shadowFrame2&quot;&gt;&lt;/iframe&gt;';
+
+test(() =&gt; {
+  assert_equals(window.frames.length, 1, 'window.frames should return only frames in document.');
+  assert_equals(window.frames[0].name, 'mainFrame1', 'window.frames[0] should be mainFrame1.');
+  assert_equals(window.frames['mainFrame1'], window.frames[0], 'window.frames[\'mainFrame1\'] should be equal to mainFrame1.');
+  assert_equals(window.frames['shadowFrame1'], undefined, 'shadowFrame1 should not leak.');
+  assert_equals(window.frames['shadowFrame2'], undefined, 'shadowFrame2 should not leak.');
+
+}, 'window.frames should not leak frames in Shadow DOM.');
+&lt;/script&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomresourcesDocumentprototypecurrentScripthelperjsfromrev206462trunkLayoutTestsfastshadowdomresourcesDocumentprototypecurrentScripthelperjs"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/Document-prototype-currentScript-helper.js (from rev 206462, trunk/LayoutTests/fast/shadow-dom/resources/Document-prototype-currentScript-helper.js) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/Document-prototype-currentScript-helper.js                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/Document-prototype-currentScript-helper.js        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+executeExternalScript();
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomresourceseventpathtesthelpersjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/event-path-test-helpers.js (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/event-path-test-helpers.js                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/event-path-test-helpers.js        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,93 @@
</span><ins>+
+function dispatchEventWithLog(shadow, target, event) {
+    var eventPath = [];
+    var relatedTargets = [];
+    var pathAtTargets = [];
+
+    var attachedNodes = [];
+    for (var nodeKey in shadow) {
+        var startingNode = shadow[nodeKey];
+        for (var node = startingNode; node; node = node.parentNode) {
+            if (attachedNodes.indexOf(node) &gt;= 0)
+                continue;
+            attachedNodes.push(node);
+            node.addEventListener(event.type, (function (event) {
+                eventPath.push(this.label);
+                relatedTargets.push(event.relatedTarget ? event.relatedTarget.label : null);
+
+                if (!event.composedPath) // Don't fail all tests just for the lack of composedPath.
+                    return;
+
+                pathAtTargets.push(event.composedPath().map(function (node) { return node.label; }));
+            }).bind(node));
+        }
+    }
+
+    target.dispatchEvent(event);
+
+    return {eventPath: eventPath, relatedTargets: relatedTargets, pathAtTargets: pathAtTargets};
+}
+
+/*
+-SR: ShadowRoot  -S: Slot
+A ------------------------------- A-SR
++ B ------------ B-SR             + A1 --- A1-SR
+  + C            + B1 --- B1-SR   + A2-S   + A1a
+  + D --- D-SR     + B1a  + B1b --- B1b-SR
+          + D1            + B1c-S   + B1b1
+                                    + B1b2
+*/
+function createTestTree(mode) {
+    var namedNodes = {};
+
+    function element(name) {
+        var element = document.createElement(name.indexOf('-S') &gt; 0 ? 'slot' : 'div');
+        element.label = name;
+        namedNodes[name] = element;
+        for (var i = 1; i &lt; arguments.length; i++) {
+            var item = arguments[i];
+            if (typeof(item) == 'function')
+                item(element);
+            else
+                element.appendChild(item);
+        }
+        return element;
+    }
+
+    function shadow(name) {
+        var children = [];
+        for (var i = 1; i &lt; arguments.length; i++)
+            children.push(arguments[i]);
+        return function (element) {
+            var shadowRoot = element.attachShadow({mode: mode});
+            shadowRoot.label = name;
+            namedNodes[name] = shadowRoot;
+            for (var child of children)
+                shadowRoot.appendChild(child);
+        }
+    }
+
+    var host = element('A',
+        shadow('A-SR',
+            element('A1',
+                shadow('A1-SR',
+                    element('A1a'))),
+            element('A2-S')
+        ),
+        element('B',
+            shadow('B-SR',
+                element('B1',
+                    shadow('B1-SR',
+                        element('B1b',
+                            shadow('B1b-SR',
+                                element('B1b1'),
+                                element('B1b2'))),
+                        element('B1c-S')),
+                    element('B1a'))),
+            element('C'),
+            element('D',
+                shadow('D-SR',
+                    element('D1')))));
+
+    return namedNodes;
+}
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomresourcesshadowdomutilsjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/shadow-dom-utils.js (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/shadow-dom-utils.js                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/shadow-dom-utils.js        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,154 @@
</span><ins>+// Copyright 2012 Google Inc. All Rights Reserved.
+
+/*
+Distributed under both the W3C Test Suite License [1] and the W3C
+3-clause BSD License [2]. To contribute to a W3C Test Suite, see the
+policies and contribution forms [3].
+
+[1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license
+[2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license
+[3] http://www.w3.org/2004/10/27-testcases
+*/
+
+&quot;use strict&quot;;
+
+// custom element is also allowed.
+var ATTACHSHADOW_SAFELISTED_ELEMENTS = [
+    'article',
+    'aside',
+    'blockquote',
+    'body',
+    'div',
+    'footer',
+    'h1',
+    'h2',
+    'h3',
+    'h4',
+    'h5',
+    'h6',
+    'header',
+    'nav',
+    'p',
+    'section',
+    'span'
+];
+
+var HTML5_ELEMENT_NAMES = [
+    'a', 'abbr', 'address', 'area', 'article', 'aside', 'audio',
+    'b', 'base', 'bdi', 'bdo', 'blockquote', 'body', 'br', 'button',
+    'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'command',
+    'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt',
+    'em', 'embed',
+    'fieldset', 'figcaption', 'figure', 'footer', 'form',
+    'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr',
+    'html',
+    'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen',
+    'label', 'legend', 'li', 'link',
+    'map', 'mark', 'menu', 'meta', 'meter',
+    'nav', 'noscript',
+    'object', 'ol', 'optgroup', 'option', 'output',
+    'p', 'param', 'pre', 'progress',
+    'q',
+    'rp', 'rt', 'ruby',
+    's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span',
+    'strong', 'style', 'sub',
+    'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time',
+    'title', 'tr', 'track',
+    'u', 'ul',
+    'var', 'video',
+    'wbr'
+];
+
+function unit(f) {
+    return function () {
+        var ctx = newContext();
+        try {
+            f(ctx);
+        } finally {
+            cleanContext(ctx);
+        }
+    }
+}
+
+function step_unit(f, ctx, t) {
+    return function () {
+        var done = false;
+        try {
+            f();
+            done = true;
+        } finally {
+            if (done) {
+                t.done();
+            }
+            cleanContext(ctx);
+        }
+    }
+}
+
+function assert_nodelist_contents_equal_noorder(actual, expected, message) {
+    assert_equals(actual.length, expected.length, message);
+    var used = [];
+    for (var i = 0; i &lt; expected.length; i++) {
+        used.push(false);
+    }
+    for (i = 0; i &lt; expected.length; i++) {
+        var found = false;
+        for (var j = 0; j &lt; actual.length; j++) {
+            if (used[j] == false &amp;&amp; expected[i] == actual[j]) {
+                used[j] = true;
+                found = true;
+                break;
+            }
+        }
+        if (!found) {
+            assert_unreached(message + &quot;. Fail reason:  element not found: &quot; + expected[i]);
+        }
+    }
+}
+
+//Example taken from http://www.w3.org/TR/shadow-dom/#event-retargeting-example
+function createTestMediaPlayer(d) {
+    d.body.innerHTML = '' +
+    '&lt;div id=&quot;player&quot;&gt;' +
+        '&lt;input type=&quot;checkbox&quot; id=&quot;outside-control&quot;&gt;' +
+        '&lt;div id=&quot;player-shadow-host&quot;&gt;' +
+        '&lt;/div&gt;' +
+    '&lt;/div&gt;';
+
+    var playerShadowRoot = d.querySelector('#player-shadow-host').attachShadow({mode: 'open'});
+    playerShadowRoot.innerHTML = '' +
+        '&lt;div id=&quot;controls&quot;&gt;' +
+            '&lt;button class=&quot;play-button&quot;&gt;PLAY&lt;/button&gt;' +
+            '&lt;div tabindex=&quot;0&quot; id=&quot;timeline&quot;&gt;' +
+                '&lt;div id=&quot;timeline-shadow-host&quot;&gt;' +
+                '&lt;/div&gt;' +
+            '&lt;/div&gt;' +
+            '&lt;div class=&quot;volume-slider-container&quot; id=&quot;volume-slider-container&quot;&gt;' +
+                '&lt;div tabindex=&quot;0&quot; class=&quot;volume-slider&quot; id=&quot;volume-slider&quot;&gt;' +
+                    '&lt;div id=&quot;volume-shadow-host&quot;&gt;' +
+                    '&lt;/div&gt;' +
+                '&lt;/div&gt;' +
+            '&lt;/div&gt;' +
+        '&lt;/div&gt;';
+
+    var timeLineShadowRoot = playerShadowRoot.querySelector('#timeline-shadow-host').attachShadow({mode: 'open'});
+    timeLineShadowRoot.innerHTML =  '&lt;div class=&quot;slider-thumb&quot; id=&quot;timeline-slider-thumb&quot;&gt;&lt;/div&gt;';
+
+    var volumeShadowRoot = playerShadowRoot.querySelector('#volume-shadow-host').attachShadow({mode: 'open'});
+    volumeShadowRoot.innerHTML = '&lt;div class=&quot;slider-thumb&quot; id=&quot;volume-slider-thumb&quot;&gt;&lt;/div&gt;';
+
+    return {
+        'playerShadowRoot': playerShadowRoot,
+        'timeLineShadowRoot': timeLineShadowRoot,
+        'volumeShadowRoot': volumeShadowRoot
+        };
+}
+
+//FIXME This call of initKeyboardEvent works for WebKit-only.
+//See https://bugs.webkit.org/show_bug.cgi?id=16735
+// and https://bugs.webkit.org/show_bug.cgi?id=13368. Add check for browser here
+function fireKeyboardEvent(doc, element, key) {
+    var event = doc.createEvent('KeyboardEvent');
+    event.initKeyboardEvent(&quot;keydown&quot;, true, true, doc.defaultView, key, 0, false, false, false, false);
+    element.dispatchEvent(event);
+}
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomresourcesshadowdomjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/shadow-dom.js (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/shadow-dom.js                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/shadow-dom.js        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,130 @@
</span><ins>+function removeWhiteSpaceOnlyTextNodes(node)
+{
+  for (var i = 0; i &lt; node.childNodes.length; i++) {
+    var child = node.childNodes[i];
+    if (child.nodeType === Node.TEXT_NODE &amp;&amp; child.nodeValue.trim().length == 0) {
+      node.removeChild(child);
+      i--;
+    } else if (child.nodeType === Node.ELEMENT_NODE || child.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
+      removeWhiteSpaceOnlyTextNodes(child);
+    }
+  }
+  if (node.shadowRoot) {
+    removeWhiteSpaceOnlyTextNodes(node.shadowRoot);
+  }
+}
+
+function createTestTree(node) {
+
+  let ids = {};
+
+  function attachShadowFromTemplate(template) {
+    let parent = template.parentNode;
+    parent.removeChild(template);
+    let shadowRoot;
+    if (template.getAttribute('data-mode') === 'v0') {
+      // For legacy Shadow DOM
+      shadowRoot = parent.createShadowRoot();
+    } else {
+      shadowRoot = parent.attachShadow({mode: template.getAttribute('data-mode')});
+    }
+    let id = template.id;
+    if (id) {
+      shadowRoot.id = id;
+      ids[id] = shadowRoot;
+    }
+    shadowRoot.appendChild(document.importNode(template.content, true));
+    return shadowRoot;
+  }
+
+  function walk(root) {
+    if (root.id) {
+      ids[root.id] = root;
+    }
+    for (let e of Array.from(root.querySelectorAll('[id]'))) {
+      ids[e.id] = e;
+    }
+    for (let e of Array.from(root.querySelectorAll('template'))) {
+      walk(attachShadowFromTemplate(e));
+    }
+  }
+
+  walk(node.cloneNode(true));
+  return ids;
+}
+
+function dispatchEventWithLog(nodes, target, event) {
+
+  function labelFor(e) {
+    return e.id || e.tagName;
+  }
+
+  let log = [];
+  let attachedNodes = [];
+  for (let label in nodes) {
+    let startingNode = nodes[label];
+    for (let node = startingNode; node; node = node.parentNode) {
+      if (attachedNodes.indexOf(node) &gt;= 0)
+        continue;
+      let id = node.id;
+      if (!id)
+        continue;
+      attachedNodes.push(node);
+      node.addEventListener(event.type, (e) =&gt; {
+        // Record [currentTarget, target, relatedTarget, composedPath()]
+        log.push([id,
+                  labelFor(e.target),
+                  e.relatedTarget ? labelFor(e.relatedTarget) : null,
+                  e.composedPath().map((n) =&gt; {
+                    return labelFor(n);
+                  })]);
+      });
+    }
+  }
+  target.dispatchEvent(event);
+  return log;
+}
+
+// TODO(hayato): Merge this into dispatchEventWithLog
+function dispatchUAEventWithLog(nodes, target, eventType, callback) {
+
+  function labelFor(e) {
+    return e.id || e.tagName;
+  }
+
+  let log = [];
+  let attachedNodes = [];
+  for (let label in nodes) {
+    let startingNode = nodes[label];
+    for (let node = startingNode; node; node = node.parentNode) {
+      if (attachedNodes.indexOf(node) &gt;= 0)
+        continue;
+      let id = node.id;
+      if (!id)
+        continue;
+      attachedNodes.push(node);
+      node.addEventListener(eventType, (e) =&gt; {
+        // Record [currentTarget, target, relatedTarget, composedPath()]
+        log.push([id,
+                  labelFor(e.target),
+                  e.relatedTarget ? labelFor(e.relatedTarget) : null,
+                  e.composedPath().map((n) =&gt; {
+                    return labelFor(n);
+                  })]);
+      });
+    }
+  }
+  callback(target);
+  return log;
+}
+
+// This function assumes that testharness.js is available.
+function assert_event_path_equals(actual, expected) {
+  assert_equals(actual.length, expected.length);
+  for (let i = 0; i &lt; actual.length; ++i) {
+    assert_equals(actual[i][0], expected[i][0], 'currentTarget at ' + i + ' should be same');
+    assert_equals(actual[i][1], expected[i][1], 'target at ' + i + ' should be same');
+    assert_equals(actual[i][2], expected[i][2], 'relatedTarget at ' + i + ' should be same');
+    assert_array_equals(actual[i][3], expected[i][3], 'composedPath at ' + i + ' should be same');
+  }
+}
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomresourcesw3cimportlog"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/w3c-import.log (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/w3c-import.log                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/w3c-import.log        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+The tests in this directory were imported from the W3C repository.
+Do NOT modify these tests directly in WebKit.
+Instead, create a pull request on the W3C CSS or WPT github:
+        https://github.com/w3c/csswg-test
+        https://github.com/w3c/web-platform-tests
+
+Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
+
+Do NOT modify or remove this file.
+
+------------------------------------------------------------------------
+Properties requiring vendor prefixes:
+None
+Property values requiring vendor prefixes:
+None
+------------------------------------------------------------------------
+List of files:
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/Document-prototype-currentScript-helper.js
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/event-path-test-helpers.js
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/shadow-dom-utils.js
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/resources/shadow-dom.js
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomscrolltothefragmentinshadowtreeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/scroll-to-the-fragment-in-shadow-tree-expected.txt (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/scroll-to-the-fragment-in-shadow-tree-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/scroll-to-the-fragment-in-shadow-tree-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+
+PASS The user agent scroll to the fragment when there is an element with an ID exactly equal to the decoded fragid 
+PASS The user agent scroll to the fragment when there is an anchor element with a name attribute exactly equal to the decoded fragid 
+PASS The user agent should not scroll to an element with an ID exactly equal to the decoded fragid in an open shadow tree 
+PASS The user agent should not scroll to an element with an ID exactly equal to the decoded fragid in a closed shadow tree 
+PASS The user agent should not scroll to an anchor element with a name attribute exactly equal to the decoded fragid in an open shadow tree 
+PASS The user agent should not scroll to an anchor element with a name attribute exactly equal to the decoded fragid in a closed shadow tree 
+PASS The user agent should scroll to an element with an ID exactly equal to the decoded fragid in the document tree even if there was another element with the same ID inside an open shadow tree earlier in tree order 
+PASS The user agent should scroll to an element with an ID exactly equal to the decoded fragid in the document tree even if there was another element with the same ID inside a closed shadow tree earlier in tree order 
+PASS The user agent should scroll to an anchor element with a name attribute exactly equal to the decoded fragid in the document tree even if there was another element with the same ID inside an open shadow tree earlier in tree order 
+PASS The user agent should scroll to an anchor element with a name attribute exactly equal to the decoded fragid in the document tree even if there was another element with the same ID inside a closed shadow tree earlier in tree order 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomscrolltothefragmentinshadowtreehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/scroll-to-the-fragment-in-shadow-tree.html (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/scroll-to-the-fragment-in-shadow-tree.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/scroll-to-the-fragment-in-shadow-tree.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,127 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;Shadow DOM: The indicated part of the document should not match an element inside a shadow tree&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;An element inside a shadow tree should not be the indicated part of the document even if its ID is exactly equal to the decoded fragid or its name attribute is exactly equal to the fragid&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;https://html.spec.whatwg.org/multipage/browsers.html#scroll-to-the-fragment-identifier&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;div id=&quot;testContainer&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+
+var tests = [
+    {test: async_test('The user agent scroll to the fragment when there is an element with an ID exactly equal to the decoded fragid'),
+        execute: testScrollingToElementInDocumentTree.bind(this, 'div')},
+    {test: async_test('The user agent scroll to the fragment when there is an anchor element with a name attribute exactly equal to the decoded fragid'),
+        execute: testScrollingToElementInDocumentTree.bind(this, 'a')},
+
+    {test: async_test('The user agent should not scroll to an element with an ID exactly equal to the decoded fragid in an open shadow tree'),
+        execute: testScrollingToElementInShadowTree.bind(this, 'div', 'open')},
+    {test: async_test('The user agent should not scroll to an element with an ID exactly equal to the decoded fragid in a closed shadow tree'),
+        execute: testScrollingToElementInShadowTree.bind(this, 'div', 'closed')},
+    {test: async_test('The user agent should not scroll to an anchor element with a name attribute exactly equal to the decoded fragid in an open shadow tree'),
+        execute: testScrollingToElementInShadowTree.bind(this, 'a', 'open')},
+    {test: async_test('The user agent should not scroll to an anchor element with a name attribute exactly equal to the decoded fragid in a closed shadow tree'),
+        execute: testScrollingToElementInShadowTree.bind(this, 'a', 'closed')},
+
+    {test: async_test('The user agent should scroll to an element with an ID exactly equal to the decoded fragid in the document tree'
+        + ' even if there was another element with the same ID inside an open shadow tree earlier in tree order'),
+        execute: testScrollingToElementInDocumentTreeAfterElementInShadowTreeWithSameID.bind(this, 'div', 'open')},
+    {test: async_test('The user agent should scroll to an element with an ID exactly equal to the decoded fragid in the document tree'
+        + ' even if there was another element with the same ID inside a closed shadow tree earlier in tree order'),
+        execute: testScrollingToElementInDocumentTreeAfterElementInShadowTreeWithSameID.bind(this, 'div', 'closed')},
+    {test: async_test('The user agent should scroll to an anchor element with a name attribute exactly equal to the decoded fragid in the document tree'
+        + ' even if there was another element with the same ID inside an open shadow tree earlier in tree order'),
+        execute: testScrollingToElementInDocumentTreeAfterElementInShadowTreeWithSameID.bind(this, 'a', 'open')},
+    {test: async_test('The user agent should scroll to an anchor element with a name attribute exactly equal to the decoded fragid in the document tree'
+        + ' even if there was another element with the same ID inside a closed shadow tree earlier in tree order'),
+        execute: testScrollingToElementInDocumentTreeAfterElementInShadowTreeWithSameID.bind(this, 'a', 'closed')},
+];
+
+function executeNextTest()
+{
+    window.scrollTo(0, 0);
+
+    currentFragIdSuffix++;
+    var nextTest = tests.shift();
+    if (!nextTest)
+        return;
+    setTimeout(function () {
+        nextTest.execute(nextTest.test);
+    }, 0);
+}
+
+var testContainer = document.getElementById('testContainer');
+var currentFragIdSuffix = 0;
+
+function tallElementMarkup()
+{
+    return '&lt;div style=&quot;height: ' + (window.innerHeight * 2) + 'px&quot;&gt;&lt;a href=&quot;#fragid' + currentFragIdSuffix + '&quot;&gt;Go to fragment&lt;/a&gt;&lt;/div&gt;';
+}
+
+function targetMarkup(elementType)
+{
+    return elementType == 'div' ? ('&lt;div id=&quot;fragid' + currentFragIdSuffix + '&quot;&gt;hello&lt;/div&gt;') : ('&lt;a name=&quot;fragid' + currentFragIdSuffix + '&quot;&gt;hello&lt;/a&gt;');
+}
+
+function clickFirstAnchorAndRunStep(test, step)
+{
+    setTimeout(function () {
+        testContainer.querySelector('a').click();
+        setTimeout(function () {
+            test.step(step);
+            testContainer.innerHTML = '';
+            test.done();
+            executeNextTest();
+        }, 0);
+    }, 0);
+}
+
+function testScrollingToElementInDocumentTree(elementType, test)
+{
+    test.step(function () {
+        testContainer.innerHTML = tallElementMarkup() + targetMarkup(elementType);
+        assert_equals(window.pageYOffset, 0);
+    });
+    clickFirstAnchorAndRunStep(test, function () {
+        assert_not_equals(window.pageYOffset, 0);
+    });
+}
+
+function testScrollingToElementInShadowTree(elementType, mode, test)
+{
+    test.step(function () {
+        testContainer.innerHTML = tallElementMarkup() + '&lt;div id=&quot;host&quot;&gt;&lt;/div&gt;';
+        var host = document.querySelector('#host');
+        var shadowRoot = host.attachShadow({mode: mode});
+        shadowRoot.innerHTML = targetMarkup(elementType);
+        assert_equals(window.pageYOffset, 0);
+    });
+    clickFirstAnchorAndRunStep(test, function () {
+        assert_equals(window.pageYOffset, 0);
+    });
+}
+
+function testScrollingToElementInDocumentTreeAfterElementInShadowTreeWithSameID(elementType, mode, test)
+{
+    test.step(function () {
+        testContainer.innerHTML = tallElementMarkup() + '&lt;div id=&quot;host&quot;&gt;&lt;/div&gt;' + tallElementMarkup() + targetMarkup(elementType);
+        var host = document.querySelector('#host');
+        var shadowRoot = host.attachShadow({mode: mode});
+        shadowRoot.innerHTML = targetMarkup(elementType);
+        assert_equals(window.pageYOffset, 0);
+    });
+    clickFirstAnchorAndRunStep(test, function () {
+        assert_true(window.pageYOffset &gt; testContainer.querySelector('#host').offsetTop);
+    });
+}
+
+executeNextTest();
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomslotchangeeventexpectedtxtfromrev206462trunkLayoutTestsfastshadowdomslotchangeeventexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange-event-expected.txt (from rev 206462, trunk/LayoutTests/fast/shadow-dom/slotchange-event-expected.txt) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange-event-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange-event-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,36 @@
</span><ins>+
+PASS slotchange event must fire on a default slot element inside an open shadow root  in a document 
+PASS slotchange event must fire on a default slot element inside a closed shadow root  in a document 
+PASS slotchange event must fire on a default slot element inside an open shadow root  not in a document 
+PASS slotchange event must fire on a default slot element inside a closed shadow root  not in a document 
+PASS slotchange event must fire on a named slot element insidean open shadow root  in a document 
+PASS slotchange event must fire on a named slot element insidea closed shadow root  in a document 
+PASS slotchange event must fire on a named slot element insidean open shadow root  not in a document 
+PASS slotchange event must fire on a named slot element insidea closed shadow root  not in a document 
+PASS slotchange event must not fire on a slot element inside an open shadow root  in a document when another slot's assigned nodes change 
+PASS slotchange event must not fire on a slot element inside a closed shadow root  in a document when another slot's assigned nodes change 
+PASS slotchange event must not fire on a slot element inside an open shadow root  not in a document when another slot's assigned nodes change 
+PASS slotchange event must not fire on a slot element inside a closed shadow root  not in a document when another slot's assigned nodes change 
+PASS slotchange event must not fire on a slot element inside an open shadow root  in a document when the shadow host was mutated before the slot was inserted or after the slot was removed 
+PASS slotchange event must not fire on a slot element inside a closed shadow root  in a document when the shadow host was mutated before the slot was inserted or after the slot was removed 
+PASS slotchange event must not fire on a slot element inside an open shadow root  not in a document when the shadow host was mutated before the slot was inserted or after the slot was removed 
+PASS slotchange event must not fire on a slot element inside a closed shadow root  not in a document when the shadow host was mutated before the slot was inserted or after the slot was removed 
+PASS slotchange event must fire on a slot element inside an open shadow root  in a document even if the slot was removed immediately after the assigned nodes were mutated 
+PASS slotchange event must fire on a slot element inside a closed shadow root  in a document even if the slot was removed immediately after the assigned nodes were mutated 
+PASS slotchange event must fire on a slot element inside an open shadow root  not in a document even if the slot was removed immediately after the assigned nodes were mutated 
+PASS slotchange event must fire on a slot element inside a closed shadow root  not in a document even if the slot was removed immediately after the assigned nodes were mutated 
+PASS slotchange event must fire on a slot element inside an open shadow root  in a document when innerHTML modifies the children of the shadow host 
+PASS slotchange event must fire on a slot element inside a closed shadow root  in a document when innerHTML modifies the children of the shadow host 
+PASS slotchange event must fire on a slot element inside an open shadow root  not in a document when innerHTML modifies the children of the shadow host 
+PASS slotchange event must fire on a slot element inside a closed shadow root  not in a document when innerHTML modifies the children of the shadow host 
+PASS slotchange event must fire on a slot element inside an open shadow root  in a document when nested slots's contents change 
+PASS slotchange event must fire on a slot element inside a closed shadow root  in a document when nested slots's contents change 
+PASS slotchange event must fire on a slot element inside an open shadow root  not in a document when nested slots's contents change 
+PASS slotchange event must fire on a slot element inside a closed shadow root  not in a document when nested slots's contents change 
+PASS slotchange event must fire at the end of current microtask after mutation observers are invoked inside an open shadow root  in a document when slots's contents change 
+PASS slotchange event must fire at the end of current microtask after mutation observers are invoked inside a closed shadow root  in a document when slots's contents change 
+PASS slotchange event must fire at the end of current microtask after mutation observers are invoked inside an open shadow root  not in a document when slots's contents change 
+PASS slotchange event must fire at the end of current microtask after mutation observers are invoked inside a closed shadow root  not in a document when slots's contents change 
+hello
+hello
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomslotchangeeventhtmlfromrev206462trunkLayoutTestsfastshadowdomslotchangeeventhtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange-event.html (from rev 206462, trunk/LayoutTests/fast/shadow-dom/slotchange-event.html) (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange-event.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange-event.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,620 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;Shadow DOM: slotchange event&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;https://dom.spec.whatwg.org/#signaling-slot-change&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+// FIXME: Fix these test cases once https://github.com/w3c/webcomponents/issues/571 is resolved.
+
+function treeName(mode, connectedToDocument)
+{
+    return (mode == 'open' ? 'an ' : 'a ') + mode + ' shadow root '
+        + (connectedToDocument ? '' : ' not') + ' in a document';
+}
+
+function testAppendingSpanToShadowRootWithDefaultSlot(mode, connectedToDocument)
+{
+    var test = async_test('slotchange event must fire on a default slot element inside '
+        + treeName(mode, connectedToDocument));
+
+    var host;
+    var slot;
+    var eventCount = 0;
+
+    test.step(function () {
+        host = document.createElement('div');
+        if (connectedToDocument)
+            document.body.appendChild(host);
+
+        var shadowRoot = host.attachShadow({'mode': mode});
+        slot = document.createElement('slot');
+
+        slot.addEventListener('slotchange', function (event) {
+            if (event.isFakeEvent)
+                return;
+
+            test.step(function () {
+                assert_equals(event.type, 'slotchange', 'slotchange event\'s type must be &quot;slotchange&quot;');
+                assert_equals(event.target, slot, 'slotchange event\'s target must be the slot element');
+                assert_equals(event.relatedTarget, undefined, 'slotchange must not set relatedTarget');
+            });
+            eventCount++;
+        });
+
+        shadowRoot.appendChild(slot);
+
+        host.appendChild(document.createElement('span'));
+        host.appendChild(document.createElement('b'));
+
+        assert_equals(eventCount, 0, 'slotchange event must not be fired synchronously');
+    });
+
+    setTimeout(function () {
+        test.step(function () {
+            assert_equals(eventCount, 1, 'slotchange must be fired exactly once after the assigned nodes changed');
+
+            host.appendChild(document.createElement('i'));
+        });
+
+        setTimeout(function () {
+            test.step(function () {
+                assert_equals(eventCount, 2, 'slotchange must be fired exactly once after the assigned nodes changed');
+
+                host.appendChild(document.createTextNode('hello'));
+
+                var fakeEvent = new Event('slotchange');
+                fakeEvent.isFakeEvent = true;
+                slot.dispatchEvent(fakeEvent);
+            });
+
+            setTimeout(function () {
+                test.step(function () {
+                    assert_equals(eventCount, 3, 'slotchange must be fired exactly once after the assigned nodes changed'
+                        + ' event if there was a synthetic slotchange event fired');
+                });
+                test.done();
+            }, 1);
+        }, 1);
+    }, 1);
+}
+
+testAppendingSpanToShadowRootWithDefaultSlot('open', true);
+testAppendingSpanToShadowRootWithDefaultSlot('closed', true);
+testAppendingSpanToShadowRootWithDefaultSlot('open', false);
+testAppendingSpanToShadowRootWithDefaultSlot('closed', false);
+
+function testAppendingSpanToShadowRootWithNamedSlot(mode, connectedToDocument)
+{
+    var test = async_test('slotchange event must fire on a named slot element inside'
+        + treeName(mode, connectedToDocument));
+
+    var host;
+    var slot;
+    var eventCount = 0;
+
+    test.step(function () {
+        host = document.createElement('div');
+        if (connectedToDocument)
+            document.body.appendChild(host);
+
+        var shadowRoot = host.attachShadow({'mode': mode});
+        slot = document.createElement('slot');
+        slot.name = 'someSlot';
+
+        slot.addEventListener('slotchange', function (event) {
+            if (event.isFakeEvent)
+                return;
+
+            test.step(function () {
+                assert_equals(event.type, 'slotchange', 'slotchange event\'s type must be &quot;slotchange&quot;');
+                assert_equals(event.target, slot, 'slotchange event\'s target must be the slot element');
+                assert_equals(event.relatedTarget, undefined, 'slotchange must not set relatedTarget');
+            });
+            eventCount++;
+        });
+
+        shadowRoot.appendChild(slot);
+
+        var span = document.createElement('span');
+        span.slot = 'someSlot';
+        host.appendChild(span);
+
+        var b = document.createElement('b');
+        b.slot = 'someSlot';
+        host.appendChild(b);
+
+        assert_equals(eventCount, 0, 'slotchange event must not be fired synchronously');
+    });
+
+    setTimeout(function () {
+        test.step(function () {
+            assert_equals(eventCount, 1, 'slotchange must be fired exactly once after the assigned nodes changed');
+
+            var i = document.createElement('i');
+            i.slot = 'someSlot';
+            host.appendChild(i);
+        });
+
+        setTimeout(function () {
+            test.step(function () {
+                assert_equals(eventCount, 2, 'slotchange must be fired exactly once after the assigned nodes changed');
+
+                var em = document.createElement('em');
+                em.slot = 'someSlot';
+                host.appendChild(em);
+
+                var fakeEvent = new Event('slotchange');
+                fakeEvent.isFakeEvent = true;
+                slot.dispatchEvent(fakeEvent);
+            });
+
+            setTimeout(function () {
+                test.step(function () {
+                    assert_equals(eventCount, 3, 'slotchange must be fired exactly once after the assigned nodes changed'
+                        + ' event if there was a synthetic slotchange event fired');
+                });
+                test.done();
+            }, 1);
+
+        }, 1);
+    }, 1);
+}
+
+testAppendingSpanToShadowRootWithNamedSlot('open', true);
+testAppendingSpanToShadowRootWithNamedSlot('closed', true);
+testAppendingSpanToShadowRootWithNamedSlot('open', false);
+testAppendingSpanToShadowRootWithNamedSlot('closed', false);
+
+function testSlotchangeDoesNotFireWhenOtherSlotsChange(mode, connectedToDocument)
+{
+    var test = async_test('slotchange event must not fire on a slot element inside '
+        + treeName(mode, connectedToDocument)
+        + ' when another slot\'s assigned nodes change');
+
+    var host;
+    var defaultSlotEventCount = 0;
+    var namedSlotEventCount = 0;
+
+    test.step(function () {
+        host = document.createElement('div');
+        if (connectedToDocument)
+            document.body.appendChild(host);
+
+        var shadowRoot = host.attachShadow({'mode': mode});
+        var defaultSlot = document.createElement('slot');
+        defaultSlot.addEventListener('slotchange', function (event) {
+            test.step(function () {
+                assert_equals(event.target, defaultSlot, 'slotchange event\'s target must be the slot element');
+            });
+            defaultSlotEventCount++;
+        });
+
+        var namedSlot = document.createElement('slot');
+        namedSlot.name = 'slotName';
+        namedSlot.addEventListener('slotchange', function (event) {
+            test.step(function () {
+                assert_equals(event.target, namedSlot, 'slotchange event\'s target must be the slot element');
+            });
+            namedSlotEventCount++;
+        });
+
+        shadowRoot.appendChild(defaultSlot);
+        shadowRoot.appendChild(namedSlot);
+
+        host.appendChild(document.createElement('span'));
+
+        assert_equals(defaultSlotEventCount, 0, 'slotchange event must not be fired synchronously');
+        assert_equals(namedSlotEventCount, 0, 'slotchange event must not be fired synchronously');
+    });
+
+    setTimeout(function () {
+        test.step(function () {
+            assert_equals(defaultSlotEventCount, 1,
+                'slotchange must be fired exactly once after the assigned nodes change on a default slot');
+            assert_equals(namedSlotEventCount, 0,
+                'slotchange must not be fired on a named slot after the assigned nodes change on a default slot');
+
+            var span = document.createElement('span');
+            span.slot = 'slotName';
+            host.appendChild(span);
+        });
+
+        setTimeout(function () {
+            test.step(function () {
+                assert_equals(defaultSlotEventCount, 1,
+                    'slotchange must not be fired on a default slot after the assigned nodes change on a named slot');
+                assert_equals(namedSlotEventCount, 1,
+                    'slotchange must be fired exactly once after the assigned nodes change on a default slot');
+            });
+            test.done();
+        }, 1);
+    }, 1);
+}
+
+testSlotchangeDoesNotFireWhenOtherSlotsChange('open', true);
+testSlotchangeDoesNotFireWhenOtherSlotsChange('closed', true);
+testSlotchangeDoesNotFireWhenOtherSlotsChange('open', false);
+testSlotchangeDoesNotFireWhenOtherSlotsChange('closed', false);
+
+function testSlotchangeDoesNotFireForMutationBeforeOrAfterSlotWasPresent(mode, connectedToDocument)
+{
+    var test = async_test('slotchange event must not fire on a slot element inside '
+        + treeName(mode, connectedToDocument)
+        + ' when the shadow host was mutated before the slot was inserted or after the slot was removed');
+
+    var host;
+    var slot;
+    var eventCount = 0;
+
+    test.step(function () {
+        host = document.createElement('div');
+        if (connectedToDocument)
+            document.body.appendChild(host);
+
+        var shadowRoot = host.attachShadow({'mode': mode});
+        slot = document.createElement('slot');
+        slot.addEventListener('slotchange', function (event) {
+            test.step(function () {
+                assert_equals(event.target, slot, 'slotchange event\'s target must be the slot element');
+            });
+            eventCount++;
+        });
+
+        host.appendChild(document.createElement('span'));
+        shadowRoot.appendChild(slot);
+
+        assert_equals(eventCount, 0, 'slotchange event must not be fired synchronously');
+    });
+
+    setTimeout(function () {
+        test.step(function () {
+            assert_equals(eventCount, 0,
+                'slotchange must not be fired on a slot element if the assigned nodes changed before the slot was inserted');
+            host.removeChild(host.firstChild);
+        });
+
+        setTimeout(function () {
+            test.step(function () {
+                assert_equals(eventCount, 1,
+                    'slotchange must be fired exactly once after the assigned nodes change on a slot while the slot element was in the tree');
+                slot.parentNode.removeChild(slot);
+                host.appendChild(document.createElement('span'));
+            });
+
+            setTimeout(function () {
+                assert_equals(eventCount, 1,
+                    'slotchange must not be fired on a slot element if the assigned nodes changed after the slot was removed');
+                test.done();
+            }, 1);
+        }, 1);
+    }, 1);
+}
+
+testSlotchangeDoesNotFireForMutationBeforeOrAfterSlotWasPresent('open', true);
+testSlotchangeDoesNotFireForMutationBeforeOrAfterSlotWasPresent('closed', true);
+testSlotchangeDoesNotFireForMutationBeforeOrAfterSlotWasPresent('open', false);
+testSlotchangeDoesNotFireForMutationBeforeOrAfterSlotWasPresent('closed', false);
+
+function testSlotchangeFiresOnTransientlyPresentSlot(mode, connectedToDocument)
+{
+    var test = async_test('slotchange event must fire on a slot element inside '
+        + treeName(mode, connectedToDocument)
+        + ' even if the slot was removed immediately after the assigned nodes were mutated');
+
+    var host;
+    var slot;
+    var anotherSlot;
+    var slotEventCount = 0;
+    var anotherSlotEventCount = 0;
+
+    test.step(function () {
+        host = document.createElement('div');
+        if (connectedToDocument)
+            document.body.appendChild(host);
+
+        var shadowRoot = host.attachShadow({'mode': mode});
+        slot = document.createElement('slot');
+        slot.name = 'someSlot';
+        slot.addEventListener('slotchange', function (event) {
+            test.step(function () {
+                assert_equals(event.target, slot, 'slotchange event\'s target must be the slot element');
+            });
+            slotEventCount++;
+        });
+
+        anotherSlot = document.createElement('slot');
+        anotherSlot.name = 'someSlot';
+        anotherSlot.addEventListener('slotchange', function (event) {
+            test.step(function () {
+                assert_equals(event.target, anotherSlot, 'slotchange event\'s target must be the slot element');
+            });
+            anotherSlotEventCount++;
+        });
+
+        shadowRoot.appendChild(slot);
+
+        var span = document.createElement('span');
+        span.slot = 'someSlot';
+        host.appendChild(span);
+
+        shadowRoot.removeChild(slot);
+        shadowRoot.appendChild(anotherSlot);
+
+        var span = document.createElement('span');
+        span.slot = 'someSlot';
+        host.appendChild(span);
+
+        shadowRoot.removeChild(anotherSlot);
+
+        assert_equals(slotEventCount, 0, 'slotchange event must not be fired synchronously');
+        assert_equals(anotherSlotEventCount, 0, 'slotchange event must not be fired synchronously');
+    });
+
+    setTimeout(function () {
+        test.step(function () {
+            assert_equals(slotEventCount, 1,
+                'slotchange must be fired on a slot element if the assigned nodes changed while the slot was present');
+            assert_equals(anotherSlotEventCount, 1,
+                'slotchange must be fired on a slot element if the assigned nodes changed while the slot was present');
+        });
+        test.done();
+    }, 1);
+}
+
+testSlotchangeFiresOnTransientlyPresentSlot('open', true);
+testSlotchangeFiresOnTransientlyPresentSlot('closed', true);
+testSlotchangeFiresOnTransientlyPresentSlot('open', false);
+testSlotchangeFiresOnTransientlyPresentSlot('closed', false);
+
+function testSlotchangeFiresOnInnerHTML(mode, connectedToDocument)
+{
+    var test = async_test('slotchange event must fire on a slot element inside '
+        + treeName(mode, connectedToDocument)
+        + ' when innerHTML modifies the children of the shadow host');
+
+    var host;
+    var defaultSlot;
+    var namedSlot;
+    var defaultSlotEventCount = 0;
+    var namedSlotEventCount = 0;
+
+    test.step(function () {
+        host = document.createElement('div');
+        if (connectedToDocument)
+            document.body.appendChild(host);
+
+        var shadowRoot = host.attachShadow({'mode': mode});
+        defaultSlot = document.createElement('slot');
+        defaultSlot.addEventListener('slotchange', function (event) {
+            test.step(function () {
+                assert_equals(event.target, defaultSlot, 'slotchange event\'s target must be the slot element');
+            });
+            defaultSlotEventCount++;
+        });
+
+        namedSlot = document.createElement('slot');
+        namedSlot.name = 'someSlot';
+        namedSlot.addEventListener('slotchange', function (event) {
+            test.step(function () {
+                assert_equals(event.target, namedSlot, 'slotchange event\'s target must be the slot element');
+            });
+            namedSlotEventCount++;
+        });
+        shadowRoot.appendChild(namedSlot);
+        shadowRoot.appendChild(defaultSlot);
+        host.innerHTML = 'foo &lt;b&gt;bar&lt;/b&gt;';
+
+        assert_equals(defaultSlotEventCount, 0, 'slotchange event must not be fired synchronously');
+        assert_equals(namedSlotEventCount, 0, 'slotchange event must not be fired synchronously');
+    });
+
+    setTimeout(function () {
+        test.step(function () {
+            assert_equals(defaultSlotEventCount, 1,
+                'slotchange must be fired on a slot element if the assigned nodes are changed by innerHTML');
+            assert_equals(namedSlotEventCount, 0,
+                'slotchange must not be fired on a slot element if the assigned nodes are not changed by innerHTML');
+            host.innerHTML = 'baz';
+        });
+        setTimeout(function () {
+            test.step(function () {
+                assert_equals(defaultSlotEventCount, 2,
+                    'slotchange must be fired on a slot element if the assigned nodes are changed by innerHTML');
+                assert_equals(namedSlotEventCount, 0,
+                    'slotchange must not be fired on a slot element if the assigned nodes are not changed by innerHTML');
+                host.innerHTML = '';
+            });
+            setTimeout(function () {
+                test.step(function () {
+                    assert_equals(defaultSlotEventCount, 3,
+                        'slotchange must be fired on a slot element if the assigned nodes are changed by innerHTML');
+                    assert_equals(namedSlotEventCount, 0,
+                        'slotchange must not be fired on a slot element if the assigned nodes are not changed by innerHTML');
+                    host.innerHTML = '&lt;b slot=&quot;someSlot&quot;&gt;content&lt;/b&gt;';
+                });
+                setTimeout(function () {
+                    test.step(function () {
+                        assert_equals(defaultSlotEventCount, 3,
+                            'slotchange must not be fired on a slot element if the assigned nodes are not changed by innerHTML');
+                        assert_equals(namedSlotEventCount, 1,
+                            'slotchange must not be fired on a slot element if the assigned nodes are changed by innerHTML');
+                        host.innerHTML = '';
+                    });
+                    setTimeout(function () {
+                        test.step(function () {
+                            // FIXME: This test would fail in the current implementation because we can't tell
+                            // whether a text node was removed in AllChildrenRemoved or not.
+//                            assert_equals(defaultSlotEventCount, 3,
+//                                'slotchange must not be fired on a slot element if the assigned nodes are not changed by innerHTML');
+                            assert_equals(namedSlotEventCount, 2,
+                                'slotchange must not be fired on a slot element if the assigned nodes are changed by innerHTML');
+                        });
+                        test.done();
+                    }, 1);
+                }, 1);
+            }, 1);
+        }, 1);
+    }, 1);
+}
+
+testSlotchangeFiresOnInnerHTML('open', true);
+testSlotchangeFiresOnInnerHTML('closed', true);
+testSlotchangeFiresOnInnerHTML('open', false);
+testSlotchangeFiresOnInnerHTML('closed', false);
+
+function testSlotchangeFiresWhenNestedSlotChange(mode, connectedToDocument)
+{
+    var test = async_test('slotchange event must fire on a slot element inside '
+        + treeName(mode, connectedToDocument)
+        + ' when nested slots\'s contents change');
+
+    var outerHost;
+    var innerHost;
+    var outerSlot;
+    var innerSlot;
+    var outerSlotEventCount = 0;
+    var innerSlotEventCount = 0;
+
+    test.step(function () {
+        outerHost = document.createElement('div');
+        if (connectedToDocument)
+            document.body.appendChild(outerHost);
+
+        var outerShadow = outerHost.attachShadow({'mode': mode});
+        outerShadow.appendChild(document.createElement('span'));
+        outerSlot = document.createElement('slot');
+        outerSlot.addEventListener('slotchange', function (event) {
+            event.stopPropagation();
+            test.step(function () {
+                assert_equals(event.target, outerSlot, 'slotchange event\'s target must be the slot element');
+            });
+            outerSlotEventCount++;
+        });
+
+        innerHost = document.createElement('div');
+        innerHost.appendChild(outerSlot);
+        outerShadow.appendChild(innerHost);
+
+        var innerShadow = innerHost.attachShadow({'mode': mode});
+        innerShadow.appendChild(document.createElement('span'));
+        innerSlot = document.createElement('slot');
+        innerSlot.addEventListener('slotchange', function (event) {
+            event.stopPropagation();
+            test.step(function () {
+                assert_equals(event.target, innerSlot, 'slotchange event\'s target must be the slot element');
+            });
+            innerSlotEventCount++;
+        });
+        innerShadow.appendChild(innerSlot);
+
+        outerHost.appendChild(document.createElement('span'));
+
+        assert_equals(innerSlotEventCount, 0, 'slotchange event must not be fired synchronously');
+        assert_equals(outerSlotEventCount, 0, 'slotchange event must not be fired synchronously');
+    });
+
+    setTimeout(function () {
+        test.step(function () {
+            assert_equals(innerSlotEventCount, 1,
+                'slotchange must be fired on a slot element if the assigned nodes changed');
+            assert_equals(outerSlotEventCount, 1,
+                'slotchange must be fired on a slot element if the assigned nodes of an inner slot changed');
+        });
+        test.done();
+    }, 1);
+}
+
+testSlotchangeFiresWhenNestedSlotChange('open', true);
+testSlotchangeFiresWhenNestedSlotChange('closed', true);
+testSlotchangeFiresWhenNestedSlotChange('open', false);
+testSlotchangeFiresWhenNestedSlotChange('closed', false);
+
+function testSlotchangeFiresAtEndOfMicroTask(mode, connectedToDocument)
+{
+    var test = async_test('slotchange event must fire at the end of current microtask after mutation observers are invoked inside '
+        + treeName(mode, connectedToDocument) + ' when slots\'s contents change');
+
+    var outerHost;
+    var innerHost;
+    var outerSlot;
+    var innerSlot;
+    var slotchangeEvents = [];
+
+    test.step(function () {
+        outerHost = document.createElement('div');
+        if (connectedToDocument)
+            document.body.appendChild(outerHost);
+
+        var outerShadow = outerHost.attachShadow({'mode': mode});
+        outerShadow.appendChild(document.createElement('span'));
+        outerSlot = document.createElement('slot');
+        outerSlot.addEventListener('slotchange', function (event) {
+            event.stopPropagation();
+            test.step(function () {
+                assert_equals(event.target, outerSlot, 'slotchange event\'s target must be the slot element');
+            });
+            slotchangeEvents.push('outer');
+        });
+
+        innerHost = document.createElement('div');
+        innerHost.appendChild(outerSlot);
+        outerShadow.appendChild(innerHost);
+
+        var innerShadow = innerHost.attachShadow({'mode': mode});
+        innerShadow.appendChild(document.createElement('span'));
+        innerSlot = document.createElement('slot');
+        innerSlot.addEventListener('slotchange', function (event) {
+            event.stopPropagation();
+            test.step(function () {
+                assert_equals(event.target, innerSlot, 'slotchange event\'s target must be the slot element');
+            });
+            slotchangeEvents.push('inner');
+        });
+        innerShadow.appendChild(innerSlot);
+
+        outerHost.appendChild(document.createElement('span'));
+
+        assert_equals(slotchangeEvents.length, 0, 'slotchange event must not be fired synchronously');
+    });
+
+    var element = document.createElement('div');
+
+    new MutationObserver(function () {
+        test.step(function () {
+            assert_equals(slotchangeEvents.length, 0, 'slotchange event must not be fired before mutation records are delivered');
+        });
+        element.setAttribute('title', 'bar');
+        innerHost.appendChild(document.createElement('span'));
+    }).observe(element, {attributes: true, attributeFilter: ['id']});
+
+    new MutationObserver(function () {
+        test.step(function () {
+            assert_array_equals(slotchangeEvents, ['outer', 'inner'], 'slotchange event must be fired during a single compound microtask');
+        });
+    }).observe(element, {attributes: true, attributeFilter: ['title']});
+
+    element.setAttribute('id', 'foo');
+
+    setTimeout(function () {
+        test.step(function () {
+            assert_array_equals(slotchangeEvents, ['outer', 'inner', 'inner'],
+                'a distinct slotchange event must be enqueued for changes made during a mutation observer delivery');
+        });
+        test.done();
+    }, 0);
+}
+
+testSlotchangeFiresAtEndOfMicroTask('open', true);
+testSlotchangeFiresAtEndOfMicroTask('closed', true);
+testSlotchangeFiresAtEndOfMicroTask('open', false);
+testSlotchangeFiresAtEndOfMicroTask('closed', false);
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomslotchangeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange-expected.txt (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+
+Harness Error (TIMEOUT), message = null
+
+PASS slotchange event: Append a child to a host. 
+PASS slotchange event: Remove a child from a host. 
+PASS slotchange event: Remove a child before adding an event listener. 
+PASS slotchange event: Change slot= attribute to make it un-assigned. 
+TIMEOUT slotchange event: Change slot's name= attribute so that none is assigned. Test timed out
+PASS slotchange event: Change slot= attribute to make it assigned. 
+TIMEOUT slotchange event: Change slot's name= attribute so that a node is assigned to the slot. Test timed out
+PASS slotchange event: Add a fallback content. 
+PASS slotchange event: Remove a fallback content. 
+TIMEOUT slotchange event: Add a fallback content to nested slots. Test timed out
+TIMEOUT slotchange event: Remove a fallback content from nested slots. Test timed out
+TIMEOUT slotchange event: Insert a slot before an existing slot. Test timed out
+TIMEOUT slotchange event: Remove a preceding slot. Test timed out
+PASS slotchange event: A slot is assigned to another slot. 
+PASS slotchange event: Even if distributed nodes do not change, slotchange should be fired if assigned nodes are changed. 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomslotchangehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange.html (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,270 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;title&gt;Shadow DOM: slotchange Events&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Hayato Ito&quot; href=&quot;mailto:hayato@google.com&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/shadow-dom.js&quot;&gt;&lt;/script&gt;
+
+&lt;div id=&quot;test1&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot;&gt;&lt;/slot&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c1&quot; slot=&quot;slot1&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+function doneIfSlotChange(slots, test) {
+  let fired = new Set();
+  for (let slot of slots) {
+    slot.addEventListener('slotchange', test.step_func((e) =&gt; {
+      assert_false(fired.has(slot.id));
+      fired.add(slot.id);
+      if (fired.size == slots.length) {
+        test.done();
+      }
+    }))
+  }
+}
+
+async_test((test) =&gt; {
+  let n = createTestTree(test1);
+  removeWhiteSpaceOnlyTextNodes(n.test1);
+
+  doneIfSlotChange([n.s1], test);
+
+  let d1 = document.createElement('div');
+  d1.setAttribute('slot', 'slot1');
+  n.host1.appendChild(d1);
+}, 'slotchange event: Append a child to a host.');
+
+async_test((test) =&gt; {
+  let n = createTestTree(test1);
+  removeWhiteSpaceOnlyTextNodes(n.test1);
+
+  doneIfSlotChange([n.s1], test);
+
+  n.c1.remove();
+}, 'slotchange event: Remove a child from a host.');
+
+async_test((test) =&gt; {
+  let n = createTestTree(test1);
+  removeWhiteSpaceOnlyTextNodes(n.test1);
+
+  n.c1.remove();
+
+  doneIfSlotChange([n.s1], test);
+}, 'slotchange event: Remove a child before adding an event listener.');
+
+async_test((test) =&gt; {
+  let n = createTestTree(test1);
+  removeWhiteSpaceOnlyTextNodes(n.test1);
+
+  doneIfSlotChange([n.s1], test);
+
+  n.c1.setAttribute('slot', 'slot-none');
+}, 'slotchange event: Change slot= attribute to make it un-assigned.');
+
+async_test((test) =&gt; {
+  let n = createTestTree(test1);
+  removeWhiteSpaceOnlyTextNodes(n.test1);
+
+  doneIfSlotChange([n.s1], test);
+
+  n.s1.setAttribute('name', 'slot-none');
+}, 'slotchange event: Change slot\'s name= attribute so that none is assigned.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test2&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot;&gt;&lt;/slot&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c2&quot; slot=&quot;slot2&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+async_test((test) =&gt; {
+  let n = createTestTree(test2);
+  removeWhiteSpaceOnlyTextNodes(n.test2);
+
+  doneIfSlotChange([n.s1], test);
+
+  n.c2.setAttribute('slot', 'slot1');
+}, 'slotchange event: Change slot= attribute to make it assigned.');
+
+async_test((test) =&gt; {
+  let n = createTestTree(test2);
+  removeWhiteSpaceOnlyTextNodes(n.test2);
+
+  doneIfSlotChange([n.s1], test);
+
+  n.s1.setAttribute('name', 'slot2');
+}, 'slotchange event: Change slot\'s name= attribute so that a node is assigned to the slot.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test_fallback&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;slot id=&quot;s1&quot;&gt;&lt;/slot&gt;
+    &lt;/template&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+async_test((test) =&gt; {
+  let n = createTestTree(test_fallback);
+  removeWhiteSpaceOnlyTextNodes(n.test_fallback);
+
+  doneIfSlotChange([n.s1], test);
+
+  n.s1.appendChild(document.createElement('div'));
+}, 'slotchange event: Add a fallback content.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test_fallback2&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;slot id=&quot;s1&quot;&gt;
+        &lt;div id=&quot;f1&quot;&gt;&lt;/div&gt;
+      &lt;/slot&gt;
+    &lt;/template&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+async_test((test) =&gt; {
+  let n = createTestTree(test_fallback2);
+  removeWhiteSpaceOnlyTextNodes(n.test_fallback2);
+
+  doneIfSlotChange([n.s1], test);
+
+  n.f1.remove();
+}, 'slotchange event: Remove a fallback content.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test_fallback3&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;slot id=&quot;s2&quot;&gt;
+        &lt;slot id=&quot;s1&quot;&gt;
+          &lt;div id=&quot;f1&quot;&gt;&lt;/div&gt;
+        &lt;/slot&gt;
+      &lt;/slot&gt;
+    &lt;/template&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+async_test((test) =&gt; {
+  let n = createTestTree(test_fallback3);
+  removeWhiteSpaceOnlyTextNodes(n.test_fallback3);
+
+  doneIfSlotChange([n.s1, n.s2], test);
+
+  n.s1.appendChild(document.createElement('div'));
+}, 'slotchange event: Add a fallback content to nested slots.');
+
+async_test((test) =&gt; {
+  let n = createTestTree(test_fallback3);
+  removeWhiteSpaceOnlyTextNodes(n.test_fallback3);
+
+  doneIfSlotChange([n.s1, n.s2], test);
+
+  n.f1.remove();
+}, 'slotchange event: Remove a fallback content from nested slots.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test3&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template id=&quot;shadowroot&quot; data-mode=&quot;open&quot;&gt;
+      &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot;&gt;&lt;/slot&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c1&quot; slot=&quot;slot1&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+async_test((test) =&gt; {
+  let n = createTestTree(test3);
+  removeWhiteSpaceOnlyTextNodes(n.test3);
+
+  doneIfSlotChange([n.s1], test);
+
+  let slot = document.createElement('slot');
+  slot.setAttribute('name', 'slot1');
+  n.shadowroot.insertBefore(slot, n.s1);
+}, &quot;slotchange event: Insert a slot before an existing slot.&quot;);
+&lt;/script&gt;
+
+&lt;div id=&quot;test4&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template id=&quot;shadowroot&quot; data-mode=&quot;open&quot;&gt;
+      &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot;&gt;&lt;/slot&gt;
+      &lt;slot id=&quot;s2&quot; name=&quot;slot1&quot;&gt;&lt;/slot&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c1&quot; slot=&quot;slot1&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+async_test((test) =&gt; {
+  let n = createTestTree(test4);
+  removeWhiteSpaceOnlyTextNodes(n.test4);
+
+  doneIfSlotChange([n.s2], test);
+
+  n.s1.remove();
+}, &quot;slotchange event: Remove a preceding slot.&quot;);
+&lt;/script&gt;
+
+&lt;div id=&quot;test5&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;div id=&quot;host2&quot;&gt;
+        &lt;template data-mode=&quot;open&quot;&gt;
+          &lt;slot id=&quot;s2&quot; name=&quot;slot2&quot;&gt;&lt;/slot&gt;
+        &lt;/template&gt;
+        &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot; slot=&quot;slot2&quot;&gt;&lt;/slot&gt;
+      &lt;/div&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c1&quot; slot=&quot;slot1&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+async_test((test) =&gt; {
+  let n = createTestTree(test5);
+  removeWhiteSpaceOnlyTextNodes(n.test5);
+
+  doneIfSlotChange([n.s1, n.s2], test);
+
+  n.c1.remove();
+}, &quot;slotchange event: A slot is assigned to another slot.&quot;);
+&lt;/script&gt;
+
+&lt;div id=&quot;test6&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;div id=&quot;host2&quot;&gt;
+        &lt;template data-mode=&quot;open&quot;&gt;
+          &lt;slot id=&quot;s2&quot; name=&quot;slot2&quot;&gt;&lt;/slot&gt;
+        &lt;/template&gt;
+        &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot; slot=&quot;slot2&quot;&gt;&lt;/slot&gt;
+      &lt;/div&gt;
+    &lt;/template&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+async_test((test) =&gt; {
+  let n = createTestTree(test6);
+  removeWhiteSpaceOnlyTextNodes(n.test6);
+
+  doneIfSlotChange([n.s2], test);
+
+  n.s1.remove();
+}, &quot;slotchange event: Even if distributed nodes do not change, slotchange should be fired if assigned nodes are changed.&quot;);
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomslotsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-expected.txt (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+
+PASS Slots: Basic. 
+PASS Slots: Slots in closed. 
+PASS Slots: Slots not in a shadow tree. 
+FAIL Slots: Distributed nooes for Slots not in a shadow tree. assert_array_equals: lengths differ, expected 1 got 0
+PASS Slots: Name matching 
+PASS Slots: No direct host child. 
+PASS Slots: Default Slot. 
+PASS Slots: Slot in Slot does not matter in assignment. 
+PASS Slots: Slot is assigned to another slot 
+PASS Slots: Open &gt; Closed. 
+PASS Slots: Closed &gt; Closed. 
+PASS Slots: Closed &gt; Open. 
+PASS Slots: Complex case: Basi line. 
+PASS Slots: Mutation: appendChild. 
+PASS Slots: Mutation: Change slot= attribute 1. 
+PASS Slots: Mutation: Change slot= attribute 2. 
+PASS Slots: Mutation: Change slot= attribute 3. 
+PASS Slots: Mutation: Remove a child. 
+PASS Slots: Mutation: Add a slot: after. 
+PASS Slots: Mutation: Add a slot: before. 
+PASS Slots: Mutation: Remove a slot. 
+PASS Slots: Mutation: Change slot name= attribute. 
+PASS Slots: Mutation: Change slot slot= attribute. 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomslotsfallbackexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-fallback-expected.txt (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-fallback-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-fallback-expected.txt        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+
+FAIL Slots fallback: Basic. assert_array_equals: lengths differ, expected 1 got 0
+FAIL Slots fallback: Slots in Slots. assert_array_equals: lengths differ, expected 1 got 0
+FAIL Slots fallback: Fallback contents should not be used if a node is assigned. assert_array_equals: lengths differ, expected 1 got 0
+FAIL Slots fallback: Slots in Slots: Assinged nodes should be used as fallback contents of another slot assert_array_equals: lengths differ, expected 1 got 0
+FAIL Slots fallback: Complex case. assert_array_equals: lengths differ, expected 2 got 0
+FAIL Slots fallback: Mutation. Append fallback contents. assert_array_equals: lengths differ, expected 3 got 0
+FAIL Slots fallback: Mutation. Remove fallback contents. assert_array_equals: lengths differ, expected 1 got 0
+FAIL Slots fallback: Mutation. Assign a node to a slot so that fallback contens are no longer used. assert_array_equals: lengths differ, expected 2 got 0
+FAIL Slots fallback: Mutation. Remove an assigned node from a slot so that fallback contens will be used. assert_array_equals: lengths differ, expected 1 got 0
+FAIL Slots fallback: Mutation.  Remove a slot which is a fallback content of another slot. assert_array_equals: lengths differ, expected 1 got 0
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomslotsfallbackhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-fallback.html (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-fallback.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-fallback.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,221 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;title&gt;Shadow DOM: Slots and fallback contents&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Hayato Ito&quot; href=&quot;mailto:hayato@google.com&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/shadow-dom.js&quot;&gt;&lt;/script&gt;
+
+&lt;div id=&quot;test1&quot;&gt;
+  &lt;div id=&quot;host&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot;&gt;
+        &lt;div id=&quot;f1&quot;&gt;&lt;/div&gt;
+      &lt;/slot&gt;
+    &lt;/template&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test1);
+  removeWhiteSpaceOnlyTextNodes(n.test1);
+
+  assert_equals(n.f1.assignedSlot, null);
+
+  assert_array_equals(n.s1.assignedNodes(), []);
+  assert_array_equals(n.s1.assignedNodes({ flatten: true }), [n.f1]);
+}, 'Slots fallback: Basic.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test2&quot;&gt;
+  &lt;div id=&quot;host&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot;&gt;
+        &lt;slot id=&quot;s2&quot; name=&quot;slot2&quot;&gt;
+          &lt;div id=&quot;f1&quot;&gt;&lt;/div&gt;
+        &lt;/slot&gt;
+      &lt;/slot&gt;
+    &lt;/template&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test2);
+  removeWhiteSpaceOnlyTextNodes(n.test2);
+
+  assert_equals(n.f1.assignedSlot, null);
+
+  assert_array_equals(n.s1.assignedNodes(), []);
+  assert_array_equals(n.s2.assignedNodes(), []);
+
+  assert_array_equals(n.s1.assignedNodes({ flatten: true }), [n.f1]);
+  assert_array_equals(n.s2.assignedNodes({ flatten: true }), [n.f1]);
+}, 'Slots fallback: Slots in Slots.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test3&quot;&gt;
+  &lt;div id=&quot;host&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot;&gt;
+        &lt;slot id=&quot;s2&quot; name=&quot;slot2&quot;&gt;
+          &lt;div id=&quot;f1&quot;&gt;&lt;/div&gt;
+        &lt;/slot&gt;
+      &lt;/slot&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c1&quot; slot=&quot;slot1&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test3);
+  removeWhiteSpaceOnlyTextNodes(n.test3);
+
+  assert_equals(n.c1.assignedSlot, n.s1);
+  assert_equals(n.f1.assignedSlot, null);
+
+  assert_array_equals(n.s1.assignedNodes(), [n.c1]);
+  assert_array_equals(n.s2.assignedNodes(), []);
+
+  assert_array_equals(n.s1.assignedNodes({ flatten: true }), [n.c1]);
+  assert_array_equals(n.s2.assignedNodes({ flatten: true }), [n.f1]);
+}, 'Slots fallback: Fallback contents should not be used if a node is assigned.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test4&quot;&gt;
+  &lt;div id=&quot;host&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot;&gt;
+        &lt;slot id=&quot;s2&quot; name=&quot;slot2&quot;&gt;
+          &lt;div id=&quot;f1&quot;&gt;&lt;/div&gt;
+        &lt;/slot&gt;
+      &lt;/slot&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c1&quot; slot=&quot;slot2&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test4);
+  removeWhiteSpaceOnlyTextNodes(n.test4);
+
+  assert_equals(n.c1.assignedSlot, n.s2);
+  assert_equals(n.f1.assignedSlot, null);
+
+  assert_array_equals(n.s1.assignedNodes(), []);
+  assert_array_equals(n.s2.assignedNodes(), [n.c1]);
+
+  assert_array_equals(n.s1.assignedNodes({ flatten: true }), [n.c1]);
+  assert_array_equals(n.s2.assignedNodes({ flatten: true }), [n.c1]);
+}, 'Slots fallback: Slots in Slots: Assinged nodes should be used as fallback contents of another slot');
+&lt;/script&gt;
+
+&lt;div id=&quot;test5&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;div id=&quot;host2&quot;&gt;
+        &lt;template data-mode=&quot;open&quot;&gt;
+          &lt;slot id=&quot;s4&quot; name=&quot;slot4&quot;&gt;
+            &lt;slot id=&quot;s3&quot; name=&quot;slot3&quot;&gt;
+              &lt;div id=&quot;f3&quot;&gt;&lt;/div&gt;
+            &lt;/slot&gt;
+            &lt;div id=&quot;f4&quot;&gt;&lt;/div&gt;
+          &lt;/slot&gt;
+        &lt;/template&gt;
+        &lt;slot id=&quot;s2&quot; name=&quot;slot2&quot; slot=&quot;slot3&quot;&gt;
+          &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot;&gt;
+            &lt;div id=&quot;f1&quot;&gt;&lt;/div&gt;
+          &lt;/slot&gt;
+          &lt;div id=&quot;f2&quot;&gt;&lt;/div&gt;
+        &lt;/slot&gt;
+      &lt;/div&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c1&quot; slot=&quot;slot1&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test5);
+  removeWhiteSpaceOnlyTextNodes(n.test5);
+
+  assert_array_equals(n.s1.assignedNodes(), [n.c1]);
+  assert_array_equals(n.s2.assignedNodes(), []);
+  assert_array_equals(n.s3.assignedNodes(), [n.s2]);
+  assert_array_equals(n.s4.assignedNodes(), []);
+
+  assert_array_equals(n.s1.assignedNodes({ flatten: true }), [n.c1]);
+  assert_array_equals(n.s2.assignedNodes({ flatten: true }), [n.c1, n.f2]);
+  assert_array_equals(n.s3.assignedNodes({ flatten: true }), [n.c1, n.f2]);
+  assert_array_equals(n.s4.assignedNodes({ flatten: true }), [n.c1, n.f2, n.f4]);
+}, 'Slots fallback: Complex case.');
+
+test(() =&gt; {
+  let n = createTestTree(test5);
+  removeWhiteSpaceOnlyTextNodes(n.test5);
+
+  let d1 = document.createElement('div');
+  n.s2.appendChild(d1);
+
+  assert_array_equals(n.s1.assignedNodes({ flatten: true }), [n.c1]);
+  assert_array_equals(n.s2.assignedNodes({ flatten: true }), [n.c1, n.f2, d1]);
+  assert_array_equals(n.s3.assignedNodes({ flatten: true }), [n.c1, n.f2, d1]);
+  assert_array_equals(n.s4.assignedNodes({ flatten: true }), [n.c1, n.f2, d1, n.f4]);
+}, 'Slots fallback: Mutation. Append fallback contents.');
+
+test(() =&gt; {
+  let n = createTestTree(test5);
+  removeWhiteSpaceOnlyTextNodes(n.test5);
+
+  n.f2.remove();
+
+  assert_array_equals(n.s1.assignedNodes({ flatten: true }), [n.c1]);
+  assert_array_equals(n.s2.assignedNodes({ flatten: true }), [n.c1]);
+  assert_array_equals(n.s3.assignedNodes({ flatten: true }), [n.c1]);
+  assert_array_equals(n.s4.assignedNodes({ flatten: true }), [n.c1, n.f4]);
+}, 'Slots fallback: Mutation. Remove fallback contents.');
+
+test(() =&gt; {
+  let n = createTestTree(test5);
+  removeWhiteSpaceOnlyTextNodes(n.test5);
+
+  let d2 = document.createElement('div');
+  d2.setAttribute('slot', 'slot2');
+  n.host1.appendChild(d2);
+
+  assert_array_equals(n.s2.assignedNodes(), [d2]);
+  assert_array_equals(n.s2.assignedNodes({ flatten: true }), [d2]);
+  assert_array_equals(n.s3.assignedNodes({ flatten: true }), [d2]);
+  assert_array_equals(n.s4.assignedNodes({ flatten: true }), [d2, n.f4]);
+}, 'Slots fallback: Mutation. Assign a node to a slot so that fallback contens are no longer used.');
+
+test(() =&gt; {
+  let n = createTestTree(test5);
+  removeWhiteSpaceOnlyTextNodes(n.test5);
+
+  n.c1.remove();
+
+  assert_array_equals(n.s1.assignedNodes(), []);
+
+  assert_array_equals(n.s1.assignedNodes({ flatten: true }), [n.f1]);
+  assert_array_equals(n.s2.assignedNodes({ flatten: true }), [n.f1, n.f2]);
+  assert_array_equals(n.s3.assignedNodes({ flatten: true }), [n.f1, n.f2]);
+  assert_array_equals(n.s4.assignedNodes({ flatten: true }), [n.f1, n.f2, n.f4]);
+}, 'Slots fallback: Mutation. Remove an assigned node from a slot so that fallback contens will be used.');
+
+test(() =&gt; {
+  let n = createTestTree(test5);
+  removeWhiteSpaceOnlyTextNodes(n.test5);
+
+  n.s1.remove();
+
+  assert_array_equals(n.s1.assignedNodes(), []);
+
+  assert_array_equals(n.s1.assignedNodes({ flatten: true }), [n.f1]);
+  assert_array_equals(n.s2.assignedNodes({ flatten: true }), [n.f2]);
+  assert_array_equals(n.s3.assignedNodes({ flatten: true }), [n.f2]);
+  assert_array_equals(n.s4.assignedNodes({ flatten: true }), [n.f2, n.f4]);
+}, 'Slots fallback: Mutation.  Remove a slot which is a fallback content of another slot.');
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomslotshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots.html (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots.html        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,508 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;title&gt;Shadow DOM: Slots and assignments&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Hayato Ito&quot; href=&quot;mailto:hayato@google.com&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/shadow-dom.js&quot;&gt;&lt;/script&gt;
+
+&lt;div id=&quot;test_basic&quot;&gt;
+  &lt;div id=&quot;host&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot;&gt;&lt;/slot&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c1&quot; slot=&quot;slot1&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test_basic);
+  removeWhiteSpaceOnlyTextNodes(n.test_basic);
+
+  assert_equals(n.c1.assignedSlot, n.s1);
+  assert_array_equals(n.s1.assignedNodes(), [n.c1]);
+}, 'Slots: Basic.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test_basic_closed&quot;&gt;
+  &lt;div id=&quot;host&quot;&gt;
+    &lt;template data-mode=&quot;closed&quot;&gt;
+      &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot;&gt;&lt;/slot&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c1&quot; slot=&quot;slot1&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test_basic_closed);
+  removeWhiteSpaceOnlyTextNodes(n.test_basic_closed);
+
+  assert_equals(n.c1.assignedSlot, null);
+  assert_array_equals(n.s1.assignedNodes(), [n.c1]);
+}, 'Slots: Slots in closed.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test_slot_not_in_shadow&quot;&gt;
+  &lt;slot id=&quot;s1&quot;&gt;&lt;/slot&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test_slot_not_in_shadow);
+  removeWhiteSpaceOnlyTextNodes(n.test_slot_not_in_shadow);
+
+  assert_array_equals(n.s1.assignedNodes(), []);
+}, 'Slots: Slots not in a shadow tree.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test_slot_not_in_shadow_2&quot;&gt;
+  &lt;slot id=&quot;s1&quot;&gt;
+    &lt;div id=&quot;c1&quot;&gt;&lt;/div&gt;
+  &lt;/slot&gt;
+  &lt;slot id=&quot;s2&quot;&gt;
+    &lt;div id=&quot;c2&quot;&gt;&lt;/div&gt;
+    &lt;slot id=&quot;s3&quot;&gt;
+      &lt;div id=&quot;c3_1&quot;&gt;&lt;/div&gt;
+      &lt;div id=&quot;c3_2&quot;&gt;&lt;/div&gt;
+    &lt;/slot&gt;
+  &lt;/slot&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test_slot_not_in_shadow_2);
+  removeWhiteSpaceOnlyTextNodes(n.test_slot_not_in_shadow_2);
+
+  assert_equals(n.c1.assignedSlot, null);
+  assert_equals(n.c2.assignedSlot, null);
+  assert_equals(n.c3_1.assignedSlot, null);
+  assert_equals(n.c3_2.assignedSlot, null);
+
+  assert_array_equals(n.s1.assignedNodes(), []);
+  assert_array_equals(n.s2.assignedNodes(), []);
+  assert_array_equals(n.s3.assignedNodes(), []);
+
+  assert_array_equals(n.s1.assignedNodes({ flatten: true }), [n.c1]);
+  assert_array_equals(n.s2.assignedNodes({ flatten: true }), [n.c2, n.c3_1, n.c3_2]);
+  assert_array_equals(n.s3.assignedNodes({ flatten: true }), [n.c3_1, n.c3_2]);
+}, 'Slots: Distributed nooes for Slots not in a shadow tree.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test_slot_name_matching&quot;&gt;
+  &lt;div id=&quot;host&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot;&gt;&lt;/slot&gt;
+      &lt;slot id=&quot;s2&quot; name=&quot;slot2&quot;&gt;&lt;/slot&gt;
+      &lt;slot id=&quot;s3&quot; name=&quot;xxx&quot;&gt;&lt;/slot&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c1&quot; slot=&quot;slot1&quot;&gt;&lt;/div&gt;
+    &lt;div id=&quot;c2&quot; slot=&quot;slot2&quot;&gt;&lt;/div&gt;
+    &lt;div id=&quot;c3&quot; slot=&quot;yyy&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test_slot_name_matching);
+  removeWhiteSpaceOnlyTextNodes(n.test_slot_name_matching);
+
+  assert_equals(n.c1.assignedSlot, n.s1);
+  assert_equals(n.c2.assignedSlot, n.s2);
+  assert_equals(n.c3.assignedSlot, null);
+}, 'Slots: Name matching');
+&lt;/script&gt;
+
+&lt;div id=&quot;test_no_direct_host_child&quot;&gt;
+  &lt;div id=&quot;host&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot;&gt;&lt;/slot&gt;
+      &lt;slot id=&quot;s2&quot; name=&quot;slot1&quot;&gt;&lt;/slot&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c1&quot; slot=&quot;slot1&quot;&gt;&lt;/div&gt;
+    &lt;div id=&quot;c2&quot; slot=&quot;slot1&quot;&gt;&lt;/div&gt;
+    &lt;div&gt;
+      &lt;div id=&quot;c3&quot; slot=&quot;slot1&quot;&gt;&lt;/div&gt;
+    &lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test_no_direct_host_child);
+  removeWhiteSpaceOnlyTextNodes(n.test_no_direct_host_child);
+
+  assert_equals(n.c1.assignedSlot, n.s1);
+  assert_equals(n.c2.assignedSlot, n.s1);
+  assert_equals(n.c3.assignedSlot, null);
+
+  assert_array_equals(n.s1.assignedNodes(), [n.c1, n.c2]);
+}, 'Slots: No direct host child.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test_default_slot&quot;&gt;
+  &lt;div id=&quot;host&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot;&gt;&lt;/slot&gt;
+      &lt;slot id=&quot;s2&quot;&gt;&lt;/slot&gt;
+      &lt;slot id=&quot;s3&quot;&gt;&lt;/slot&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c1&quot;&gt;&lt;/div&gt;
+    &lt;div id=&quot;c2&quot; slot=&quot;&quot;&gt;&lt;/div&gt;
+    &lt;div id=&quot;c3&quot; slot=&quot;foo&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test_default_slot);
+  removeWhiteSpaceOnlyTextNodes(n.test_default_slot);
+
+  assert_equals(n.c1.assignedSlot, n.s2);
+  assert_equals(n.c2.assignedSlot, n.s2);
+  assert_equals(n.c3.assignedSlot, null);
+}, 'Slots: Default Slot.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test_slot_in_slot&quot;&gt;
+  &lt;div id=&quot;host&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot;&gt;
+        &lt;slot id=&quot;s2&quot; name=&quot;slot2&quot;&gt;&lt;/slot&gt;
+      &lt;/slot&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c1&quot; slot=&quot;slot2&quot;&gt;&lt;/div&gt;
+    &lt;div id=&quot;c2&quot; slot=&quot;slot1&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test_slot_in_slot);
+  removeWhiteSpaceOnlyTextNodes(n.test_slot_in_slot);
+
+  assert_equals(n.c1.assignedSlot, n.s2);
+  assert_equals(n.c2.assignedSlot, n.s1);
+}, 'Slots: Slot in Slot does not matter in assignment.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test_slot_is_assigned_to_slot&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;div id=&quot;host2&quot;&gt;
+        &lt;template data-mode=&quot;open&quot;&gt;
+          &lt;slot id=&quot;s2&quot; name=&quot;slot2&quot;&gt;&lt;/slot&gt;
+        &lt;/template&gt;
+        &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot; slot=&quot;slot2&quot;&gt;&lt;/slot&gt;
+      &lt;/div&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c1&quot; slot=&quot;slot1&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test_slot_is_assigned_to_slot);
+  removeWhiteSpaceOnlyTextNodes(n.test_slot_is_assigned_to_slot);
+
+  assert_equals(n.c1.assignedSlot, n.s1);
+  assert_equals(n.s1.assignedSlot, n.s2);
+
+  assert_array_equals(n.s1.assignedNodes(), [n.c1]);
+  assert_array_equals(n.s2.assignedNodes(), [n.s1]);
+
+  assert_array_equals(n.s1.assignedNodes({ flatten: true }), [n.c1]);
+  assert_array_equals(n.s2.assignedNodes({ flatten: true }), [n.c1]);
+}, 'Slots: Slot is assigned to another slot');
+&lt;/script&gt;
+
+&lt;div id=&quot;test_open_closed&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;div id=&quot;host2&quot;&gt;
+        &lt;template data-mode=&quot;closed&quot;&gt;
+          &lt;slot id=&quot;s2&quot; name=&quot;slot2&quot;&gt;&lt;/slot&gt;
+        &lt;/template&gt;
+        &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot; slot=&quot;slot2&quot;&gt;&lt;/slot&gt;
+      &lt;/div&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c1&quot; slot=&quot;slot1&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test_open_closed);
+  removeWhiteSpaceOnlyTextNodes(n.test_open_closed);
+
+  assert_equals(n.c1.assignedSlot, n.s1);
+  assert_equals(n.s1.assignedSlot, null,
+                'A slot in a closed shadow tree should not be accessed via assignedSlot');
+
+  assert_array_equals(n.s1.assignedNodes(), [n.c1]);
+  assert_array_equals(n.s2.assignedNodes(), [n.s1]);
+
+  assert_array_equals(n.s1.assignedNodes({ flatten: true }), [n.c1]);
+  assert_array_equals(n.s2.assignedNodes({ flatten: true }), [n.c1]);
+}, 'Slots: Open &gt; Closed.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test_closed_closed&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template data-mode=&quot;closed&quot;&gt;
+      &lt;div id=&quot;host2&quot;&gt;
+        &lt;template data-mode=&quot;closed&quot;&gt;
+          &lt;slot id=&quot;s2&quot; name=&quot;slot2&quot;&gt;&lt;/slot&gt;
+        &lt;/template&gt;
+        &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot; slot=&quot;slot2&quot;&gt;&lt;/slot&gt;
+      &lt;/div&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c1&quot; slot=&quot;slot1&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test_closed_closed);
+  removeWhiteSpaceOnlyTextNodes(n.test_closed_closed);
+
+  assert_equals(n.c1.assignedSlot, null,
+                'A slot in a closed shadow tree should not be accessed via assignedSlot');
+  assert_equals(n.s1.assignedSlot, null,
+                'A slot in a closed shadow tree should not be accessed via assignedSlot');
+
+  assert_array_equals(n.s1.assignedNodes(), [n.c1]);
+  assert_array_equals(n.s2.assignedNodes(), [n.s1]);
+
+  assert_array_equals(n.s1.assignedNodes({ flatten: true }), [n.c1]);
+  assert_array_equals(n.s2.assignedNodes({ flatten: true }), [n.c1]);
+}, 'Slots: Closed &gt; Closed.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test_closed_open&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template data-mode=&quot;closed&quot;&gt;
+      &lt;div id=&quot;host2&quot;&gt;
+        &lt;template data-mode=&quot;open&quot;&gt;
+          &lt;slot id=&quot;s2&quot; name=&quot;slot2&quot;&gt;&lt;/slot&gt;
+        &lt;/template&gt;
+        &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot; slot=&quot;slot2&quot;&gt;&lt;/slot&gt;
+      &lt;/div&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c1&quot; slot=&quot;slot1&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test_closed_open);
+  removeWhiteSpaceOnlyTextNodes(n.test_closed_open);
+
+  assert_equals(n.c1.assignedSlot, null,
+                'A slot in a closed shadow tree should not be accessed via assignedSlot');
+  assert_equals(n.s1.assignedSlot, n.s2);
+
+  assert_array_equals(n.s1.assignedNodes(), [n.c1]);
+  assert_array_equals(n.s2.assignedNodes(), [n.s1]);
+
+  assert_array_equals(n.s1.assignedNodes({ flatten: true }), [n.c1]);
+  assert_array_equals(n.s2.assignedNodes({ flatten: true }), [n.c1]);
+}, 'Slots: Closed &gt; Open.');
+&lt;/script&gt;
+
+&lt;div id=&quot;test_complex&quot;&gt;
+  &lt;div id=&quot;host1&quot;&gt;
+    &lt;template data-mode=&quot;open&quot;&gt;
+      &lt;div id=&quot;host2&quot;&gt;
+        &lt;template data-mode=&quot;open&quot;&gt;
+          &lt;slot id=&quot;s5&quot; name=&quot;slot5&quot;&gt;&lt;/slot&gt;
+          &lt;slot id=&quot;s6&quot; name=&quot;slot6&quot;&gt;&lt;/slot&gt;
+          &lt;slot id=&quot;s7&quot;&gt;&lt;/slot&gt;
+          &lt;slot id=&quot;s8&quot; name=&quot;slot8&quot;&gt;&lt;/slot&gt;
+        &lt;/template&gt;
+        &lt;slot id=&quot;s1&quot; name=&quot;slot1&quot; slot=&quot;slot5&quot;&gt;&lt;/slot&gt;
+        &lt;slot id=&quot;s2&quot; name=&quot;slot2&quot; slot=&quot;slot6&quot;&gt;&lt;/slot&gt;
+        &lt;slot id=&quot;s3&quot;&gt;&lt;/slot&gt;
+        &lt;slot id=&quot;s4&quot; name=&quot;slot4&quot; slot=&quot;slot-none&quot;&gt;&lt;/slot&gt;
+        &lt;div id=&quot;c5&quot; slot=&quot;slot5&quot;&gt;&lt;/div&gt;
+        &lt;div id=&quot;c6&quot; slot=&quot;slot6&quot;&gt;&lt;/div&gt;
+        &lt;div id=&quot;c7&quot;&gt;&lt;/div&gt;
+        &lt;div id=&quot;c8&quot; slot=&quot;slot-none&quot;&gt;&lt;/div&gt;
+      &lt;/div&gt;
+    &lt;/template&gt;
+    &lt;div id=&quot;c1&quot; slot=&quot;slot1&quot;&gt;&lt;/div&gt;
+    &lt;div id=&quot;c2&quot; slot=&quot;slot2&quot;&gt;&lt;/div&gt;
+    &lt;div id=&quot;c3&quot;&gt;&lt;/div&gt;
+    &lt;div id=&quot;c4&quot; slot=&quot;slot-none&quot;&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;script&gt;
+test(() =&gt; {
+  let n = createTestTree(test_complex);
+  removeWhiteSpaceOnlyTextNodes(n.test_complex);
+
+  assert_equals(n.c1.assignedSlot, n.s1);
+  assert_equals(n.c2.assignedSlot, n.s2);
+  assert_equals(n.c3.assignedSlot, n.s3);
+  assert_equals(n.c4.assignedSlot, null);
+
+  assert_equals(n.s1.assignedSlot, n.s5);
+  assert_equals(n.s2.assignedSlot, n.s6);
+  assert_equals(n.s3.assignedSlot, n.s7);
+  assert_equals(n.s4.assignedSlot, null);
+
+  assert_equals(n.c5.assignedSlot, n.s5);
+  assert_equals(n.c6.assignedSlot, n.s6);
+  assert_equals(n.c7.assignedSlot, n.s7);
+  assert_equals(n.c8.assignedSlot, null);
+
+  assert_array_equals(n.s1.assignedNodes(), [n.c1]);
+  assert_array_equals(n.s2.assignedNodes(), [n.c2]);
+  assert_array_equals(n.s3.assignedNodes(), [n.c3]);
+  assert_array_equals(n.s4.assignedNodes(), []);
+  assert_array_equals(n.s5.assignedNodes(), [n.s1, n.c5]);
+  assert_array_equals(n.s6.assignedNodes(), [n.s2, n.c6]);
+  assert_array_equals(n.s7.assignedNodes(), [n.s3, n.c7]);
+  assert_array_equals(n.s8.assignedNodes(), []);
+
+  assert_array_equals(n.s1.assignedNodes({ flatten: true }), [n.c1]);
+  assert_array_equals(n.s2.assignedNodes({ flatten: true }), [n.c2]);
+  assert_array_equals(n.s3.assignedNodes({ flatten: true }), [n.c3]);
+  assert_array_equals(n.s4.assignedNodes({ flatten: true }), []);
+  assert_array_equals(n.s5.assignedNodes({ flatten: true }), [n.c1, n.c5]);
+  assert_array_equals(n.s6.assignedNodes({ flatten: true }), [n.c2, n.c6]);
+  assert_array_equals(n.s7.assignedNodes({ flatten: true }), [n.c3, n.c7]);
+  assert_array_equals(n.s8.assignedNodes({ flatten: true }), []);
+}, 'Slots: Complex case: Basi line.');
+
+test(() =&gt; {
+  let n = createTestTree(test_complex);
+  removeWhiteSpaceOnlyTextNodes(n.test_complex);
+
+  let d1 = document.createElement('div');
+  d1.setAttribute('slot', 'slot1');
+  n.host1.appendChild(d1);
+
+  assert_array_equals(n.s1.assignedNodes(), [n.c1, d1]);
+  assert_equals(d1.assignedSlot, n.s1);
+
+  assert_array_equals(n.s5.assignedNodes({ flatten: true }), [n.c1, d1, n.c5]);
+}, 'Slots: Mutation: appendChild.');
+
+test(() =&gt; {
+  let n = createTestTree(test_complex);
+  removeWhiteSpaceOnlyTextNodes(n.test_complex);
+
+  n.c1.setAttribute('slot', 'slot-none');
+
+  assert_array_equals(n.s1.assignedNodes(), []);
+  assert_equals(n.c1.assignedSlot, null);
+
+  assert_array_equals(n.s5.assignedNodes({ flatten: true }), [n.c5]);
+}, 'Slots: Mutation: Change slot= attribute 1.');
+
+test(() =&gt; {
+  let n = createTestTree(test_complex);
+  removeWhiteSpaceOnlyTextNodes(n.test_complex);
+
+  n.c1.setAttribute('slot', 'slot2');
+
+  assert_array_equals(n.s1.assignedNodes(), []);
+  assert_array_equals(n.s2.assignedNodes(), [n.c1, n.c2]);
+  assert_equals(n.c1.assignedSlot, n.s2);
+
+  assert_array_equals(n.s5.assignedNodes({ flatten: true }), [n.c5]);
+  assert_array_equals(n.s6.assignedNodes({ flatten: true }), [n.c1, n.c2, n.c6]);
+}, 'Slots: Mutation: Change slot= attribute 2.');
+
+test(() =&gt; {
+  let n = createTestTree(test_complex);
+  removeWhiteSpaceOnlyTextNodes(n.test_complex);
+
+  n.c4.setAttribute('slot', 'slot1');
+
+  assert_array_equals(n.s1.assignedNodes(), [n.c1, n.c4]);
+  assert_equals(n.c4.assignedSlot, n.s1);
+
+  assert_array_equals(n.s5.assignedNodes({ flatten: true }), [n.c1, n.c4, n.c5]);
+}, 'Slots: Mutation: Change slot= attribute 3.');
+
+test(() =&gt; {
+  let n = createTestTree(test_complex);
+  removeWhiteSpaceOnlyTextNodes(n.test_complex);
+
+  n.c1.remove();
+
+  assert_array_equals(n.s1.assignedNodes(), []);
+  assert_equals(n.c1.assignedSlot, null);
+
+  assert_array_equals(n.s5.assignedNodes({ flatten: true }), [n.c5]);
+}, 'Slots: Mutation: Remove a child.');
+
+test(() =&gt; {
+  let n = createTestTree(test_complex);
+  removeWhiteSpaceOnlyTextNodes(n.test_complex);
+
+  let slot = document.createElement('slot');
+  slot.setAttribute('name', 'slot1');
+  n.host2.appendChild(slot);
+
+  assert_array_equals(slot.assignedNodes(), []);
+}, 'Slots: Mutation: Add a slot: after.');
+
+test(() =&gt; {
+  let n = createTestTree(test_complex);
+  removeWhiteSpaceOnlyTextNodes(n.test_complex);
+
+  let slot = document.createElement('slot');
+  slot.setAttribute('name', 'slot1');
+  n.host2.insertBefore(slot, n.s1);
+
+  assert_array_equals(slot.assignedNodes(), [n.c1]);
+  assert_equals(n.c1.assignedSlot, slot);
+
+  assert_array_equals(n.s7.assignedNodes(), [slot, n.s3, n.c7]);
+  assert_array_equals(n.s7.assignedNodes({ flatten: true }), [n.c1, n.c3, n.c7]);
+}, 'Slots: Mutation: Add a slot: before.');
+
+test(() =&gt; {
+  let n = createTestTree(test_complex);
+  removeWhiteSpaceOnlyTextNodes(n.test_complex);
+
+  n.s1.remove();
+
+  assert_array_equals(n.s1.assignedNodes(), []);
+  assert_equals(n.c1.assignedSlot, null);
+
+  assert_array_equals(n.s5.assignedNodes(), [n.c5]);
+  assert_array_equals(n.s5.assignedNodes({ flatten: true }), [n.c5]);
+}, 'Slots: Mutation: Remove a slot.');
+
+test(() =&gt; {
+  let n = createTestTree(test_complex);
+  removeWhiteSpaceOnlyTextNodes(n.test_complex);
+
+  n.s1.setAttribute('name', 'slot2');
+
+  assert_array_equals(n.s1.assignedNodes(), [n.c2]);
+  assert_equals(n.c1.assignedSlot, null);
+  assert_equals(n.c2.assignedSlot, n.s1);
+
+  assert_array_equals(n.s5.assignedNodes(), [n.s1, n.c5]);
+  assert_array_equals(n.s5.assignedNodes({ flatten: true }), [n.c2, n.c5]);
+}, 'Slots: Mutation: Change slot name= attribute.');
+
+test(() =&gt; {
+  let n = createTestTree(test_complex);
+  removeWhiteSpaceOnlyTextNodes(n.test_complex);
+
+  n.s1.setAttribute('slot', 'slot6');
+
+  assert_array_equals(n.s1.assignedNodes(), [n.c1]);
+
+  assert_array_equals(n.s5.assignedNodes(), [n.c5]);
+  assert_array_equals(n.s6.assignedNodes(), [n.s1, n.s2, n.c6]);
+  assert_array_equals(n.s6.assignedNodes({ flatten: true }), [n.c1, n.c2, n.c6]);
+}, 'Slots: Mutation: Change slot slot= attribute.');
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomw3cimportlog"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/w3c-import.log (0 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/w3c-import.log                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/w3c-import.log        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+The tests in this directory were imported from the W3C repository.
+Do NOT modify these tests directly in WebKit.
+Instead, create a pull request on the W3C CSS or WPT github:
+        https://github.com/w3c/csswg-test
+        https://github.com/w3c/web-platform-tests
+
+Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
+
+Do NOT modify or remove this file.
+
+------------------------------------------------------------------------
+Properties requiring vendor prefixes:
+None
+Property values requiring vendor prefixes:
+None
+------------------------------------------------------------------------
+List of files:
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-adoptNode.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-currentScript.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Document-prototype-importNode.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-attachShadow.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-shadowRoot-attribute.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Extensions-to-Event-Interface.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/HTMLSlotElement-interface.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Node-prototype-cloneNode.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/OWNERS
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/ShadowRoot-interface.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Slotable-interface.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path-with-related-target.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed-path.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-composed.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-shadow-tree.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-inside-slotted-node.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/event-with-related-target.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/scroll-to-the-fragment-in-shadow-tree.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange-event.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots-fallback.html
+/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slots.html
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/Source/WebCore/ChangeLog        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-09-27  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Import w3c shadow DOM tests and fix one assertion
+        https://bugs.webkit.org/show_bug.cgi?id=162629
+
+        Reviewed by Chris Dumez.
+
+        The assertion failure was caused by RelatedNodeRetargeter's constructor mixing up the ancestor tree scopes
+        for the target and the related target. Fixed the bug by reversing the two.
+
+        Tests: imported/w3c/web-platform-tests/shadow-dom/event-composed-path-with-related-target.html
+
+        * dom/EventPath.cpp:
+        (WebCore::RelatedNodeRetargeter::RelatedNodeRetargeter): i and m_ancestorTreeScopes are for the related target
+        and j and targetTreeScopeAncestors are for the target.
+
</ins><span class="cx"> 2016-09-27  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         It should be possible to dispatch events on documents that do not have a browsing context
</span></span></pre></div>
<a id="trunkSourceWebCoredomEventPathcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/EventPath.cpp (206462 => 206463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/EventPath.cpp        2016-09-27 20:55:20 UTC (rev 206462)
+++ trunk/Source/WebCore/dom/EventPath.cpp        2016-09-27 21:04:15 UTC (rev 206463)
</span><span class="lines">@@ -288,8 +288,8 @@
</span><span class="cx"> 
</span><span class="cx">     bool lowestCommonAncestorIsDocumentScope = i + 1 == m_ancestorTreeScopes.size();
</span><span class="cx">     if (lowestCommonAncestorIsDocumentScope &amp;&amp; !relatedNode.inDocument() &amp;&amp; !target.inDocument()) {
</span><del>-        Node&amp; targetAncestorInDocumentScope = i ? *downcast&lt;ShadowRoot&gt;(m_ancestorTreeScopes[i - 1]-&gt;rootNode()).shadowHost() : target;
-        Node&amp; relatedNodeAncestorInDocumentScope = j ? *downcast&lt;ShadowRoot&gt;(targetTreeScopeAncestors[j - 1]-&gt;rootNode()).shadowHost() : relatedNode;
</del><ins>+        Node&amp; relatedNodeAncestorInDocumentScope = i ? *downcast&lt;ShadowRoot&gt;(m_ancestorTreeScopes[i - 1]-&gt;rootNode()).shadowHost() : relatedNode;
+        Node&amp; targetAncestorInDocumentScope = j ? *downcast&lt;ShadowRoot&gt;(targetTreeScopeAncestors[j - 1]-&gt;rootNode()).shadowHost() : target;
</ins><span class="cx">         if (&amp;targetAncestorInDocumentScope.rootNode() != &amp;relatedNodeAncestorInDocumentScope.rootNode()) {
</span><span class="cx">             m_hasDifferentTreeRoot = true;
</span><span class="cx">             m_retargetedRelatedNode = moveOutOfAllShadowRoots(relatedNode);
</span></span></pre>
</div>
</div>

</body>
</html>