예제 #1
0
TEST(TreeScopeTest, CommonAncestorOfTreesAtDifferentDepths) {
  //  document
  //    / \    : Common ancestor is document.
  //   Y   B
  //  /
  // A

  Document* document = Document::create();
  Element* html = document->createElement("html", StringOrDictionary());
  document->appendChild(html);
  Element* head = document->createElement("head", StringOrDictionary());
  html->appendChild(head);
  Element* body = document->createElement("body", StringOrDictionary());
  html->appendChild(body);

  ShadowRoot* shadowRootY =
      head->createShadowRootInternal(ShadowRootType::V0, ASSERT_NO_EXCEPTION);
  ShadowRoot* shadowRootB =
      body->createShadowRootInternal(ShadowRootType::V0, ASSERT_NO_EXCEPTION);

  Element* divInY = document->createElement("div", StringOrDictionary());
  shadowRootY->appendChild(divInY);
  ShadowRoot* shadowRootA =
      divInY->createShadowRootInternal(ShadowRootType::V0, ASSERT_NO_EXCEPTION);

  EXPECT_EQ(document, shadowRootA->commonAncestorTreeScope(*shadowRootB));
  EXPECT_EQ(document, shadowRootB->commonAncestorTreeScope(*shadowRootA));
}
예제 #2
0
TEST(TreeScopeTest, CommonAncestorOfSameTrees) {
  Document* document = Document::create();
  EXPECT_EQ(document, document->commonAncestorTreeScope(*document));

  Element* html = document->createElement("html", StringOrDictionary());
  document->appendChild(html);
  ShadowRoot* shadowRoot =
      html->createShadowRootInternal(ShadowRootType::V0, ASSERT_NO_EXCEPTION);
  EXPECT_EQ(shadowRoot, shadowRoot->commonAncestorTreeScope(*shadowRoot));
}
예제 #3
0
TEST(TreeScopeTest, CommonAncestorOfSiblingTrees)
{
    //  document
    //   /    \  : Common ancestor is document.
    //  A      B

    Document* document = Document::create();
    Element* html = document->createElement("html", nullAtom, ASSERT_NO_EXCEPTION);
    document->appendChild(html, ASSERT_NO_EXCEPTION);
    Element* head = document->createElement("head", nullAtom, ASSERT_NO_EXCEPTION);
    html->appendChild(head);
    Element* body = document->createElement("body", nullAtom, ASSERT_NO_EXCEPTION);
    html->appendChild(body);

    ShadowRoot* shadowRootA = head->createShadowRootInternal(ShadowRootType::V0, ASSERT_NO_EXCEPTION);
    ShadowRoot* shadowRootB = body->createShadowRootInternal(ShadowRootType::V0, ASSERT_NO_EXCEPTION);

    EXPECT_EQ(document, shadowRootA->commonAncestorTreeScope(*shadowRootB));
    EXPECT_EQ(document, shadowRootB->commonAncestorTreeScope(*shadowRootA));
}
예제 #4
0
TEST(TreeScopeTest, CommonAncestorOfInclusiveTrees)
{
    //  document
    //     |      : Common ancestor is document.
    // shadowRoot

    Document* document = Document::create();
    Element* html = document->createElement("html", nullAtom, ASSERT_NO_EXCEPTION);
    document->appendChild(html, ASSERT_NO_EXCEPTION);
    ShadowRoot* shadowRoot = html->createShadowRootInternal(ShadowRootType::V0, ASSERT_NO_EXCEPTION);

    EXPECT_EQ(document, document->commonAncestorTreeScope(*shadowRoot));
    EXPECT_EQ(document, shadowRoot->commonAncestorTreeScope(*document));
}