#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/core/dom/flat_tree_traversal.h"
#include <memory>
#include <string_view>
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/node.h"
#include "third_party/blink/renderer/core/dom/node_traversal.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/html/html_slot_element.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink {
namespace {
HeapVector<Member<Node>> GatherFromTraversalRange(auto traversal_range) {
HeapVector<Member<Node>> result;
for (Node& node : traversal_range) {
result.push_back(&node);
}
return result;
}
class FlatTreeTraversalTest : public PageTestBase { … };
void FlatTreeTraversalTest::SetupSampleHTML(std::string_view main_html,
std::string_view shadow_html,
unsigned index) { … }
void FlatTreeTraversalTest::SetupDocumentTree(std::string_view main_html) { … }
void FlatTreeTraversalTest::AttachOpenShadowRoot(
Element& shadow_host,
std::string_view shadow_inner_html) { … }
namespace {
void TestCommonAncestor(Node* expected_result,
const Node& node_a,
const Node& node_b) { … }
}
TEST_F(FlatTreeTraversalTest, childAt) { … }
TEST_F(FlatTreeTraversalTest, DescendantsOf) { … }
TEST_F(FlatTreeTraversalTest, StartsAtOrAfter) { … }
TEST_F(FlatTreeTraversalTest, ChildrenOf) { … }
TEST_F(FlatTreeTraversalTest, commonAncestor) { … }
TEST_F(FlatTreeTraversalTest, SkippingChildrenFunctions) { … }
TEST_F(FlatTreeTraversalTest, AncestorsOf) { … }
TEST_F(FlatTreeTraversalTest, InclusiveAncestorsOf) { … }
TEST_F(FlatTreeTraversalTest, lastWithin) { … }
TEST_F(FlatTreeTraversalTest, previousPostOrder) { … }
TEST_F(FlatTreeTraversalTest, nextSiblingNotInDocumentFlatTree) { … }
TEST_F(FlatTreeTraversalTest, v1Simple) { … }
TEST_F(FlatTreeTraversalTest, v1Redistribution) { … }
TEST_F(FlatTreeTraversalTest, v1SlotInDocumentTree) { … }
TEST_F(FlatTreeTraversalTest, v1FallbackContent) { … }
TEST_F(FlatTreeTraversalTest, v1FallbackContentSkippedInTraversal) { … }
TEST_F(FlatTreeTraversalTest, v1AllFallbackContent) { … }
}
}