| <!doctype html> |
| <html> |
| <head> |
| <script src="../resources/inspector-test.js"></script> |
| <script> |
| function test() |
| { |
| let suite = InspectorTest.createAsyncSuite("DOM.DisconnectTreeOnMainResourceChange"); |
| |
| suite.addTestCase({ |
| name: "CheckLazyInitializationOfDOMTree", |
| description: "Check that DOMTree instances are created lazily.", |
| test(resolve, reject) { |
| let instances = WebInspector.domTreeManager.retainedObjectsWithPrototype(WebInspector.DOMTree); |
| InspectorTest.expectThat(instances.size === 0, "There should not be a DOMTree listening to DOMTreeManager events initially."); |
| InspectorTest.log("DOMTree instance count: " + instances.size); |
| resolve(); |
| } |
| }); |
| |
| suite.addTestCase({ |
| name: "CheckDOMTreeCountAfterUsingGetter", |
| description: "Check that the count of connected DOMTrees is correct after initializing them.", |
| test(resolve, reject) { |
| let mainFrame = WebInspector.frameResourceManager.mainFrame; |
| mainFrame.domTree; // Force creation of the root DOM tree. |
| |
| let instances = WebInspector.domTreeManager.retainedObjectsWithPrototype(WebInspector.DOMTree); |
| InspectorTest.expectThat(instances.size === 1, "There should be a one DOMTree listening to DOMTreeManager events after creation."); |
| InspectorTest.log("DOMTree instance count: " + instances.size); |
| |
| // Force creation of child DOM trees. |
| 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); |
| |
| resolve(); |
| } |
| }); |
| |
| suite.addTestCase({ |
| name: "CheckDOMTreeCountAfterReloading", |
| description: "Check that the count of connected DOMTrees is correct after a reload.", |
| test(resolve, reject) { |
| WebInspector.Frame.awaitEvent(WebInspector.Frame.Event.MainResourceDidChange) |
| .then((event) => { |
| let instances = WebInspector.domTreeManager.retainedObjectsWithPrototype(WebInspector.DOMTree); |
| InspectorTest.expectThat(instances.size === 0, "There should not be any DOMTrees listening to DOMTreeManager events after a main frame navigation."); |
| InspectorTest.log("DOMTree instance count: " + instances.size); |
| }) |
| .then(resolve, reject); |
| |
| InspectorTest.reloadPage(); |
| } |
| }); |
| |
| suite.runTestCasesAndFinish(); |
| } |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <p>Testing that DOMTrees are not retained by DOMTreeManager across main frame navigations.</p> |
| <iframe src="resources/nested-frame-2-deep.html"/> |
| </body> |
| </html> |