xref: /aosp_15_r20/external/pdfium/testing/resources/javascript/xfa_specific/dump_tree.js (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1// Copyright 2020 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Note: Be sure that this file is only included inside a CDATA block,
6// otherwise the less-than comparision below will break the XML parse.
7
8function dumpTree(node, level) {
9  level = level || 0;
10  var indentation = "| ".repeat(level);
11  try {
12    app.alert(indentation + node.className);
13    var children = node.nodes;
14    if (children) {
15      for (var i = 0; i < children.length; ++i) {
16        dumpTree(children.item(i), level + 1);
17      }
18    }
19  } catch (e) {
20    app.alert(indentation + "Error: " + e);
21  }
22}
23