Title: [218020] trunk
- Revision
- 218020
- Author
- [email protected]
- Date
- 2017-06-09 14:59:03 -0700 (Fri, 09 Jun 2017)
Log Message
Web Inspector: Web inspector does not show non-shadow children of an element with a shadow root (e.g. <video>)
https://bugs.webkit.org/show_bug.cgi?id=173121
<rdar://problem/30948943>
Patch by Joseph Pecoraro <[email protected]> on 2017-06-09
Reviewed by Matt Baker.
Source/WebInspectorUI:
* UserInterface/Models/DOMNode.js:
(WebInspector.DOMNode):
Only populate _children when we have both the shadowRoots and
actual children payloads. Backends always send shadowRoots but
only send children when requested. So if we have shadowRoots
but expect actual children, don't populate _children until we
request the child nodes.
LayoutTests:
* inspector/dom/shadow-and-non-shadow-children-expected.txt: Added.
* inspector/dom/shadow-and-non-shadow-children.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (218019 => 218020)
--- trunk/LayoutTests/ChangeLog 2017-06-09 21:53:34 UTC (rev 218019)
+++ trunk/LayoutTests/ChangeLog 2017-06-09 21:59:03 UTC (rev 218020)
@@ -1,3 +1,14 @@
+2017-06-09 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Web inspector does not show non-shadow children of an element with a shadow root (e.g. <video>)
+ https://bugs.webkit.org/show_bug.cgi?id=173121
+ <rdar://problem/30948943>
+
+ Reviewed by Matt Baker.
+
+ * inspector/dom/shadow-and-non-shadow-children-expected.txt: Added.
+ * inspector/dom/shadow-and-non-shadow-children.html: Added.
+
2017-06-09 Said Abou-Hallawa <[email protected]>
LayoutTest fast/images/animated-image-different-dest-size.html is a flaky failure
Added: trunk/LayoutTests/inspector/dom/shadow-and-non-shadow-children-expected.txt (0 => 218020)
--- trunk/LayoutTests/inspector/dom/shadow-and-non-shadow-children-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/dom/shadow-and-non-shadow-children-expected.txt 2017-06-09 21:59:03 UTC (rev 218020)
@@ -0,0 +1,14 @@
+Test for DOMNode.children of an element with a shadow and non-shadow children.
+
+
+
+== Running test suite: DOMNode.ShadowAndNonShadowChildren
+-- Running test case: DOMNode.ShadowAndNonShadowChildren.VideoWithSource
+PASS: DOMNode should be a `video` element.
+PASS: DOMNode should have child nodes.
+PASS: DOMNode should indicate it has 2 child nodes.
+PASS: DOMNode children should be null.
+PASS: DOMNode should have 2 children.
+PASS: DOMNode 1st child should be a ShadowRoot.
+PASS: DOMNode 2nd child should be a `source` element.
+
Added: trunk/LayoutTests/inspector/dom/shadow-and-non-shadow-children.html (0 => 218020)
--- trunk/LayoutTests/inspector/dom/shadow-and-non-shadow-children.html (rev 0)
+++ trunk/LayoutTests/inspector/dom/shadow-and-non-shadow-children.html 2017-06-09 21:59:03 UTC (rev 218020)
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+// FIXME: LayoutTest with <video> ends before running any onload handler.
+if (window.testRunner)
+ testRunner.waitUntilDone();
+
+function test()
+{
+ let documentNodeId;
+ let suite = InspectorTest.createAsyncSuite("DOMNode.ShadowAndNonShadowChildren");
+
+ suite.addTestCase({
+ name: "DOMNode.ShadowAndNonShadowChildren.VideoWithSource",
+ description: "Check for all children of a video with a source child.",
+ test(resolve, reject) {
+ WebInspector.domTreeManager.querySelector(documentNodeId, "#test-video", (nodeId) => {
+ let domNode = WebInspector.domTreeManager.nodeForId(nodeId);
+ InspectorTest.expectEqual(domNode.nodeName(), "VIDEO", "DOMNode should be a `video` element.");
+ InspectorTest.expectThat(domNode.hasChildNodes(), "DOMNode should have child nodes.");
+ InspectorTest.expectThat(domNode.childNodeCount, "DOMNode should indicate it has 2 child nodes.");
+ InspectorTest.expectNull(domNode.children, "DOMNode children should be null.");
+ domNode.getChildNodes((children) => {
+ InspectorTest.assert(children, domNode.children);
+ InspectorTest.expectEqual(domNode.children.length, 2, "DOMNode should have 2 children.");
+ InspectorTest.expectThat(domNode.children[0].isShadowRoot(), "DOMNode 1st child should be a ShadowRoot.");
+ InspectorTest.expectEqual(domNode.children[1].nodeName(), "SOURCE", "DOMNode 2nd child should be a `source` element.");
+ resolve();
+ });
+ });
+ }
+ });
+
+ WebInspector.domTreeManager.requestDocument((documentNode) => {
+ documentNodeId = documentNode.id;
+ suite.runTestCasesAndFinish();
+ });
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Test for DOMNode.children of an element with a shadow and non-shadow children.</p>
+<video id="test-video" controls><source src="" type="video/mp4"></video>
+</body>
+</html>
Modified: trunk/Source/WebInspectorUI/ChangeLog (218019 => 218020)
--- trunk/Source/WebInspectorUI/ChangeLog 2017-06-09 21:53:34 UTC (rev 218019)
+++ trunk/Source/WebInspectorUI/ChangeLog 2017-06-09 21:59:03 UTC (rev 218020)
@@ -1,3 +1,19 @@
+2017-06-09 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Web inspector does not show non-shadow children of an element with a shadow root (e.g. <video>)
+ https://bugs.webkit.org/show_bug.cgi?id=173121
+ <rdar://problem/30948943>
+
+ Reviewed by Matt Baker.
+
+ * UserInterface/Models/DOMNode.js:
+ (WebInspector.DOMNode):
+ Only populate _children when we have both the shadowRoots and
+ actual children payloads. Backends always send shadowRoots but
+ only send children when requested. So if we have shadowRoots
+ but expect actual children, don't populate _children until we
+ request the child nodes.
+
2017-06-07 Carlos Garcia Campos <[email protected]>
Remove legacy INSPECTOR_SERVER implementation
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js (218019 => 218020)
--- trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js 2017-06-09 21:53:34 UTC (rev 218019)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/DOMNode.js 2017-06-09 21:59:03 UTC (rev 218020)
@@ -73,6 +73,9 @@
this._enabledPseudoClasses = [];
// FIXME: The logic around this._shadowRoots and this._children is very confusing.
+ // We eventually include shadow roots at the start of _children. However we might
+ // not have our actual children yet. So we try to defer initializing _children until
+ // we have both shadowRoots and child nodes.
this._shadowRoots = [];
if (payload.shadowRoots) {
for (var i = 0; i < payload.shadowRoots.length; ++i) {
@@ -83,6 +86,11 @@
}
}
+ if (payload.children)
+ this._setChildrenPayload(payload.children);
+ else if (this._shadowRoots.length && !this._childNodeCount)
+ this._children = this._shadowRoots.slice();
+
if (this._nodeType === Node.ELEMENT_NODE)
this._customElementState = payload.customElementState || WebInspector.DOMNode.CustomElementState.Builtin;
else
@@ -93,11 +101,6 @@
this._templateContent.parentNode = this;
}
- if (payload.children)
- this._setChildrenPayload(payload.children);
- else if (!this._children && this._shadowRoots.length)
- this._children = this._shadowRoots.slice();
-
this._pseudoElements = new Map;
if (payload.pseudoElements) {
for (var i = 0; i < payload.pseudoElements.length; ++i) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes