<!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>[208878] 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/208878">208878</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2016-11-17 21:30:24 -0800 (Thu, 17 Nov 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add an experimental API to find elements across shadow boundaries
https://bugs.webkit.org/show_bug.cgi?id=164851
&lt;rdar://problem/28220092&gt;

Reviewed by Sam Weinig.

Source/JavaScriptCore:

* runtime/CommonIdentifiers.h:

Source/WebCore:

Add window.collectMatchingElementsInFlatTree(Node node, DOMString selectors)
as an experimental API which finds a list of elements that matches the given CSS selectors
and expose it to a JSWorld on which WKBundleScriptWorldMakeAllShadowRootsOpen was called.

No new tests. More test cases are added to WebKit2.InjectedBundleMakeAllShadowRootsOpen.

* bindings/scripts/CodeGeneratorJS.pm:
(NeedsRuntimeCheck): Added. Abstracts checks for EnabledAtRuntime and EnabledForWorld.
(OperationShouldBeOnInstance):
(GeneratePropertiesHashTable):
(GetRuntimeEnableFunctionName): Use worldForDOMObject(this).condition() for EnabledForWorld.
Also split the line for EnabledAtRuntime and EnabledAtRuntime for a better readability.
(GenerateImplementation):
(addIterableProperties):
* bindings/scripts/IDLAttributes.txt:
* bindings/scripts/preprocess-idls.pl:
(GenerateConstructorAttribute):
* bindings/scripts/test/JS/JSTestGlobalObject.cpp:
(WebCore::JSTestGlobalObject::finishCreation):
(WebCore::jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorld):
(WebCore::jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldCaller):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::JSTestObjPrototype::finishCreation):
(WebCore::jsTestObjPrototypeFunctionWorldSpecificMethod):
(WebCore::jsTestObjPrototypeFunctionWorldSpecificMethodCaller):
* bindings/scripts/test/TestGlobalObject.idl: Added a test case.
* bindings/scripts/test/TestObj.idl: Ditto.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::collectMatchingElementsInFlatTree): Added. Implements the feature by
calling SelectorQuery's matches on a node yielded by ComposedTreeIterator.
* page/DOMWindow.h:
* page/DOMWindow.idl:

Tools:

Added test cases for window.collectMatchingElementsInFlatTree to WebKit2.InjectedBundleMakeAllShadowRootOpen.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRoot*s*Open_Bundle.cpp: Renamed
from InjectedBundleMakeAllShadowRootOpen_Bundle.cpp.
(TestWebKitAPI::InjectedBundleMakeAllShadowRootOpenTest::initialize): Added test cases for
window.collectMatchingElementsInFlatTree by calling alert() many times.
* TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootsOpen.cpp:
(TestWebKitAPI::runJavaScriptAlert): Added expectations for multiple test cases. Each test case
finishes with a call to alert, and moves testNumber forward.
(TestWebKitAPI::TEST): Use the newly added closed-shadow-tree-test.html
* TestWebKitAPI/Tests/WebKit2/closed-shadow-tree-test.html: Added. Creates a shadow tree with slots
and tests that window.collectMatchingElementsInFlatTree is not present when
an event named &quot;testnormalworld&quot; is dispatched by the injected bundle.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCommonIdentifiersh">trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsIDLAttributestxt">trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptspreprocessidlspl">trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestGlobalObjectcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestTestGlobalObjectidl">trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestTestObjidl">trunk/Source/WebCore/bindings/scripts/test/TestObj.idl</a></li>
<li><a href="#trunkSourceWebCorepageDOMWindowcpp">trunk/Source/WebCore/page/DOMWindow.cpp</a></li>
<li><a href="#trunkSourceWebCorepageDOMWindowh">trunk/Source/WebCore/page/DOMWindow.h</a></li>
<li><a href="#trunkSourceWebCorepageDOMWindowidl">trunk/Source/WebCore/page/DOMWindow.idl</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2InjectedBundleMakeAllShadowRootsOpencpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootsOpen.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2InjectedBundleMakeAllShadowRootsOpen_Bundlecpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2closedshadowtreetesthtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2/closed-shadow-tree-test.html</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2InjectedBundleMakeAllShadowRootOpen_Bundlecpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootOpen_Bundle.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (208877 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-11-18 05:11:18 UTC (rev 208877)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-11-17  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Add an experimental API to find elements across shadow boundaries
+        https://bugs.webkit.org/show_bug.cgi?id=164851
+        &lt;rdar://problem/28220092&gt;
+
+        Reviewed by Sam Weinig.
+
+        * runtime/CommonIdentifiers.h:
+
</ins><span class="cx"> 2016-11-17  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [JSC] Drop arguments.caller
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCommonIdentifiersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h (208877 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h        2016-11-18 05:11:18 UTC (rev 208877)
+++ trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -260,6 +260,7 @@
</span><span class="cx">     macro(value) \
</span><span class="cx">     macro(valueOf) \
</span><span class="cx">     macro(webkit) \
</span><ins>+    macro(collectMatchingElementsInFlatTree) \
</ins><span class="cx">     macro(webkitIDBCursor) \
</span><span class="cx">     macro(webkitIDBDatabase) \
</span><span class="cx">     macro(webkitIDBFactory) \
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208877 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-18 05:11:18 UTC (rev 208877)
+++ trunk/Source/WebCore/ChangeLog        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2016-11-17  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Add an experimental API to find elements across shadow boundaries
+        https://bugs.webkit.org/show_bug.cgi?id=164851
+        &lt;rdar://problem/28220092&gt;
+
+        Reviewed by Sam Weinig.
+
+        Add window.collectMatchingElementsInFlatTree(Node node, DOMString selectors)
+        as an experimental API which finds a list of elements that matches the given CSS selectors
+        and expose it to a JSWorld on which WKBundleScriptWorldMakeAllShadowRootsOpen was called.
+
+        No new tests. More test cases are added to WebKit2.InjectedBundleMakeAllShadowRootsOpen.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (NeedsRuntimeCheck): Added. Abstracts checks for EnabledAtRuntime and EnabledForWorld.
+        (OperationShouldBeOnInstance):
+        (GeneratePropertiesHashTable):
+        (GetRuntimeEnableFunctionName): Use worldForDOMObject(this).condition() for EnabledForWorld.
+        Also split the line for EnabledAtRuntime and EnabledAtRuntime for a better readability.
+        (GenerateImplementation):
+        (addIterableProperties):
+        * bindings/scripts/IDLAttributes.txt:
+        * bindings/scripts/preprocess-idls.pl:
+        (GenerateConstructorAttribute):
+        * bindings/scripts/test/JS/JSTestGlobalObject.cpp:
+        (WebCore::JSTestGlobalObject::finishCreation):
+        (WebCore::jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorld):
+        (WebCore::jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldCaller):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::JSTestObjPrototype::finishCreation):
+        (WebCore::jsTestObjPrototypeFunctionWorldSpecificMethod):
+        (WebCore::jsTestObjPrototypeFunctionWorldSpecificMethodCaller):
+        * bindings/scripts/test/TestGlobalObject.idl: Added a test case.
+        * bindings/scripts/test/TestObj.idl: Ditto.
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::collectMatchingElementsInFlatTree): Added. Implements the feature by
+        calling SelectorQuery's matches on a node yielded by ComposedTreeIterator.
+        * page/DOMWindow.h:
+        * page/DOMWindow.idl:
+
</ins><span class="cx"> 2016-11-17  Sam Weinig  &lt;sam@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [WebIDL] Add support for ByteString
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (208877 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-11-18 05:11:18 UTC (rev 208877)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -693,6 +693,13 @@
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+sub NeedsRuntimeCheck
+{
+    my $interface = shift;
+    return $interface-&gt;extendedAttributes-&gt;{EnabledAtRuntime}
+        || $interface-&gt;extendedAttributes-&gt;{EnabledForWorld};
+}
+
</ins><span class="cx"> # https://heycam.github.io/webidl/#es-operations
</span><span class="cx"> sub OperationShouldBeOnInstance
</span><span class="cx"> {
</span><span class="lines">@@ -702,7 +709,7 @@
</span><span class="cx">     return 1 if IsGlobalOrPrimaryGlobalInterface($interface);
</span><span class="cx"> 
</span><span class="cx">     # FIXME: The bindings generator does not support putting runtime-enabled operations on the instance yet (except for global objects).
</span><del>-    return 0 if $function-&gt;extendedAttributes-&gt;{EnabledAtRuntime};
</del><ins>+    return 0 if NeedsRuntimeCheck($function);
</ins><span class="cx"> 
</span><span class="cx">     # [Unforgeable] operations should be on the instance. https://heycam.github.io/webidl/#Unforgeable
</span><span class="cx">     return 1 if IsUnforgeable($interface, $function);
</span><span class="lines">@@ -1875,7 +1882,7 @@
</span><span class="cx">         next if AttributeShouldBeOnInstance($interface, $attribute) != $isInstance;
</span><span class="cx"> 
</span><span class="cx">         # Global objects add RuntimeEnabled attributes after creation so do not add them to the static table.
</span><del>-        if ($isInstance &amp;&amp; $attribute-&gt;extendedAttributes-&gt;{EnabledAtRuntime}) {
</del><ins>+        if ($isInstance &amp;&amp; NeedsRuntimeCheck($attribute)) {
</ins><span class="cx">             $propertyCount -= 1;
</span><span class="cx">             next;
</span><span class="cx">         }
</span><span class="lines">@@ -1904,7 +1911,7 @@
</span><span class="cx">         my $conditional = $attribute-&gt;extendedAttributes-&gt;{Conditional};
</span><span class="cx">         $conditionals-&gt;{$name} = $conditional if $conditional;
</span><span class="cx"> 
</span><del>-        if ($attribute-&gt;extendedAttributes-&gt;{EnabledAtRuntime}) {
</del><ins>+        if (NeedsRuntimeCheck($attribute)) {
</ins><span class="cx">             push(@$runtimeEnabledAttributes, $attribute);
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -1920,7 +1927,7 @@
</span><span class="cx">         next if $function-&gt;name eq &quot;[Symbol.Iterator]&quot;;
</span><span class="cx"> 
</span><span class="cx">         # Global objects add RuntimeEnabled operations after creation so do not add them to the static table.
</span><del>-        if ($isInstance &amp;&amp; $function-&gt;extendedAttributes-&gt;{EnabledAtRuntime}) {
</del><ins>+        if ($isInstance &amp;&amp; NeedsRuntimeCheck($function)) {
</ins><span class="cx">             $propertyCount -= 1;
</span><span class="cx">             next;
</span><span class="cx">         }
</span><span class="lines">@@ -1947,7 +1954,7 @@
</span><span class="cx">         my $conditional = getConditionalForFunctionConsideringOverloads($function);
</span><span class="cx">         $conditionals-&gt;{$name} = $conditional if $conditional;
</span><span class="cx"> 
</span><del>-        if ($function-&gt;extendedAttributes-&gt;{EnabledAtRuntime}) {
</del><ins>+        if (NeedsRuntimeCheck($function)) {
</ins><span class="cx">             push(@$runtimeEnabledFunctions, $function);
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -2511,8 +2518,16 @@
</span><span class="cx"> {
</span><span class="cx">     my $context = shift;
</span><span class="cx"> 
</span><ins>+    AddToImplIncludes(&quot;RuntimeEnabledFeatures.h&quot;);
+    
+    if ($context-&gt;extendedAttributes-&gt;{EnabledForWorld}) {
+        return &quot;worldForDOMObject(this).&quot; . ToMethodName($context-&gt;extendedAttributes-&gt;{EnabledForWorld});
+    }
+
</ins><span class="cx">     # If a parameter is given (e.g. &quot;EnabledAtRuntime=FeatureName&quot;) return the RuntimeEnabledFeatures::sharedFeatures().{FeatureName}Enabled() method.
</span><del>-    return &quot;RuntimeEnabledFeatures::sharedFeatures().&quot; . ToMethodName($context-&gt;extendedAttributes-&gt;{EnabledAtRuntime}) . &quot;Enabled&quot; if ($context-&gt;extendedAttributes-&gt;{EnabledAtRuntime} &amp;&amp; $context-&gt;extendedAttributes-&gt;{EnabledAtRuntime} ne &quot;VALUE_IS_MISSING&quot;);
</del><ins>+    if ($context-&gt;extendedAttributes-&gt;{EnabledAtRuntime} &amp;&amp; $context-&gt;extendedAttributes-&gt;{EnabledAtRuntime} ne &quot;VALUE_IS_MISSING&quot;) {
+        return &quot;RuntimeEnabledFeatures::sharedFeatures().&quot; . ToMethodName($context-&gt;extendedAttributes-&gt;{EnabledAtRuntime}) . &quot;Enabled&quot;;
+    }
</ins><span class="cx"> 
</span><span class="cx">     # Otherwise return a function named RuntimeEnabledFeatures::sharedFeatures().{methodName}Enabled().
</span><span class="cx">     return &quot;RuntimeEnabledFeatures::sharedFeatures().&quot; . ToMethodName($context-&gt;name) . &quot;Enabled&quot;;
</span><span class="lines">@@ -3000,10 +3015,9 @@
</span><span class="cx"> 
</span><span class="cx">     # Support for RuntimeEnabled attributes on instances.
</span><span class="cx">     foreach my $attribute (@{$interface-&gt;attributes}) {
</span><del>-        next unless $attribute-&gt;extendedAttributes-&gt;{EnabledAtRuntime};
</del><ins>+        next unless NeedsRuntimeCheck($attribute);
</ins><span class="cx">         next unless AttributeShouldBeOnInstance($interface, $attribute);
</span><span class="cx"> 
</span><del>-        AddToImplIncludes(&quot;RuntimeEnabledFeatures.h&quot;);
</del><span class="cx">         my $conditionalString = $codeGenerator-&gt;GenerateConditionalString($attribute);
</span><span class="cx">         push(@implContent, &quot;#if ${conditionalString}\n&quot;) if $conditionalString;
</span><span class="cx">         my $enable_function = GetRuntimeEnableFunctionName($attribute);
</span><span class="lines">@@ -3035,11 +3049,10 @@
</span><span class="cx"> 
</span><span class="cx">     # Support for RuntimeEnabled operations on instances.
</span><span class="cx">     foreach my $function (@{$interface-&gt;functions}) {
</span><del>-        next unless $function-&gt;extendedAttributes-&gt;{EnabledAtRuntime};
</del><ins>+        next unless NeedsRuntimeCheck($function);
</ins><span class="cx">         next unless OperationShouldBeOnInstance($interface, $function);
</span><span class="cx">         next if $function-&gt;{overloadIndex} &amp;&amp; $function-&gt;{overloadIndex} &gt; 1;
</span><span class="cx"> 
</span><del>-        AddToImplIncludes(&quot;RuntimeEnabledFeatures.h&quot;);
</del><span class="cx">         my $conditionalString = $codeGenerator-&gt;GenerateConditionalString($function);
</span><span class="cx">         push(@implContent, &quot;#if ${conditionalString}\n&quot;) if $conditionalString;
</span><span class="cx">         my $enable_function = GetRuntimeEnableFunctionName($function);
</span><span class="lines">@@ -5027,8 +5040,7 @@
</span><span class="cx">     my $interface = shift;
</span><span class="cx">     my $className = shift;
</span><span class="cx"> 
</span><del>-    if ($interface-&gt;iterable-&gt;extendedAttributes-&gt;{EnabledAtRuntime}) {
-        AddToImplIncludes(&quot;RuntimeEnabledFeatures.h&quot;);
</del><ins>+    if (NeedsRuntimeCheck($interface-&gt;iterable)) {
</ins><span class="cx">         my $enable_function = GetRuntimeEnableFunctionName($interface-&gt;iterable);
</span><span class="cx">         push(@implContent, &quot;    if (${enable_function}())\n    &quot;);
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsIDLAttributestxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt (208877 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt        2016-11-18 05:11:18 UTC (rev 208877)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -59,6 +59,7 @@
</span><span class="cx"> DocumentEventHandler
</span><span class="cx"> EnabledAtRuntime=*
</span><span class="cx"> EnabledBySetting=*
</span><ins>+EnabledForWorld=*
</ins><span class="cx"> EnforceRange
</span><span class="cx"> ExportMacro=WEBCORE_EXPORT|WEBCORE_TESTSUPPORT_EXPORT
</span><span class="cx"> ExportToWrappedFunction
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptspreprocessidlspl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl (208877 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl        2016-11-18 05:11:18 UTC (rev 208877)
+++ trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -246,7 +246,7 @@
</span><span class="cx">     my $code = &quot;    &quot;;
</span><span class="cx">     my @extendedAttributesList;
</span><span class="cx">     foreach my $attributeName (sort keys %{$extendedAttributes}) {
</span><del>-      next unless ($attributeName eq &quot;Conditional&quot; || $attributeName eq &quot;EnabledAtRuntime&quot; || $attributeName eq &quot;EnabledBySetting&quot; || $attributeName eq &quot;PrivateIdentifier&quot; || $attributeName eq &quot;PublicIdentifier&quot;);
</del><ins>+      next unless ($attributeName eq &quot;Conditional&quot; || $attributeName eq &quot;EnabledAtRuntime&quot; || $attributeName eq &quot;EnabledForWorld&quot; || $attributeName eq &quot;EnabledBySetting&quot; || $attributeName eq &quot;PrivateIdentifier&quot; || $attributeName eq &quot;PublicIdentifier&quot;);
</ins><span class="cx">       my $extendedAttribute = $attributeName;
</span><span class="cx">       $extendedAttribute .= &quot;=&quot; . $extendedAttributes-&gt;{$attributeName} unless $extendedAttributes-&gt;{$attributeName} eq &quot;VALUE_IS_MISSING&quot;;
</span><span class="cx">       push(@extendedAttributesList, $extendedAttribute);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestGlobalObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp (208877 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp        2016-11-18 05:11:18 UTC (rev 208877)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx"> #if ENABLE(TEST_FEATURE)
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation(JSC::ExecState*);
</span><span class="cx"> #endif
</span><ins>+JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorld(JSC::ExecState*);
</ins><span class="cx"> #if ENABLE(TEST_FEATURE)
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionTestPrivateFunction(JSC::ExecState*);
</span><span class="cx"> #endif
</span><span class="lines">@@ -159,6 +160,8 @@
</span><span class="cx">     if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())
</span><span class="cx">         putDirectNativeFunction(vm, this, vm.propertyNames-&gt;enabledAtRuntimeOperation, 1, jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation, NoIntrinsic, attributesForStructure(JSC::Function));
</span><span class="cx"> #endif
</span><ins>+    if (worldForDOMObject(this).specificWorld())
+        putDirectNativeFunction(vm, this, vm.propertyNames-&gt;enabledInSpecificWorld, 1, jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorld, NoIntrinsic, attributesForStructure(JSC::Function));
</ins><span class="cx"> #if ENABLE(TEST_FEATURE)
</span><span class="cx">     if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())
</span><span class="cx">         putDirectNativeFunction(vm, this, static_cast&lt;JSVMClientData*&gt;(vm.clientData)-&gt;builtinNames().testPrivateFunctionPrivateName(), 0, jsTestGlobalObjectInstanceFunctionTestPrivateFunction, NoIntrinsic, attributesForStructure(JSC::Function));
</span><span class="lines">@@ -451,6 +454,26 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+static inline JSC::EncodedJSValue jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldCaller(JSC::ExecState*, JSTestGlobalObject*, JSC::ThrowScope&amp;);
+
+EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorld(ExecState* state)
+{
+    return BindingCaller&lt;JSTestGlobalObject&gt;::callOperation&lt;jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldCaller&gt;(state, &quot;enabledInSpecificWorld&quot;);
+}
+
+static inline JSC::EncodedJSValue jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldCaller(JSC::ExecState* state, JSTestGlobalObject* castedThis, JSC::ThrowScope&amp; throwScope)
+{
+    UNUSED_PARAM(state);
+    UNUSED_PARAM(throwScope);
+    auto&amp; impl = castedThis-&gt;wrapped();
+    if (UNLIKELY(state-&gt;argumentCount() &lt; 1))
+        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
+    auto testParam = convert&lt;IDLLong&gt;(*state, state-&gt;uncheckedArgument(0), IntegerConversionConfiguration::Normal);
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+    impl.enabledInSpecificWorld(WTFMove(testParam));
+    return JSValue::encode(jsUndefined());
+}
+
</ins><span class="cx"> #if ENABLE(TEST_FEATURE)
</span><span class="cx"> static inline JSC::EncodedJSValue jsTestGlobalObjectInstanceFunctionTestPrivateFunctionCaller(JSC::ExecState*, JSTestGlobalObject*, JSC::ThrowScope&amp;);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (208877 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp        2016-11-18 05:11:18 UTC (rev 208877)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -938,6 +938,7 @@
</span><span class="cx"> #if ENABLE(TEST_FEATURE)
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionEnabledAtRuntimeOperation(JSC::ExecState*);
</span><span class="cx"> #endif
</span><ins>+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWorldSpecificMethod(JSC::ExecState*);
</ins><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethod(JSC::ExecState*);
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethodWithArgs(JSC::ExecState*);
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionByteMethod(JSC::ExecState*);
</span><span class="lines">@@ -1545,6 +1546,7 @@
</span><span class="cx"> #else
</span><span class="cx">     { 0, 0, NoIntrinsic, { 0, 0 } },
</span><span class="cx"> #endif
</span><ins>+    { &quot;worldSpecificMethod&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionWorldSpecificMethod), (intptr_t) (1) } },
</ins><span class="cx">     { &quot;voidMethod&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionVoidMethod), (intptr_t) (0) } },
</span><span class="cx">     { &quot;voidMethodWithArgs&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionVoidMethodWithArgs), (intptr_t) (3) } },
</span><span class="cx">     { &quot;byteMethod&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionByteMethod), (intptr_t) (0) } },
</span><span class="lines">@@ -1726,6 +1728,11 @@
</span><span class="cx">         JSObject::deleteProperty(this, globalObject()-&gt;globalExec(), propertyName);
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><ins>+    if (!worldForDOMObject(this).someWorld()) {
+        Identifier propertyName = Identifier::fromString(&amp;vm, reinterpret_cast&lt;const LChar*&gt;(&quot;worldSpecificMethod&quot;), strlen(&quot;worldSpecificMethod&quot;));
+        VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
+        JSObject::deleteProperty(this, globalObject()-&gt;globalExec(), propertyName);
+    }
</ins><span class="cx"> #if ENABLE(TEST_FEATURE)
</span><span class="cx">     if (!RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled()) {
</span><span class="cx">         Identifier propertyName = Identifier::fromString(&amp;vm, reinterpret_cast&lt;const LChar*&gt;(&quot;enabledAtRuntimeAttribute&quot;), strlen(&quot;enabledAtRuntimeAttribute&quot;));
</span><span class="lines">@@ -4711,6 +4718,26 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionWorldSpecificMethodCaller(JSC::ExecState*, JSTestObj*, JSC::ThrowScope&amp;);
+
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWorldSpecificMethod(ExecState* state)
+{
+    return BindingCaller&lt;JSTestObj&gt;::callOperation&lt;jsTestObjPrototypeFunctionWorldSpecificMethodCaller&gt;(state, &quot;worldSpecificMethod&quot;);
+}
+
+static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionWorldSpecificMethodCaller(JSC::ExecState* state, JSTestObj* castedThis, JSC::ThrowScope&amp; throwScope)
+{
+    UNUSED_PARAM(state);
+    UNUSED_PARAM(throwScope);
+    auto&amp; impl = castedThis-&gt;wrapped();
+    if (UNLIKELY(state-&gt;argumentCount() &lt; 1))
+        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
+    auto testParam = convert&lt;IDLLong&gt;(*state, state-&gt;uncheckedArgument(0), IntegerConversionConfiguration::Normal);
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+    impl.worldSpecificMethod(WTFMove(testParam));
+    return JSValue::encode(jsUndefined());
+}
+
</ins><span class="cx"> static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionVoidMethodCaller(JSC::ExecState*, JSTestObj*, JSC::ThrowScope&amp;);
</span><span class="cx"> 
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethod(ExecState* state)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestTestGlobalObjectidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl (208877 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl        2016-11-18 05:11:18 UTC (rev 208877)
+++ trunk/Source/WebCore/bindings/scripts/test/TestGlobalObject.idl        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -35,6 +35,8 @@
</span><span class="cx">     [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void enabledAtRuntimeOperation(DOMString testParam);
</span><span class="cx">     [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void enabledAtRuntimeOperation(long testParam);
</span><span class="cx"> 
</span><ins>+    [EnabledForWorld=specificWorld] void enabledInSpecificWorld(long testParam);
+
</ins><span class="cx">     [PrivateIdentifier, Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void testPrivateFunction();
</span><span class="cx">     [JSBuiltin, Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void testJSBuiltinFunction();
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestTestObjidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (208877 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl        2016-11-18 05:11:18 UTC (rev 208877)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -109,6 +109,8 @@
</span><span class="cx">     [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void enabledAtRuntimeOperation(DOMString testParam);
</span><span class="cx">     [Conditional=TEST_FEATURE, EnabledAtRuntime=TestFeature] void enabledAtRuntimeOperation(long testParam);
</span><span class="cx"> 
</span><ins>+    [EnabledForWorld=someWorld] void worldSpecificMethod(long testParam);
+
</ins><span class="cx">     // TypedArray attribute
</span><span class="cx">     attribute Float32Array typedArrayAttr;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMWindowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMWindow.cpp (208877 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DOMWindow.cpp        2016-11-18 05:11:18 UTC (rev 208877)
+++ trunk/Source/WebCore/page/DOMWindow.cpp        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include &quot;CSSRuleList.h&quot;
</span><span class="cx"> #include &quot;Chrome.h&quot;
</span><span class="cx"> #include &quot;ChromeClient.h&quot;
</span><ins>+#include &quot;ComposedTreeIterator.h&quot;
</ins><span class="cx"> #include &quot;ContentExtensionActions.h&quot;
</span><span class="cx"> #include &quot;ContentExtensionRule.h&quot;
</span><span class="cx"> #include &quot;Crypto.h&quot;
</span><span class="lines">@@ -89,8 +90,10 @@
</span><span class="cx"> #include &quot;SecurityOrigin.h&quot;
</span><span class="cx"> #include &quot;SecurityOriginData.h&quot;
</span><span class="cx"> #include &quot;SecurityPolicy.h&quot;
</span><ins>+#include &quot;SelectorQuery.h&quot;
</ins><span class="cx"> #include &quot;SerializedScriptValue.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><ins>+#include &quot;StaticNodeList.h&quot;
</ins><span class="cx"> #include &quot;Storage.h&quot;
</span><span class="cx"> #include &quot;StorageArea.h&quot;
</span><span class="cx"> #include &quot;StorageNamespace.h&quot;
</span><span class="lines">@@ -632,6 +635,33 @@
</span><span class="cx">     return *m_customElementRegistry;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ExceptionOr&lt;Ref&lt;NodeList&gt;&gt; DOMWindow::collectMatchingElementsInFlatTree(Node&amp; scope, const String&amp; selectors)
+{
+    if (!m_frame)
+        return Exception { NOT_SUPPORTED_ERR };
+
+    Document* document = m_frame-&gt;document();
+    if (!document)
+        return Exception { NOT_SUPPORTED_ERR };
+
+    auto queryOrException = document-&gt;selectorQueryForString(selectors);
+    if (queryOrException.hasException())
+        return queryOrException.releaseException();
+
+    if (!is&lt;ContainerNode&gt;(scope))
+        return Ref&lt;NodeList&gt; { StaticElementList::create() };
+
+    SelectorQuery&amp; query = queryOrException.releaseReturnValue();
+
+    Vector&lt;Ref&lt;Element&gt;&gt; result;
+    for (auto&amp; node : composedTreeDescendants(downcast&lt;ContainerNode&gt;(scope))) {
+        if (is&lt;Element&gt;(node) &amp;&amp; query.matches(downcast&lt;Element&gt;(node)))
+            result.append(downcast&lt;Element&gt;(node));
+    }
+
+    return Ref&lt;NodeList&gt; { StaticElementList::create(WTFMove(result)) };
+}
+
</ins><span class="cx"> #if ENABLE(ORIENTATION_EVENTS)
</span><span class="cx"> 
</span><span class="cx"> int DOMWindow::orientation() const
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMWindowh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMWindow.h (208877 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DOMWindow.h        2016-11-18 05:11:18 UTC (rev 208877)
+++ trunk/Source/WebCore/page/DOMWindow.h        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -71,6 +71,7 @@
</span><span class="cx"> class MessagePort;
</span><span class="cx"> class Navigator;
</span><span class="cx"> class Node;
</span><ins>+class NodeList;
</ins><span class="cx"> class Page;
</span><span class="cx"> class PageConsoleClient;
</span><span class="cx"> class Performance;
</span><span class="lines">@@ -295,6 +296,8 @@
</span><span class="cx">     CustomElementRegistry* customElementRegistry() { return m_customElementRegistry.get(); }
</span><span class="cx">     CustomElementRegistry&amp; ensureCustomElementRegistry();
</span><span class="cx"> 
</span><ins>+    ExceptionOr&lt;Ref&lt;NodeList&gt;&gt; collectMatchingElementsInFlatTree(Node&amp;, const String&amp; selectors);
+
</ins><span class="cx"> #if ENABLE(ORIENTATION_EVENTS)
</span><span class="cx">     // This is the interface orientation in degrees. Some examples are:
</span><span class="cx">     //  0 is straight up; -90 is when the device is rotated 90 clockwise;
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMWindowidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMWindow.idl (208877 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DOMWindow.idl        2016-11-18 05:11:18 UTC (rev 208877)
+++ trunk/Source/WebCore/page/DOMWindow.idl        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -173,6 +173,9 @@
</span><span class="cx"> 
</span><span class="cx">     [EnabledAtRuntime=CustomElements, ImplementedAs=ensureCustomElementRegistry] readonly attribute CustomElementRegistry customElements;
</span><span class="cx"> 
</span><ins>+    [MayThrowException, EnabledForWorld=shadowRootIsAlwaysOpen]
+    NodeList collectMatchingElementsInFlatTree(Node scope, DOMString selectors);
+
</ins><span class="cx">     // Event handlers unique to Element and DOMWindow.
</span><span class="cx">     // FIXME: Should these be exposed on Document as well (and therefore moved to GlobalEventHandlers.idl)?
</span><span class="cx">     [NotEnumerable] attribute EventHandler onanimationend;
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (208877 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-11-18 05:11:18 UTC (rev 208877)
+++ trunk/Tools/ChangeLog        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2016-11-17  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Add an experimental API to find elements across shadow boundaries
+        https://bugs.webkit.org/show_bug.cgi?id=164851
+        &lt;rdar://problem/28220092&gt;
+
+        Reviewed by Sam Weinig.
+
+        Added test cases for window.collectMatchingElementsInFlatTree to WebKit2.InjectedBundleMakeAllShadowRootOpen.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRoot*s*Open_Bundle.cpp: Renamed
+        from InjectedBundleMakeAllShadowRootOpen_Bundle.cpp.
+        (TestWebKitAPI::InjectedBundleMakeAllShadowRootOpenTest::initialize): Added test cases for
+        window.collectMatchingElementsInFlatTree by calling alert() many times.
+        * TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootsOpen.cpp:
+        (TestWebKitAPI::runJavaScriptAlert): Added expectations for multiple test cases. Each test case
+        finishes with a call to alert, and moves testNumber forward.
+        (TestWebKitAPI::TEST): Use the newly added closed-shadow-tree-test.html
+        * TestWebKitAPI/Tests/WebKit2/closed-shadow-tree-test.html: Added. Creates a shadow tree with slots
+        and tests that window.collectMatchingElementsInFlatTree is not present when
+        an event named &quot;testnormalworld&quot; is dispatched by the injected bundle.
+
</ins><span class="cx"> 2016-11-17  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add _WKIconLoadingDelegate SPI.
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (208877 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-11-18 05:11:18 UTC (rev 208877)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -433,8 +433,9 @@
</span><span class="cx">                 93F7E86F14DC8E5C00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F7E86E14DC8E5B00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp */; };
</span><span class="cx">                 9984FACC1CFFAF60008D198C /* WKWebViewTextInput.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9984FACA1CFFAEEE008D198C /* WKWebViewTextInput.mm */; };
</span><span class="cx">                 9984FACE1CFFB090008D198C /* editable-body.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9984FACD1CFFB038008D198C /* editable-body.html */; };
</span><del>-                9B0786A51C5885C300D159E3 /* InjectedBundleMakeAllShadowRootOpen_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B0786A41C5885C300D159E3 /* InjectedBundleMakeAllShadowRootOpen_Bundle.cpp */; };
</del><ins>+                9B0786A51C5885C300D159E3 /* InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B0786A41C5885C300D159E3 /* InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp */; };
</ins><span class="cx">                 9B26FCCA159D16DE00CC3765 /* HTMLFormCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */; };
</span><ins>+                9B270FEE1DDC2C0B002D53F3 /* closed-shadow-tree-test.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B270FED1DDC25FD002D53F3 /* closed-shadow-tree-test.html */; };
</ins><span class="cx">                 9B4F8FA7159D52DD002D9F94 /* HTMLCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */; };
</span><span class="cx">                 9C64DC321D76198A004B598E /* YouTubePluginReplacement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9C64DC311D76198A004B598E /* YouTubePluginReplacement.cpp */; };
</span><span class="cx">                 A1146A8D1D2D7115000FE710 /* ContentFiltering.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1146A8A1D2D704F000FE710 /* ContentFiltering.mm */; };
</span><span class="lines">@@ -579,6 +580,7 @@
</span><span class="cx">                         dstPath = TestWebKitAPI.resources;
</span><span class="cx">                         dstSubfolderSpec = 7;
</span><span class="cx">                         files = (
</span><ins>+                                9B270FEE1DDC2C0B002D53F3 /* closed-shadow-tree-test.html in Copy Resources */,
</ins><span class="cx">                                 F4C2AB221DD6D95E00E06D5B /* enormous-video-with-sound.html in Copy Resources */,
</span><span class="cx">                                 8349D3C41DB9728E004A9F65 /* link-with-download-attribute.html in Copy Resources */,
</span><span class="cx">                                 AD57AC221DA7466E00FF1BDE /* many-iframes.html in Copy Resources */,
</span><span class="lines">@@ -1077,9 +1079,10 @@
</span><span class="cx">                 9984FACA1CFFAEEE008D198C /* WKWebViewTextInput.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewTextInput.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 9984FACD1CFFB038008D198C /* editable-body.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;editable-body.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 9B0786A21C58830F00D159E3 /* InjectedBundleMakeAllShadowRootsOpen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleMakeAllShadowRootsOpen.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                9B0786A41C5885C300D159E3 /* InjectedBundleMakeAllShadowRootOpen_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleMakeAllShadowRootOpen_Bundle.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><ins>+                9B0786A41C5885C300D159E3 /* InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 9B26FC6B159D061000CC3765 /* HTMLFormCollectionNamedItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HTMLFormCollectionNamedItem.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = HTMLFormCollectionNamedItem.html; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                9B270FED1DDC25FD002D53F3 /* closed-shadow-tree-test.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;closed-shadow-tree-test.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HTMLCollectionNamedItem.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = HTMLCollectionNamedItem.html; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 9B79164F1BD89D0D00D50B8F /* FirstResponderScrollingPosition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FirstResponderScrollingPosition.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -1727,7 +1730,7 @@
</span><span class="cx">                                 378E64751632655D00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp */,
</span><span class="cx">                                 F660AA1215A619C8003A1243 /* InjectedBundleInitializationUserDataCallbackWins.cpp */,
</span><span class="cx">                                 F660AA1415A61ABF003A1243 /* InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp */,
</span><del>-                                9B0786A41C5885C300D159E3 /* InjectedBundleMakeAllShadowRootOpen_Bundle.cpp */,
</del><ins>+                                9B0786A41C5885C300D159E3 /* InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp */,
</ins><span class="cx">                                 9B0786A21C58830F00D159E3 /* InjectedBundleMakeAllShadowRootsOpen.cpp */,
</span><span class="cx">                                 93D3D19D17B1A84200C7C415 /* LayoutMilestonesWithAllContentInFrame.cpp */,
</span><span class="cx">                                 52CB47401448FB9300873995 /* LoadAlternateHTMLStringWithNonDirectoryURL.cpp */,
</span><span class="lines">@@ -1870,6 +1873,7 @@
</span><span class="cx">                                 76E182DE15475A8300F1FADD /* auto-submitting-form.html */,
</span><span class="cx">                                 7C486BA01AA1254B003F6F9B /* bundle-file.html */,
</span><span class="cx">                                 1A50AA1F1A2A4EA500F4C345 /* close-from-within-create-page.html */,
</span><ins>+                                9B270FED1DDC25FD002D53F3 /* closed-shadow-tree-test.html */,
</ins><span class="cx">                                 290F4274172A1FDE00939FF0 /* custom-protocol-sync-xhr.html */,
</span><span class="cx">                                 C5E1AFFD16B22179006CC1F2 /* execCopy.html */,
</span><span class="cx">                                 BC2D004A12A9FEB300E732A3 /* file-with-anchor.html */,
</span><span class="lines">@@ -2669,7 +2673,7 @@
</span><span class="cx">                                 378E64771632655E00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp in Sources */,
</span><span class="cx">                                 F660AA1515A61ABF003A1243 /* InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp in Sources */,
</span><span class="cx">                                 BC575A97126E74F1006F0F12 /* InjectedBundleMain.cpp in Sources */,
</span><del>-                                9B0786A51C5885C300D159E3 /* InjectedBundleMakeAllShadowRootOpen_Bundle.cpp in Sources */,
</del><ins>+                                9B0786A51C5885C300D159E3 /* InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp in Sources */,
</ins><span class="cx">                                 33DC89141419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp in Sources */,
</span><span class="cx">                                 33BE5AF9137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp in Sources */,
</span><span class="cx">                                 93F1DB3414DA20870024C362 /* NewFirstVisuallyNonEmptyLayout_Bundle.cpp in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2InjectedBundleMakeAllShadowRootOpen_Bundlecpp"></a>
<div class="delfile"><h4>Deleted: trunk/Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootOpen_Bundle.cpp (208877 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootOpen_Bundle.cpp        2016-11-18 05:11:18 UTC (rev 208877)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootOpen_Bundle.cpp        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -1,65 +0,0 @@
</span><del>-/*
- * Copyright (C) 2010, 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include &quot;config.h&quot;
-
-#if WK_HAVE_C_SPI
-
-#include &quot;InjectedBundleTest.h&quot;
-#include &lt;WebKit/WKBundlePageGroup.h&gt;
-#include &lt;WebKit/WKBundlePrivate.h&gt;
-#include &lt;WebKit/WKBundleScriptWorld.h&gt;
-#include &lt;WebKit/WKRetainPtr.h&gt;
-#include &lt;assert.h&gt;
-
-namespace TestWebKitAPI {
-
-class InjectedBundleMakeAllShadowRootOpenTest : public InjectedBundleTest {
-public:
-    InjectedBundleMakeAllShadowRootOpenTest(const std::string&amp; identifier)
-        : InjectedBundleTest(identifier)
-    { }
-
-    virtual void initialize(WKBundleRef bundle, WKTypeRef userData)
-    {
-        assert(WKGetTypeID(userData) == WKBundlePageGroupGetTypeID());
-        WKBundlePageGroupRef pageGroup = static_cast&lt;WKBundlePageGroupRef&gt;(userData);
-
-        auto world = WKBundleScriptWorldCreateWorld();
-        WKBundleScriptWorldMakeAllShadowRootsOpen(world);
-
-        WKRetainPtr&lt;WKStringRef&gt; source(AdoptWK, WKStringCreateWithUTF8CString(
-            &quot;var element = document.createElement('div');&quot;
-            &quot;element.attachShadow({mode: 'closed'});&quot;
-            &quot;alert(element.shadowRoot ? 'PASS' : 'FAIL');&quot;));
-        WKBundleAddUserScript(bundle, pageGroup, world, source.get(), 0, 0, 0, kWKInjectAtDocumentStart, kWKInjectInAllFrames);
-    }
-};
-
-static InjectedBundleTest::Register&lt;InjectedBundleMakeAllShadowRootOpenTest&gt; registrar(&quot;InjectedBundleMakeAllShadowRootOpenTest&quot;);
-
-} // namespace TestWebKitAPI
-
-#endif
</del></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2InjectedBundleMakeAllShadowRootsOpencpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootsOpen.cpp (208877 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootsOpen.cpp        2016-11-18 05:11:18 UTC (rev 208877)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootsOpen.cpp        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace TestWebKitAPI {
</span><span class="cx"> 
</span><ins>+static unsigned testNumber = 0;
</ins><span class="cx"> static bool done;
</span><span class="cx"> 
</span><span class="cx"> static void runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo)
</span><span class="lines">@@ -41,9 +42,27 @@
</span><span class="cx">     ASSERT_NOT_NULL(frame);
</span><span class="cx"> 
</span><span class="cx">     EXPECT_EQ(page, WKFrameGetPage(frame));
</span><del>-    EXPECT_WK_STREQ(&quot;PASS&quot;, alertText);
-
-    done = true;
</del><ins>+    switch (++testNumber) {
+    case 1:
+        EXPECT_WK_STREQ(&quot;PASS: shadowRoot created in injected bundle&quot;, alertText);
+        break;
+    case 2:
+        EXPECT_WK_STREQ(&quot;PASS: shadowRoot created by normal world&quot;, alertText);
+        break;
+    case 3:
+        EXPECT_WK_STREQ(&quot;PASS: query method exists&quot;, alertText);
+        break;
+    case 4:
+        EXPECT_WK_STREQ(&quot;PASS: query method was not present in the normal world&quot;, alertText);
+        break;
+    case 5:
+        EXPECT_WK_STREQ(&quot;Found:1,2,3,4,5,6&quot;, alertText);
+        break;
+    case 6:
+        EXPECT_WK_STREQ(&quot;Found:2,3,4&quot;, alertText);
+        done = true;
+        break;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(WebKit2, InjectedBundleMakeAllShadowRootOpenTest)
</span><span class="lines">@@ -61,7 +80,7 @@
</span><span class="cx"> 
</span><span class="cx">     WKPageSetPageUIClient(webView.page(), &amp;uiClient.base);
</span><span class="cx"> 
</span><del>-    WKRetainPtr&lt;WKURLRef&gt; url(AdoptWK, Util::createURLForResource(&quot;simple&quot;, &quot;html&quot;));
</del><ins>+    WKRetainPtr&lt;WKURLRef&gt; url(AdoptWK, Util::createURLForResource(&quot;closed-shadow-tree-test&quot;, &quot;html&quot;));
</ins><span class="cx">     WKPageLoadURL(webView.page(), url.get());
</span><span class="cx"> 
</span><span class="cx">     Util::run(&amp;done);
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2InjectedBundleMakeAllShadowRootsOpen_Bundlecppfromrev208877trunkToolsTestWebKitAPITestsWebKit2InjectedBundleMakeAllShadowRootOpen_Bundlecpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp (from rev 208877, trunk/Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootOpen_Bundle.cpp) (0 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/InjectedBundleMakeAllShadowRootsOpen_Bundle.cpp        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -0,0 +1,83 @@
</span><ins>+/*
+ * Copyright (C) 2010, 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+
+#if WK_HAVE_C_SPI
+
+#include &quot;InjectedBundleTest.h&quot;
+#include &lt;WebKit/WKBundlePageGroup.h&gt;
+#include &lt;WebKit/WKBundlePrivate.h&gt;
+#include &lt;WebKit/WKBundleScriptWorld.h&gt;
+#include &lt;WebKit/WKRetainPtr.h&gt;
+#include &lt;assert.h&gt;
+
+namespace TestWebKitAPI {
+
+class InjectedBundleMakeAllShadowRootOpenTest : public InjectedBundleTest {
+public:
+    InjectedBundleMakeAllShadowRootOpenTest(const std::string&amp; identifier)
+        : InjectedBundleTest(identifier)
+    { }
+
+    virtual void initialize(WKBundleRef bundle, WKTypeRef userData)
+    {
+        assert(WKGetTypeID(userData) == WKBundlePageGroupGetTypeID());
+        WKBundlePageGroupRef pageGroup = static_cast&lt;WKBundlePageGroupRef&gt;(userData);
+
+        auto world = WKBundleScriptWorldCreateWorld();
+        WKBundleScriptWorldMakeAllShadowRootsOpen(world);
+
+        WKRetainPtr&lt;WKStringRef&gt; source(AdoptWK, WKStringCreateWithUTF8CString(
+            &quot;window.onload = function () {\n&quot;
+            &quot;    const element = document.createElement('div');\n&quot;
+            &quot;    const queryMethodName = 'collectMatchingElementsInFlatTree';\n&quot;
+            &quot;    element.attachShadow({mode: 'closed'});\n&quot;
+            // Test 1
+            &quot;    alert(element.shadowRoot ? 'PASS: shadowRoot created in injected bundle' : 'FAIL');\n&quot;
+            // Test 2
+            &quot;    alert(document.querySelector('shadow-host').shadowRoot ? 'PASS: shadowRoot created by normal world' : 'FAIL');\n&quot;
+            // Test 3
+            &quot;    alert(window[queryMethodName] ? 'PASS: query method exists' : 'FAIL');\n&quot;
+            // Test 4
+            &quot;    document.dispatchEvent(new Event('testnormalworld'));\n&quot;
+            // Test 5
+            &quot;    const queryMethod = window[queryMethodName];\n&quot;
+            &quot;    let queryResult = Array.from(queryMethod(document, 'span'));\n&quot;
+            &quot;    alert('Found:' + queryResult.map((span) =&gt; span.textContent).join(','));\n&quot;
+            // Test 6
+            &quot;    const innerHost = queryMethod(document, 'inner-host')[0];\n&quot;
+            &quot;    queryResult = Array.from(queryMethod(innerHost, 'span'));\n&quot;
+            &quot;    alert('Found:' + queryResult.map((span) =&gt; span.textContent).join(','));\n&quot;
+            &quot;}\n&quot;));
+        WKBundleAddUserScript(bundle, pageGroup, world, source.get(), 0, 0, 0, kWKInjectAtDocumentStart, kWKInjectInAllFrames);
+    }
+};
+
+static InjectedBundleTest::Register&lt;InjectedBundleMakeAllShadowRootOpenTest&gt; registrar(&quot;InjectedBundleMakeAllShadowRootOpenTest&quot;);
+
+} // namespace TestWebKitAPI
+
+#endif
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2closedshadowtreetesthtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/closed-shadow-tree-test.html (0 => 208878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/closed-shadow-tree-test.html                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/closed-shadow-tree-test.html        2016-11-18 05:30:24 UTC (rev 208878)
</span><span class="lines">@@ -0,0 +1,28 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+&lt;shadow-host&gt;&lt;span&gt;5&lt;/span&gt;&lt;span slot=&quot;bar&quot;&gt;2&lt;/span&gt;&lt;/shadow-host&gt;
+&lt;script&gt;
+const shadowRoot = document.querySelector('shadow-host').attachShadow({mode: 'closed'});
+shadowRoot.innerHTML = `
+    &lt;span&gt;1&lt;/span&gt;
+    &lt;inner-host&gt;
+        &lt;slot name=&quot;bar&quot; slot=&quot;foo&quot;&gt;&lt;span&gt;FAIL - named slot fallback&lt;/span&gt;&lt;/slot&gt;
+        &lt;span&gt;FAIL - unassigned content&lt;/span&gt;
+        &lt;span slot=&quot;foo&quot;&gt;3&lt;/span&gt;
+    &lt;/inner-host&gt;
+    &lt;slot&gt;&lt;span&gt;FAIL - default slot fallback&lt;/span&gt;&lt;/slot&gt;
+    &lt;span&gt;6&lt;/span&gt;`;
+const innerHost = shadowRoot.querySelector('inner-host');
+innerHost.attachShadow({mode: 'closed'}).innerHTML = `
+    &lt;slot name=&quot;foo&quot;&gt;&lt;/slot&gt;
+    &lt;span&gt;4&lt;/span&gt;`;
+
+document.addEventListener('testnormalworld', function () {
+    alert(window.collectMatchingElementsInFlatTree ?
+        'FAIL' : 'PASS: query method was not present in the normal world');
+});
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre>
</div>
</div>

</body>
</html>