mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-07 04:26:32 +08:00
We initialize the globals in the `-legacy.js` files and therefore don't require the additional assignments in the Runtime itself. R=jacktfranklin@chromium.org Bug: 1127902 Fixed: 1058320 Change-Id: Id6c13d9f2b9d781bfab73957621324335d394a2b Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2410225 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
41 lines
1.2 KiB
JavaScript
41 lines
1.2 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}
|
|
*/
|
|
self.ElementsTestRunner = self.ElementsTestRunner || {};
|
|
|
|
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();
|
|
}
|
|
};
|