summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/html/html_object_element_test.cc
blob: 4e10fe8655f0cc657413b00c9f2416306f685764 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2018 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.

#include "third_party/blink/renderer/core/html/html_object_element.h"

#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h"

namespace blink {

class HTMLObjectElementTest : public testing::Test {
 protected:
  void SetUp() final {
    dummy_page_holder_ = DummyPageHolder::Create(IntSize(800, 600));
  }
  Document& GetDocument() { return dummy_page_holder_->GetDocument(); }

 private:
  std::unique_ptr<DummyPageHolder> dummy_page_holder_;
};

TEST_F(HTMLObjectElementTest, FallbackRecalcForReattach) {
  GetDocument().body()->SetInnerHTMLFromString(R"HTML(
    <object id='obj' data='dummy'></object>
  )HTML");

  HTMLObjectElement* object =
      ToHTMLObjectElement(GetDocument().getElementById("obj"));
  ASSERT_TRUE(object);

  Node* slot = object->GetShadowRoot()->firstChild();
  ASSERT_TRUE(slot);

  GetDocument().View()->UpdateAllLifecyclePhases();

  object->RenderFallbackContent();
  GetDocument().Lifecycle().AdvanceTo(DocumentLifecycle::kInStyleRecalc);
  GetDocument().GetStyleEngine().RecalcStyle(kForce);

  EXPECT_TRUE(IsHTMLSlotElement(slot));
  EXPECT_TRUE(object->UseFallbackContent());
  EXPECT_TRUE(object->GetNonAttachedStyle());
  EXPECT_TRUE(slot->GetNonAttachedStyle());
}

}  // namespace blink