Files
react-native-devtools-frontend/front_end/elements_test_runner/ElementsPanelShadowSelectionOnRefreshTestRunner.js
T
Tim van der Lippe 1d6e57a0e3 Always add braces to single-line if-statements
The Chromium/Google style guides does not enforce curly braces for
single-line if-statements, but does strongly recommend doing so. Adding
braces will improve code readability, by visually separating code
blocks. This will also prevent issues where accidental additions are
pushed to the "else"-clause instead of in the if-block.

This CL also updates the presubmit `eslint` to run the fix with the
correct configuration. It will now fix all issues it can fix.

Change-Id: I4b616f21a99393f168dec743c0bcbdc7f5db04a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1821526
Commit-Queue: Tim Van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Jeff Fisher <jeffish@microsoft.com>
Cr-Original-Commit-Position: refs/heads/master@{#701070}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 7e0bdbe2d7f9fc2386bfaefda3cc29c66ccc18f9
2019-09-30 11:55:34 +00:00

41 lines
1.1 KiB
JavaScript

// Copyright 2017 The Chromium Authors. All
// 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.reloadPage(onReloaded);
TestRunner.addSniffer(Elements.ElementsPanel.prototype, '_lastSelectedNodeSelectedForTest', onReSelected);
}
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();
}
};