Diff
Modified: trunk/LayoutTests/ChangeLog (208245 => 208246)
--- trunk/LayoutTests/ChangeLog 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/LayoutTests/ChangeLog 2016-11-01 21:48:31 UTC (rev 208246)
@@ -1,3 +1,26 @@
+2016-11-01 Devin Rousso <dcrousso+web...@gmail.com>
+
+ Web Inspector: Replace sublists inside DOM-related model objects with WI.Collection
+ https://bugs.webkit.org/show_bug.cgi?id=164098
+
+ Reviewed by Timothy Hatcher.
+
+ * http/tests/inspector/console/cross-domain-inspected-node-access-expected.txt:
+ * http/tests/inspector/console/cross-domain-inspected-node-access.html:
+ * http/tests/inspector/dom/disconnect-dom-tree-after-main-frame-navigation.html:
+ * inspector/css/manager-preferredInspectorStyleSheetForFrame-expected.txt:
+ * inspector/css/manager-preferredInspectorStyleSheetForFrame.html:
+ * inspector/dom/content-flow-list.html:
+ * inspector/dom/highlightFrame-expected.txt:
+ * inspector/dom/highlightFrame.html:
+ * inspector/dom/highlightNode-expected.txt:
+ * inspector/dom/highlightNode.html:
+ * inspector/dom/highlightSelector-expected.txt:
+ * inspector/dom/highlightSelector.html:
+ * inspector/model/frame-extra-scripts-expected.txt:
+ * inspector/model/frame-extra-scripts.html:
+ Change functionality to support WebInspector.Collection methods.
+
2016-11-01 Antoine Quint <grao...@apple.com>
[Modern Media Controls] Media Controller: Placard support
Modified: trunk/LayoutTests/http/tests/inspector/console/cross-domain-inspected-node-access-expected.txt (208245 => 208246)
--- trunk/LayoutTests/http/tests/inspector/console/cross-domain-inspected-node-access-expected.txt 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/LayoutTests/http/tests/inspector/console/cross-domain-inspected-node-access-expected.txt 2016-11-01 21:48:31 UTC (rev 208246)
@@ -3,6 +3,7 @@
Test that code evaluated in the main frame cannot access $0 that resolves to a node in a frame from a different domain. Bug 105423.
+PASS: Page should have a subframe.
== Running test suite: CommandLineAPI.$0.cross-frame
-- Running test case: AttemptCrossFrame$0AccessFromMainFrame
Modified: trunk/LayoutTests/http/tests/inspector/console/cross-domain-inspected-node-access.html (208245 => 208246)
--- trunk/LayoutTests/http/tests/inspector/console/cross-domain-inspected-node-access.html 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/LayoutTests/http/tests/inspector/console/cross-domain-inspected-node-access.html 2016-11-01 21:48:31 UTC (rev 208246)
@@ -7,6 +7,10 @@
{
let suite = InspectorTest.createAsyncSuite("CommandLineAPI.$0.cross-frame");
+ let mainFrame = WebInspector.frameResourceManager.mainFrame;
+ let childFrames = mainFrame.childFrameCollection.toArray();
+ InspectorTest.expectEqual(childFrames.length, 1, "Page should have a subframe.");
+
let nodeInMainFrameId;
let nodeInSubFrameId;
@@ -13,7 +17,7 @@
suite.addTestCase({
name: "AttemptCrossFrame$0AccessFromMainFrame",
description: "Should not be able to access $0 node in different domain subframe from the main frame.",
- test: (resolve, reject) => {
+ test(resolve, reject) {
InspectorTest.log("Setting $0 to node within subframe.");
ConsoleAgent.addInspectedNode(nodeInSubFrameId);
RuntimeAgent.evaluate.invoke({_expression_: "$0", includeCommandLineAPI: true}, (error, remoteObjectPayload, wasThrown) => {
@@ -29,7 +33,7 @@
suite.addTestCase({
name: "AttemptSameFrame$0AccessFromMainFrame",
description: "Should be able to access $0 node in the same frame.",
- test: (resolve, reject) => {
+ test(resolve, reject) {
InspectorTest.log("Setting $0 to node within the main frame.");
ConsoleAgent.addInspectedNode(nodeInMainFrameId);
RuntimeAgent.evaluate.invoke({_expression_: "$0", includeCommandLineAPI: true}, (error, remoteObjectPayload, wasThrown) => {
@@ -45,11 +49,10 @@
suite.addTestCase({
name: "AttemptCrossFrame$0AccessFromSubFrame",
description: "Should not be able to access $0 node in different domain main frame from the subframe.",
- test: (resolve, reject) => {
+ test(resolve, reject) {
InspectorTest.log("Setting $0 to node within the main frame.");
ConsoleAgent.addInspectedNode(nodeInMainFrameId);
- const childFrame = WebInspector.frameResourceManager.mainFrame.childFrames[0];
- RuntimeAgent.evaluate.invoke({_expression_: "$0", includeCommandLineAPI: true, contextId: childFrame.pageExecutionContext.id}, (error, remoteObjectPayload, wasThrown) => {
+ RuntimeAgent.evaluate.invoke({_expression_: "$0", includeCommandLineAPI: true, contextId: childFrames[0].pageExecutionContext.id}, (error, remoteObjectPayload, wasThrown) => {
InspectorTest.assert(!error, "Should not be a protocol error.");
InspectorTest.assert(!wasThrown, "Should not be an exception.");
let remoteObject = WebInspector.RemoteObject.fromPayload(remoteObjectPayload);
@@ -62,11 +65,10 @@
suite.addTestCase({
name: "AttemptSameFrame$0AccessFromSubFrame",
description: "Should be able to access $0 node in the same frame.",
- test: (resolve, reject) => {
+ test(resolve, reject) {
InspectorTest.log("Setting $0 to node within the subframe.");
ConsoleAgent.addInspectedNode(nodeInSubFrameId);
- const childFrame = WebInspector.frameResourceManager.mainFrame.childFrames[0];
- RuntimeAgent.evaluate.invoke({_expression_: "$0", includeCommandLineAPI: true, contextId: childFrame.pageExecutionContext.id}, (error, remoteObjectPayload, wasThrown) => {
+ RuntimeAgent.evaluate.invoke({_expression_: "$0", includeCommandLineAPI: true, contextId: childFrames[0].pageExecutionContext.id}, (error, remoteObjectPayload, wasThrown) => {
InspectorTest.assert(!error, "Should not be a protocol error.");
InspectorTest.assert(!wasThrown, "Should not be an exception.");
let remoteObject = WebInspector.RemoteObject.fromPayload(remoteObjectPayload);
Modified: trunk/LayoutTests/http/tests/inspector/dom/disconnect-dom-tree-after-main-frame-navigation.html (208245 => 208246)
--- trunk/LayoutTests/http/tests/inspector/dom/disconnect-dom-tree-after-main-frame-navigation.html 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/LayoutTests/http/tests/inspector/dom/disconnect-dom-tree-after-main-frame-navigation.html 2016-11-01 21:48:31 UTC (rev 208246)
@@ -30,10 +30,15 @@
InspectorTest.log("DOMTree instance count: " + instances.size);
// Force creation of child DOM trees.
- mainFrame.childFrames[0].domTree;
- mainFrame.childFrames[0].childFrames[0].domTree;
- mainFrame.childFrames[0].childFrames[0].childFrames[0].domTree;
+ let childrenLevel1 = mainFrame.childFrameCollection.toArray();
+ childrenLevel1[0].domTree;
+ let childrenLevel2 = childrenLevel1[0].childFrameCollection.toArray();
+ childrenLevel2[0].domTree;
+
+ let childrenLevel3 = childrenLevel2[0].childFrameCollection.toArray();
+ childrenLevel3[0].domTree;
+
instances = WebInspector.domTreeManager.retainedObjectsWithPrototype(WebInspector.DOMTree);
InspectorTest.expectThat(instances.size === 4, "There should be four DOMTrees listening to DOMTreeManager events after touching each Frame.");
InspectorTest.log("DOMTree instance count: " + instances.size);
Modified: trunk/LayoutTests/inspector/css/manager-preferredInspectorStyleSheetForFrame-expected.txt (208245 => 208246)
--- trunk/LayoutTests/inspector/css/manager-preferredInspectorStyleSheetForFrame-expected.txt 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/LayoutTests/inspector/css/manager-preferredInspectorStyleSheetForFrame-expected.txt 2016-11-01 21:48:31 UTC (rev 208246)
@@ -1,6 +1,7 @@
Test CSSManager.preferredInspectorStyleSheetForFrame.
+PASS: Page should have a subframe.
== Running test suite: CSSManager.preferredInspectorStyleSheetForFrame
-- Running test case: CheckNoStyleSheets
Modified: trunk/LayoutTests/inspector/css/manager-preferredInspectorStyleSheetForFrame.html (208245 => 208246)
--- trunk/LayoutTests/inspector/css/manager-preferredInspectorStyleSheetForFrame.html 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/LayoutTests/inspector/css/manager-preferredInspectorStyleSheetForFrame.html 2016-11-01 21:48:31 UTC (rev 208246)
@@ -6,7 +6,8 @@
function test()
{
let mainFrame = WebInspector.frameResourceManager.mainFrame;
- let childFrame = mainFrame.childFrames[0];
+ let childFrames = mainFrame.childFrameCollection.toArray();
+ InspectorTest.expectEqual(childFrames.length, 1, "Page should have a subframe.");
let suite = InspectorTest.createAsyncSuite("CSSManager.preferredInspectorStyleSheetForFrame");
@@ -64,10 +65,10 @@
.then((event) => {
InspectorTest.expectThat(event.data.styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, "Added StyleSheet origin should be 'inspector'.");
InspectorTest.expectThat(event.data.styleSheet.isInspectorStyleSheet(), "StyleSheet.isInspectorStyleSheet() should be true.");
- InspectorTest.expectThat(event.data.styleSheet.parentFrame === childFrame, "Added StyleSheet frame should be a child frame.");
+ InspectorTest.expectThat(event.data.styleSheet.parentFrame === childFrames[0], "Added StyleSheet frame should be a child frame.");
});
- WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(childFrame, (styleSheet) => {
+ WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(childFrames[0], (styleSheet) => {
InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 2, "Should be two stylesheets.");
InspectorTest.expectThat(styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, "StyleSheet origin should be 'inspector'.");
InspectorTest.expectThat(styleSheet.isInspectorStyleSheet(), "StyleSheet.isInspectorStyleSheet() should be true.");
@@ -83,7 +84,7 @@
let listener = WebInspector.cssStyleManager.singleFireEventListener(WebInspector.CSSStyleManager.Event.StyleSheetAdded, (event) => {
InspectorTest.assert(false, "Should not create a new StyleSheet, should reuse the existing one");
});
- WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(childFrame, (styleSheet) => {
+ WebInspector.cssStyleManager.preferredInspectorStyleSheetForFrame(childFrames[0], (styleSheet) => {
InspectorTest.expectThat(WebInspector.cssStyleManager.styleSheets.length === 2, "Should be two stylesheets.");
InspectorTest.expectThat(styleSheet.origin === WebInspector.CSSStyleSheet.Type.Inspector, "StyleSheet origin should be 'inspector'.");
InspectorTest.expectThat(styleSheet.isInspectorStyleSheet(), "StyleSheet.isInspectorStyleSheet() should be true.");
Modified: trunk/LayoutTests/inspector/dom/content-flow-list.html (208245 => 208246)
--- trunk/LayoutTests/inspector/dom/content-flow-list.html 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/LayoutTests/inspector/dom/content-flow-list.html 2016-11-01 21:48:31 UTC (rev 208246)
@@ -16,15 +16,17 @@
function test()
{
+ let domTree = WebInspector.frameResourceManager.mainFrame.domTree;
+
function onRootDOMNodeInvalidated()
{
- WebInspector.frameResourceManager.mainFrame.domTree.requestContentFlowList();
+ domTree.requestContentFlowList();
}
function onContentFlowWasAdded(event)
{
- InspectorTest.expectThat(event.data.flow.name === "flow1", "ContentFlow was added");
- InspectorTest.expectThat(WebInspector.frameResourceManager.mainFrame.domTree.flowsCount === 1, "Flow count is 1");
+ InspectorTest.expectEqual(event.data.flow.name, "flow1", "ContentFlow was added");
+ InspectorTest.expectEqual(domTree.contentFlowCollection.items.size, 1, "Flow count is 1");
InspectorTest.evaluateInPage("removeFlow()");
}
@@ -31,16 +33,15 @@
function onContentFlowWasRemoved(event)
{
- InspectorTest.expectThat(event.data.flow.name === "flow1", "ContentFlow was removed");
- InspectorTest.expectThat(WebInspector.frameResourceManager.mainFrame.domTree.flowsCount === 0, "Flow count is 0");
+ InspectorTest.expectEqual(event.data.flow.name, "flow1", "ContentFlow was removed");
+ InspectorTest.expectEqual(domTree.contentFlowCollection.items.size, 0, "Flow count is 0");
InspectorTest.completeTest();
}
WebInspector.Frame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, function() {
- var domTree = WebInspector.frameResourceManager.mainFrame.domTree;
- domTree.addEventListener(WebInspector.DOMTree.Event.RootDOMNodeInvalidated, onRootDOMNodeInvalidated, null);
- domTree.addEventListener(WebInspector.DOMTree.Event.ContentFlowWasAdded, onContentFlowWasAdded, null);
- domTree.addEventListener(WebInspector.DOMTree.Event.ContentFlowWasRemoved, onContentFlowWasRemoved, null);
+ domTree.addEventListener(WebInspector.DOMTree.Event.RootDOMNodeInvalidated, onRootDOMNodeInvalidated);
+ domTree.addEventListener(WebInspector.DOMTree.Event.ContentFlowWasAdded, onContentFlowWasAdded);
+ domTree.addEventListener(WebInspector.DOMTree.Event.ContentFlowWasRemoved, onContentFlowWasRemoved);
domTree.requestContentFlowList();
});
Modified: trunk/LayoutTests/inspector/dom/highlightFrame-expected.txt (208245 => 208246)
--- trunk/LayoutTests/inspector/dom/highlightFrame-expected.txt 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/LayoutTests/inspector/dom/highlightFrame-expected.txt 2016-11-01 21:48:31 UTC (rev 208246)
@@ -1,6 +1,7 @@
Tests for the DOM.highlightFrame command.
+PASS: Page should have subframes.
== Running test suite: DOM.highlightFrame
-- Running test case: CheckEmptyHighlight
Modified: trunk/LayoutTests/inspector/dom/highlightFrame.html (208245 => 208246)
--- trunk/LayoutTests/inspector/dom/highlightFrame.html 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/LayoutTests/inspector/dom/highlightFrame.html 2016-11-01 21:48:31 UTC (rev 208246)
@@ -5,11 +5,12 @@
<script>
function test()
{
- InspectorTest.assert(WebInspector.frameResourceManager.mainFrame.childFrames.length === 2, "Page should have subframes.");
- const mainFrame = WebInspector.frameResourceManager.mainFrame;
- const childFrame1 = WebInspector.frameResourceManager.mainFrame.childFrames[0];
- const childFrame2 = WebInspector.frameResourceManager.mainFrame.childFrames[1];
+ let suite = InspectorTest.createAsyncSuite("DOM.highlightFrame");
+ let mainFrame = WebInspector.frameResourceManager.mainFrame;
+ let childFrames = mainFrame.childFrameCollection.toArray();
+ InspectorTest.expectEqual(childFrames.length, 2, "Page should have subframes.");
+
function getHighlight(callback) {
InspectorTest.evaluateInPage("window.internals.inspectorHighlightObject()", (error, payload, wasThrown) => {
InspectorTest.assert(!error, "Unexpected error dumping highlight: " + error);
@@ -25,12 +26,10 @@
});
}
- let suite = InspectorTest.createAsyncSuite("DOM.highlightFrame");
-
suite.addTestCase({
name: "CheckEmptyHighlight",
description: "Should not be a highlight yet.",
- test: (resolve, reject) => {
+ test(resolve, reject) {
getHighlight((highlightObjectPayload) => {
InspectorTest.expectThat(highlightObjectPayload.length === 0, "Should not be a highlight yet.");
resolve();
@@ -41,7 +40,7 @@
suite.addTestCase({
name: "HighlightMainFrame",
description: "Main frame does not have an owner element, so there will be no highlight.",
- test: (resolve, reject) => {
+ test(resolve, reject) {
DOMAgent.highlightFrame(mainFrame.id, undefined, undefined, (error) => {
getHighlight((highlightObjectPayload) => {
InspectorTest.expectThat(highlightObjectPayload.length === 0, "Should not be a highlight for the main frame.");
@@ -54,8 +53,8 @@
suite.addTestCase({
name: "HighlightChildFrame1",
description: "Should highlight child frame 1.",
- test: (resolve, reject) => {
- DOMAgent.highlightFrame(childFrame1.id, undefined, undefined, (error) => {
+ test(resolve, reject) {
+ DOMAgent.highlightFrame(childFrames[0].id, undefined, undefined, (error) => {
InspectorTest.assert(!error, "Should not have an error.");
dumpHighlight(resolve);
});
@@ -65,8 +64,8 @@
suite.addTestCase({
name: "HighlightChildFrame2",
description: "Should highlight child frame 2.",
- test: (resolve, reject) => {
- DOMAgent.highlightFrame(childFrame2.id, undefined, undefined, (error) => {
+ test(resolve, reject) {
+ DOMAgent.highlightFrame(childFrames[1].id, undefined, undefined, (error) => {
InspectorTest.assert(!error, "Should not have an error.");
dumpHighlight(resolve);
});
@@ -78,7 +77,7 @@
suite.addTestCase({
name: "BadFrameId",
description: "Bad frame id should cause an error.",
- test: (resolve, reject) => {
+ test(resolve, reject) {
DOMAgent.highlightFrame("bad-frame-id", undefined, undefined, (error) => {
InspectorTest.expectThat(error, "Should produce an error.");
InspectorTest.log("Error: " + error);
Modified: trunk/LayoutTests/inspector/dom/highlightNode-expected.txt (208245 => 208246)
--- trunk/LayoutTests/inspector/dom/highlightNode-expected.txt 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/LayoutTests/inspector/dom/highlightNode-expected.txt 2016-11-01 21:48:31 UTC (rev 208246)
@@ -1,6 +1,7 @@
Tests for the DOM.highlightNode command.
+PASS: Page should have a subframe.
== Running test suite: DOM.highlightNode
-- Running test case: CheckEmptyHighlight
Modified: trunk/LayoutTests/inspector/dom/highlightNode.html (208245 => 208246)
--- trunk/LayoutTests/inspector/dom/highlightNode.html 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/LayoutTests/inspector/dom/highlightNode.html 2016-11-01 21:48:31 UTC (rev 208246)
@@ -5,9 +5,12 @@
<script>
function test()
{
- InspectorTest.assert(WebInspector.frameResourceManager.mainFrame.childFrames.length === 1, "Page should have a subframe.");
- const mainFrame = WebInspector.frameResourceManager.mainFrame;
- const childFrame = WebInspector.frameResourceManager.mainFrame.childFrames[0];
+ let suite = InspectorTest.createAsyncSuite("DOM.highlightNode");
+
+ let mainFrame = WebInspector.frameResourceManager.mainFrame;
+ let childFrames = mainFrame.childFrameCollection.toArray();
+ InspectorTest.expectEqual(childFrames.length, 1, "Page should have a subframe.");
+
const highlightConfig = {
showInfo: true,
contentColor: {r: 255, g: 255, b: 255},
@@ -26,7 +29,7 @@
function dumpHighlight(callback) {
getHighlight((highlightObjectPayload) => {
- InspectorTest.expectThat(highlightObjectPayload.length === 1, "Should be one highlighted node.");
+ InspectorTest.expectEqual(highlightObjectPayload.length, 1, "Should be one highlighted node.");
InspectorTest.log("Highlighted Element Data: " + JSON.stringify(highlightObjectPayload[0].elementData));
callback();
});
@@ -36,14 +39,12 @@
let mainFrameDocumentNodeId, mainFrameTargetNode;
let childFrameDocumentNodeId, childFrameTargetNode;
- let suite = InspectorTest.createAsyncSuite("DOM.highlightNode");
-
suite.addTestCase({
name: "CheckEmptyHighlight",
description: "Should not be a highlight yet.",
- test: (resolve, reject) => {
+ test(resolve, reject) {
getHighlight((highlightObjectPayload) => {
- InspectorTest.expectThat(highlightObjectPayload.length === 0, "Should not be a highlight yet.");
+ InspectorTest.expectEqual(highlightObjectPayload.length, 0, "Should not be a highlight yet.");
resolve();
});
}
@@ -52,7 +53,7 @@
suite.addTestCase({
name: "MainFrameNodeViaNodeId",
description: "Should highlight a node in the main frame using node id.",
- test: (resolve, reject) => {
+ test(resolve, reject) {
WebInspector.domTreeManager.querySelector(mainFrameDocumentNodeId, "#id-one", function(nodeId) {
mainFrameTargetNode = WebInspector.domTreeManager.nodeForId(nodeId);
DOMAgent.highlightNode(highlightConfig, mainFrameTargetNode.id, undefined, (error) => {
@@ -66,7 +67,7 @@
suite.addTestCase({
name: "ChildFrameNodeViaNodeId",
description: "Should highlight a node in the child frame using node id.",
- test: (resolve, reject) => {
+ test(resolve, reject) {
WebInspector.domTreeManager.querySelector(childFrameDocumentNodeId, "#id-one", function(nodeId) {
childFrameTargetNode = WebInspector.domTreeManager.nodeForId(nodeId);
DOMAgent.highlightNode(highlightConfig, childFrameTargetNode.id, undefined, (error) => {
@@ -80,7 +81,7 @@
suite.addTestCase({
name: "MainFrameNodeViaObjectId",
description: "Should highlight a node in the main frame using object id.",
- test: (resolve, reject) => {
+ test(resolve, reject) {
WebInspector.RemoteObject.resolveNode(mainFrameTargetNode, "test", (remoteObject) => {
DOMAgent.highlightNode(highlightConfig, undefined, remoteObject.objectId, (error) => {
InspectorTest.assert(!error, "Should not have an error.");
@@ -93,7 +94,7 @@
suite.addTestCase({
name: "ChildFrameNodeViaObjectId",
description: "Should highlight a node in the child frame using object id.",
- test: (resolve, reject) => {
+ test(resolve, reject) {
WebInspector.RemoteObject.resolveNode(childFrameTargetNode, "test", (remoteObject) => {
DOMAgent.highlightNode(highlightConfig, undefined, remoteObject.objectId, (error) => {
InspectorTest.assert(!error, "Should not have an error.");
@@ -108,7 +109,7 @@
suite.addTestCase({
name: "MissingNodeAndObjectIdShouldError",
description: "Missing identifiers should cause an error.",
- test: (resolve, reject) => {
+ test(resolve, reject) {
DOMAgent.highlightNode(highlightConfig, undefined, undefined, (error) => {
InspectorTest.expectThat(error, "Should produce an error.");
InspectorTest.log("Error: " + error);
@@ -120,7 +121,7 @@
suite.addTestCase({
name: "BadNodeId",
description: "Bad node id should cause an error.",
- test: (resolve, reject) => {
+ test(resolve, reject) {
DOMAgent.highlightNode(highlightConfig, 9999999, undefined, (error) => {
InspectorTest.expectThat(error, "Should produce an error.");
InspectorTest.log("Error: " + error);
@@ -132,7 +133,7 @@
suite.addTestCase({
name: "BadObjectId",
description: "Bad object id should cause an error.",
- test: (resolve, reject) => {
+ test(resolve, reject) {
DOMAgent.highlightNode(highlightConfig, undefined, "bad-object-id", (error) => {
InspectorTest.expectThat(error, "Should produce an error.");
InspectorTest.log("Error: " + error);
@@ -143,7 +144,7 @@
WebInspector.domTreeManager.requestDocument((documentNode) => {
mainFrameDocumentNodeId = documentNode.id;
- RuntimeAgent.evaluate.invoke({_expression_: "document", objectGroup: "test", contextId: childFrame.pageExecutionContext.id}, (error, remoteObjectPayload) => {
+ RuntimeAgent.evaluate.invoke({_expression_: "document", objectGroup: "test", contextId: childFrames[0].pageExecutionContext.id}, (error, remoteObjectPayload) => {
let remoteObject = WebInspector.RemoteObject.fromPayload(remoteObjectPayload)
remoteObject.pushNodeToFrontend((documentNodeId) => {
childFrameDocumentNodeId = documentNodeId
Modified: trunk/LayoutTests/inspector/dom/highlightSelector-expected.txt (208245 => 208246)
--- trunk/LayoutTests/inspector/dom/highlightSelector-expected.txt 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/LayoutTests/inspector/dom/highlightSelector-expected.txt 2016-11-01 21:48:31 UTC (rev 208246)
@@ -1,6 +1,7 @@
Tests for the DOM.highlightSelector command.
+PASS: Page should have a subframe.
== Running test suite: DOM.highlightSelector
-- Running test case: MainFrameTagSelector
Modified: trunk/LayoutTests/inspector/dom/highlightSelector.html (208245 => 208246)
--- trunk/LayoutTests/inspector/dom/highlightSelector.html 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/LayoutTests/inspector/dom/highlightSelector.html 2016-11-01 21:48:31 UTC (rev 208246)
@@ -5,9 +5,15 @@
<script>
function test()
{
- InspectorTest.assert(WebInspector.frameResourceManager.mainFrame.childFrames.length === 1, "Page should have a subframe.");
- const mainFrameId = WebInspector.frameResourceManager.mainFrame.id;
- const childFrameId = WebInspector.frameResourceManager.mainFrame.childFrames[0].id;
+ let suite = InspectorTest.createAsyncSuite("DOM.highlightSelector");
+
+ let mainFrame = WebInspector.frameResourceManager.mainFrame;
+ let childFrames = mainFrame.childFrameCollection.toArray();
+ InspectorTest.expectEqual(childFrames.length, 1, "Page should have a subframe.");
+
+ let mainFrameId = mainFrame.id;
+ let childFrameId = childFrames[0].id;
+
const highlightConfig = {
showInfo: true,
contentColor: {r: 255, g: 255, b: 255},
@@ -102,13 +108,10 @@
});
}
- let suite = InspectorTest.createAsyncSuite("DOM.highlightSelector");
-
- for (let testcase of tests) {
- let {name, frameId, selector, expectedElements, expectError} = testcase;
+ for (let {name, frameId, selector, expectedElements, expectError} of tests) {
suite.addTestCase({
name,
- test: (resolve, reject) => {
+ test(resolve, reject) {
InspectorTest.log("- Frame: " + displayNameForFrameId(frameId));
InspectorTest.log("- Selector: " + selector);
DOMAgent.highlightSelector(highlightConfig, selector, frameId, (error) => {
Modified: trunk/LayoutTests/inspector/model/frame-extra-scripts-expected.txt (208245 => 208246)
--- trunk/LayoutTests/inspector/model/frame-extra-scripts-expected.txt 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/LayoutTests/inspector/model/frame-extra-scripts-expected.txt 2016-11-01 21:48:31 UTC (rev 208246)
@@ -1,8 +1,8 @@
CONSOLE MESSAGE: line 1: dynamically added script element
-WebInspector.Frame.extraScripts.
+WebInspector.Frame.extraScriptCollection.
-== Running test suite: WebInspector.Frame.extraScripts
+== Running test suite: WebInspector.Frame.extraScriptCollection
-- Running test case: FrameHasNoExtraScriptsYet
PASS: Main frame should have no dynamic scripts.
Modified: trunk/LayoutTests/inspector/model/frame-extra-scripts.html (208245 => 208246)
--- trunk/LayoutTests/inspector/model/frame-extra-scripts.html 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/LayoutTests/inspector/model/frame-extra-scripts.html 2016-11-01 21:48:31 UTC (rev 208246)
@@ -11,14 +11,15 @@
function test()
{
- let suite = InspectorTest.createAsyncSuite("WebInspector.Frame.extraScripts");
+ let suite = InspectorTest.createAsyncSuite("WebInspector.Frame.extraScriptCollection");
+ let mainFrame = WebInspector.frameResourceManager.mainFrame;
+
suite.addTestCase({
name: "FrameHasNoExtraScriptsYet",
description: "No extra scripts yet.",
test(resolve, reject) {
- let mainFrame = WebInspector.frameResourceManager.mainFrame;
- InspectorTest.expectThat(mainFrame.extraScripts.length === 0, "Main frame should have no dynamic scripts.");
+ InspectorTest.expectEqual(mainFrame.extraScriptCollection.items.size, 0, "Main frame should have no dynamic scripts.");
resolve();
}
});
@@ -31,9 +32,7 @@
.then((event) => {
InspectorTest.pass("ExtraScriptAdded event fired.");
InspectorTest.expectThat(event.data.script.dynamicallyAddedScriptElement, "Script should identify as dynamic.");
-
- let mainFrame = WebInspector.frameResourceManager.mainFrame;
- InspectorTest.expectThat(mainFrame.extraScripts.length === 1, "Main frame should have 1 dynamic script.");
+ InspectorTest.expectEqual(mainFrame.extraScriptCollection.items.size, 1, "Main frame should have 1 dynamic script.");
})
.then(resolve, reject);
@@ -46,6 +45,6 @@
</script>
</head>
<body _onload_="runTest()">
-<p>WebInspector.Frame.extraScripts.</p>
+<p>WebInspector.Frame.extraScriptCollection.</p>
</body>
</html>
Modified: trunk/Source/WebInspectorUI/ChangeLog (208245 => 208246)
--- trunk/Source/WebInspectorUI/ChangeLog 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/Source/WebInspectorUI/ChangeLog 2016-11-01 21:48:31 UTC (rev 208246)
@@ -1,5 +1,27 @@
2016-11-01 Devin Rousso <dcrousso+web...@gmail.com>
+ Web Inspector: Replace sublists inside DOM-related model objects with WI.Collection
+ https://bugs.webkit.org/show_bug.cgi?id=164098
+
+ Reviewed by Timothy Hatcher.
+
+ * UserInterface/Models/DOMTree.js:
+ * UserInterface/Models/Frame.js:
+ Add support for WebInspector.Collection.
+
+ * UserInterface/Models/Script.js:
+ (WebInspector.Script):
+ * UserInterface/Views/DebuggerSidebarPanel.js:
+ (WebInspector.DebuggerSidebarPanel.prototype._addResourcesRecursivelyForFrame):
+ * UserInterface/Views/FrameTreeElement.js:
+ (WebInspector.FrameTreeElement):
+ (WebInspector.FrameTreeElement.prototype.onpopulate):
+ * UserInterface/Views/OpenResourceDialog.js:
+ (WebInspector.OpenResourceDialog.prototype._addResourcesForFrame):
+ Use new functions defined by changing to WebInspector.Collection.
+
+2016-11-01 Devin Rousso <dcrousso+web...@gmail.com>
+
Web Inspector: Fix double remove of ResourceCollection if type changes
https://bugs.webkit.org/show_bug.cgi?id=164268
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Collection.js (208245 => 208246)
--- trunk/Source/WebInspectorUI/UserInterface/Models/Collection.js 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Collection.js 2016-11-01 21:48:31 UTC (rev 208246)
@@ -112,6 +112,7 @@
WebInspector.Collection.TypeVerifier = {
Any: (object) => true,
+ ContentFlow: (object) => object instanceof WebInspector.ContentFlow,
Frame: (object) => object instanceof WebInspector.Frame,
Resource: (object) => object instanceof WebInspector.Resource,
Script: (object) => object instanceof WebInspector.Script,
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/DOMTree.js (208245 => 208246)
--- trunk/Source/WebInspectorUI/UserInterface/Models/DOMTree.js 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/DOMTree.js 2016-11-01 21:48:31 UTC (rev 208246)
@@ -33,7 +33,7 @@
this._rootDOMNode = null;
this._requestIdentifier = 0;
- this._flowMap = {};
+ this._contentFlowCollection = new WebInspector.Collection(WebInspector.Collection.TypeVerifier.ContentFlow);
this._frame.addEventListener(WebInspector.Frame.Event.PageExecutionContextChanged, this._framePageExecutionContextChanged, this);
@@ -52,21 +52,9 @@
// Public
- get frame()
- {
- return this._frame;
- }
+ get frame() { return this._frame; }
+ get contentFlowCollection() { return this._contentFlowCollection; }
- get flowMap()
- {
- return this._flowMap;
- }
-
- get flowsCount()
- {
- return Object.keys(this._flowMap).length;
- }
-
disconnect()
{
WebInspector.domTreeManager.removeEventListener(null, null, this);
@@ -263,51 +251,41 @@
return;
// Assume that all the flows have been removed.
- var deletedFlows = {};
- for (var flowId in this._flowMap)
- deletedFlows[flowId] = this._flowMap[flowId];
-
- var newFlows = [];
-
- var flows = event.data.flows;
- for (var i = 0; i < flows.length; ++i) {
- var flow = flows[i];
+ let deletedFlows = new Set(this._contentFlowCollection.items);
+ let newFlows = new Set;
+ for (let flow of event.data.flows) {
// All the flows received from WebKit are part of the same document.
console.assert(this._isContentFlowInCurrentDocument(flow));
- var flowId = flow.id;
- if (this._flowMap.hasOwnProperty(flowId)) {
+ if (this._contentFlowCollection.items.has(flow)) {
// Remove the flow name from the deleted list.
- console.assert(deletedFlows.hasOwnProperty(flowId));
- delete deletedFlows[flowId];
+ console.assert(deletedFlows.has(flow));
+ deletedFlows.delete(flow);
} else {
- this._flowMap[flowId] = flow;
- newFlows.push(flow);
+ this._contentFlowCollection.add(flow);
+ newFlows.add(flow);
}
}
- for (var flowId in deletedFlows) {
- delete this._flowMap[flowId];
- }
+ for (let flow of deletedFlows)
+ this._contentFlowCollection.remove(flow);
// Send update events to listeners.
- for (var flowId in deletedFlows)
- this.dispatchEventToListeners(WebInspector.DOMTree.Event.ContentFlowWasRemoved, {flow: deletedFlows[flowId]});
+ for (let flow of deletedFlows)
+ this.dispatchEventToListeners(WebInspector.DOMTree.Event.ContentFlowWasRemoved, {flow});
- for (var i = 0; i < newFlows.length; ++i)
- this.dispatchEventToListeners(WebInspector.DOMTree.Event.ContentFlowWasAdded, {flow: newFlows[i]});
+ for (let flow of newFlows)
+ this.dispatchEventToListeners(WebInspector.DOMTree.Event.ContentFlowWasAdded, {flow});
}
_contentFlowWasAdded(event)
{
- var flow = event.data.flow;
+ let flow = event.data.flow;
if (!this._isContentFlowInCurrentDocument(flow))
return;
- var flowId = flow.id;
- console.assert(!this._flowMap.hasOwnProperty(flowId));
- this._flowMap[flowId] = flow;
+ this._contentFlowCollection.add(flow);
this.dispatchEventToListeners(WebInspector.DOMTree.Event.ContentFlowWasAdded, {flow});
}
@@ -314,13 +292,11 @@
_contentFlowWasRemoved(event)
{
- var flow = event.data.flow;
+ let flow = event.data.flow;
if (!this._isContentFlowInCurrentDocument(flow))
return;
- var flowId = flow.id;
- console.assert(this._flowMap.hasOwnProperty(flowId));
- delete this._flowMap[flowId];
+ this._contentFlowCollection.remove(flow);
this.dispatchEventToListeners(WebInspector.DOMTree.Event.ContentFlowWasRemoved, {flow});
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Frame.js (208245 => 208246)
--- trunk/Source/WebInspectorUI/UserInterface/Models/Frame.js 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Frame.js 2016-11-01 21:48:31 UTC (rev 208246)
@@ -38,9 +38,9 @@
this._resourceCollection = new WebInspector.ResourceCollection;
this._provisionalResourceCollection = new WebInspector.ResourceCollection;
- this._extraScripts = [];
+ this._extraScriptCollection = new WebInspector.Collection(WebInspector.Collection.TypeVerifier.Script);
- this._childFrames = [];
+ this._childFrameCollection = new WebInspector.Collection(WebInspector.Collection.TypeVerifier.Frame);
this._childFrameIdentifierMap = new Map;
this._parentFrame = null;
@@ -57,6 +57,8 @@
// Public
get resourceCollection() { return this._resourceCollection; }
+ get extraScriptCollection() { return this._extraScriptCollection; }
+ get childFrameCollection() { return this._childFrameCollection; }
initialize(name, securityOrigin, loaderIdentifier, mainResource)
{
@@ -130,7 +132,7 @@
this._resourceCollection = this._provisionalResourceCollection;
this._provisionalResourceCollection = new WebInspector.ResourceCollection;
- this._extraScripts = [];
+ this._extraScriptCollection.clear();
this.clearExecutionContexts(true);
this.clearProvisionalLoad(true);
@@ -237,11 +239,6 @@
return this._parentFrame;
}
- get childFrames()
- {
- return this._childFrames;
- }
-
get domContentReadyEventTimestamp()
{
return this._domContentReadyEventTimestamp;
@@ -306,7 +303,7 @@
if (frame._parentFrame)
frame._parentFrame.removeChildFrame(frame);
- this._childFrames.push(frame);
+ this._childFrameCollection.add(frame);
this._childFrameIdentifierMap.set(frame._id, frame);
frame._parentFrame = this;
@@ -318,15 +315,14 @@
{
console.assert(frameOrFrameId);
- if (frameOrFrameId instanceof WebInspector.Frame)
- var childFrameId = frameOrFrameId._id;
- else
- var childFrameId = frameOrFrameId;
+ let childFrameId = frameOrFrameId;
+ if (childFrameId instanceof WebInspector.Frame)
+ childFrameId = frameOrFrameId._id;
// Fetch the frame by id even if we were passed a WebInspector.Frame.
- // We do this incase the WebInspector.Frame is a new object that isn't in _childFrames,
- // but the id is a valid child frame.
- var childFrame = this.childFrameForIdentifier(childFrameId);
+ // We do this incase the WebInspector.Frame is a new object that isn't
+ // in _childFrameCollection, but the id is a valid child frame.
+ let childFrame = this.childFrameForIdentifier(childFrameId);
console.assert(childFrame instanceof WebInspector.Frame);
if (!(childFrame instanceof WebInspector.Frame))
return;
@@ -333,7 +329,7 @@
console.assert(childFrame.parentFrame === this);
- this._childFrames.remove(childFrame);
+ this._childFrameCollection.remove(childFrame);
this._childFrameIdentifierMap.delete(childFrame._id);
childFrame._detachFromParentFrame();
@@ -345,10 +341,10 @@
{
this._detachFromParentFrame();
- for (let childFrame of this._childFrames)
+ for (let childFrame of this._childFrameCollection.items)
childFrame.removeAllChildFrames();
- this._childFrames = [];
+ this._childFrameCollection.clear();
this._childFrameIdentifierMap.clear();
this.dispatchEventToListeners(WebInspector.Frame.Event.AllChildFramesRemoved);
@@ -361,8 +357,8 @@
return resource;
// Check the main resources of the child frames for the requested URL.
- for (var i = 0; i < this._childFrames.length; ++i) {
- resource = this._childFrames[i].mainResource;
+ for (let childFrame of this._childFrameCollection.items) {
+ resource = childFrame.mainResource;
if (resource.url ="" url)
return resource;
}
@@ -371,8 +367,8 @@
return null;
// Recursively search resources of child frames.
- for (var i = 0; i < this._childFrames.length; ++i) {
- resource = this._childFrames[i].resourceForURL(url, true);
+ for (let childFrame of this._childFrameCollection.items) {
+ resource = childFrame.resourceForURL(url, true);
if (resource)
return resource;
}
@@ -408,13 +404,11 @@
}
}
- removeResource(resourceOrURL)
+ removeResource(resource)
{
// This does not remove provisional resources.
- var resource = this._resourceCollection.remove(resourceOrURL);
- if (!resource)
- return;
+ this._resourceCollection.remove(resource);
this._disassociateWithResource(resource);
@@ -437,14 +431,9 @@
this.dispatchEventToListeners(WebInspector.Frame.Event.AllResourcesRemoved);
}
- get extraScripts()
- {
- return this._extraScripts;
- }
-
addExtraScript(script)
{
- this._extraScripts.push(script);
+ this._extraScriptCollection.add(script);
this.dispatchEventToListeners(WebInspector.Frame.Event.ExtraScriptAdded, {script});
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Script.js (208245 => 208246)
--- trunk/Source/WebInspectorUI/UserInterface/Models/Script.js 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Script.js 2016-11-01 21:48:31 UTC (rev 208246)
@@ -52,7 +52,7 @@
this._resource = null;
this._dynamicallyAddedScriptElement = true;
documentResource.parentFrame.addExtraScript(this);
- this._dynamicallyAddedScriptElementNumber = documentResource.parentFrame.extraScripts.length;
+ this._dynamicallyAddedScriptElementNumber = documentResource.parentFrame.extraScriptCollection.items.size;
} else if (this._resource)
this._resource.associateWithScript(this);
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js (208245 => 208246)
--- trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js 2016-11-01 21:48:31 UTC (rev 208246)
@@ -422,7 +422,7 @@
for (let resource of frame.resourceCollection.items)
this._addResource(resource);
- for (var childFrame of frame.childFrames)
+ for (let childFrame of frame.childFrameCollection.items)
this._addResourcesRecursivelyForFrame(childFrame);
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FrameTreeElement.js (208245 => 208246)
--- trunk/Source/WebInspectorUI/UserInterface/Views/FrameTreeElement.js 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FrameTreeElement.js 2016-11-01 21:48:31 UTC (rev 208246)
@@ -51,19 +51,19 @@
this.registerFolderizeSettings("frames", WebInspector.UIString("Frames"),
(representedObject) => representedObject instanceof WebInspector.Frame,
- () => this.frame.childFrames.length,
+ () => this.frame.childFrameCollection.items.size,
WebInspector.FrameTreeElement
);
this.registerFolderizeSettings("flows", WebInspector.UIString("Flows"),
(representedObject) => representedObject instanceof WebInspector.ContentFlow,
- () => this.frame.domTree.flowsCount,
+ () => this.frame.domTree.contentFlowCollection.items.size,
WebInspector.ContentFlowTreeElement
);
this.registerFolderizeSettings("extra-scripts", WebInspector.UIString("Extra Scripts"),
(representedObject) => representedObject instanceof WebInspector.Script && representedObject.dynamicallyAddedScriptElement,
- () => this.frame.extraScripts.length,
+ () => this.frame.extraScriptCollection.items.size,
WebInspector.ScriptTreeElement
);
@@ -178,8 +178,8 @@
this.updateParentStatus();
this.prepareToPopulate();
- for (var i = 0; i < this._frame.childFrames.length; ++i)
- this.addChildForRepresentedObject(this._frame.childFrames[i]);
+ for (let frame of this._frame.childFrameCollection.items)
+ this.addChildForRepresentedObject(frame);
for (let resource of this._frame.resourceCollection.items)
this.addChildForRepresentedObject(resource);
@@ -191,11 +191,10 @@
this.addChildForRepresentedObject(sourceMap.resources[j]);
}
- var flowMap = this._frame.domTree.flowMap;
- for (var flowKey in flowMap)
- this.addChildForRepresentedObject(flowMap[flowKey]);
+ for (let contentFlow of this._frame.domTree.contentFlowCollection.items)
+ this.addChildForRepresentedObject(contentFlow);
- for (let extraScript of this._frame.extraScripts) {
+ for (let extraScript of this._frame.extraScriptCollection.items) {
if (extraScript.sourceURL || extraScript.sourceMappingURL)
this.addChildForRepresentedObject(extraScript);
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/OpenResourceDialog.js (208245 => 208246)
--- trunk/Source/WebInspectorUI/UserInterface/Views/OpenResourceDialog.js 2016-11-01 21:46:43 UTC (rev 208245)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/OpenResourceDialog.js 2016-11-01 21:48:31 UTC (rev 208246)
@@ -272,7 +272,7 @@
for (let resource of resources)
this._addResource(resource, suppressFilterUpdate);
- frames = frames.concat(currentFrame.childFrames);
+ frames = frames.concat(currentFrame.childFrameCollection.toArray());
}
this._updateFilter();