Commit 6d73147b authored by Pavel Feldman's avatar Pavel Feldman Committed by Commit Bot

DevTools: "Inspect" context menu in an OOPIF doesn't expand to element on first try

Bug: 817653
Change-Id: I29fed9cfc734439aa4a97cf591dafc440232de12
Reviewed-on: https://chromium-review.googlesource.com/943938Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Pavel Feldman <pfeldman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540337}
parent abe2d76d
Tests that inspect request works for nested OOPIF elements.
Selected node has text: #text
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function() {
TestRunner.addResult(`Tests that inspect request works for nested OOPIF elements.\n`);
await TestRunner.loadModule('elements_test_runner');
await TestRunner.showPanel('elements');
// Save time on style updates.
Elements.StylesSidebarPane.prototype.update = function() {};
Elements.MetricsSidebarPane.prototype.update = function() {};
TestRunner.navigatePromise('resources/page-inspect.html');
SDK.targetManager.observeTargets({
targetAdded: async function(target) {
if (target.name() === 'Main')
return;
let complete = false;
target.pageAgent().setLifecycleEventsEnabled(true);
target.model(SDK.ResourceTreeModel).addEventListener(SDK.ResourceTreeModel.Events.LifecycleEvent, async (event) => {
if (event.data.name === 'load' && !complete) {
complete = true;
target.model(SDK.RuntimeModel).defaultExecutionContext().evaluate({
expression: 'inspect(document.body)',
includeCommandLineAPI: true
}, false, false);
UI.context.addFlavorChangeListener(SDK.DOMNode, (event) => {
const treeOutline = Elements.ElementsTreeOutline.forDOMModel(event.data.domModel());
TestRunner.addResult(`Selected node has text: ${treeOutline.selectedDOMNode().children()[0].nodeName()}`);
TestRunner.completeTest();
});
}
});
},
targetRemoved: function(target) {},
});
})();
<body>
<div>
<iframe id="iframe" src="http://devtools.oopif.test:8000/devtools/oopif/resources/inner-iframe.html"></iframe>
</div>
</body>
......@@ -120,6 +120,7 @@ SDK.DOMNode = class {
const childModel = childTarget ? childTarget.model(SDK.DOMModel) : null;
if (childModel)
childModel.requestDocument();
this._children = [];
}
if (payload.importedDocument) {
......@@ -1192,6 +1193,7 @@ SDK.DOMModel = class extends SDK.SDKModel {
if (this._frameOwnerNode) {
const oldDocument = this._frameOwnerNode._contentDocument;
this._frameOwnerNode._contentDocument = this._document;
this._frameOwnerNode._children = [];
if (this._document) {
this._document.parentNode = this._frameOwnerNode;
this.dispatchEventToListeners(SDK.DOMModel.Events.NodeInserted, this._document);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment