mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-11-06 21:29:31 +08:00
As noted in the comments, the ElementsPanel was notifying the "selected node changed" event when the document had been cleared out. The test wasn't accounting for this, and it doesn't actually seem to make sense. This change pivots the functional behavior of the panel to omit the "selected node changed" event if there aren't any nodes in the document. The previous behavior would fire the event, even if the frontend didn't have a documentElement identified in the DOM. This change pivots to skip the event in this case, because we expect to receive DOM contents. CL to re-enable flaky tests: https://chromium-review.googlesource.com/c/chromium/src/+/2095969 Bug: 1044425 Bug: 1046784 Change-Id: Ib17063d241d724b777ceda7a4c385d4784a57dab Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2096918 Reviewed-by: Jack Lynch <jalyn@microsoft.com> Reviewed-by: Jose Leal <joselea@microsoft.com> Commit-Queue: Robert Paveza <Rob.Paveza@microsoft.com>
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
// Copyright 2017 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.
|
|
|
|
/**
|
|
* @fileoverview using private properties isn't a Closure violation in tests.
|
|
* @suppress {accessControls}
|
|
*/
|
|
|
|
ElementsTestRunner.selectReloadAndDump = function(next, node) {
|
|
ElementsTestRunner.selectNode(node).then(onSelected);
|
|
let reloaded = false;
|
|
let selected = false;
|
|
|
|
function onSelected() {
|
|
TestRunner.addSniffer(Elements.ElementsPanel.prototype, '_lastSelectedNodeSelectedForTest', onReSelected);
|
|
TestRunner.reloadPage(onReloaded);
|
|
}
|
|
|
|
function onReloaded() {
|
|
reloaded = true;
|
|
maybeDumpSelectedNode();
|
|
}
|
|
|
|
function onReSelected() {
|
|
selected = true;
|
|
maybeDumpSelectedNode();
|
|
}
|
|
|
|
function maybeDumpSelectedNode() {
|
|
if (!reloaded || !selected) {
|
|
return;
|
|
}
|
|
const selectedElement = ElementsTestRunner.firstElementsTreeOutline().selectedTreeElement;
|
|
const nodeName = (selectedElement ? selectedElement.node().nodeNameInCorrectCase() : 'null');
|
|
TestRunner.addResult('Selected node: \'' + nodeName + '\'');
|
|
next();
|
|
}
|
|
};
|