OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/layout/LayoutTestHelper.h" | 6 #include "core/layout/LayoutTestHelper.h" |
7 | 7 |
8 #include "core/frame/FrameHost.h" | 8 #include "core/frame/FrameHost.h" |
9 #include "core/html/HTMLIFrameElement.h" | |
10 #include "platform/graphics/test/FakeGraphicsLayerFactory.h" | 9 #include "platform/graphics/test/FakeGraphicsLayerFactory.h" |
11 | 10 |
12 namespace blink { | 11 namespace blink { |
13 | 12 |
14 namespace { | 13 namespace { |
15 | 14 |
16 class FakeChromeClient : public EmptyChromeClient { | 15 class FakeChromeClient : public EmptyChromeClient { |
17 public: | 16 public: |
18 static PassOwnPtrWillBeRawPtr<FakeChromeClient> create() { return adoptPtrWi
llBeNoop(new FakeChromeClient); } | 17 static PassOwnPtrWillBeRawPtr<FakeChromeClient> create() { return adoptPtrWi
llBeNoop(new FakeChromeClient); } |
19 | 18 |
(...skipping 16 matching lines...) Expand all Loading... |
36 | 35 |
37 void RenderingTest::SetUp() | 36 void RenderingTest::SetUp() |
38 { | 37 { |
39 // This ensures that the minimal DOM tree gets attached | 38 // This ensures that the minimal DOM tree gets attached |
40 // correctly for tests that don't call setBodyInnerHTML. | 39 // correctly for tests that don't call setBodyInnerHTML. |
41 document().view()->updateAllLifecyclePhases(); | 40 document().view()->updateAllLifecyclePhases(); |
42 } | 41 } |
43 | 42 |
44 void RenderingTest::TearDown() | 43 void RenderingTest::TearDown() |
45 { | 44 { |
46 if (m_subframe) { | |
47 m_subframe->detach(FrameDetachType::Remove); | |
48 static_cast<SingleChildFrameLoaderClient*>(document().frame()->client())
->setChild(nullptr); | |
49 document().frame()->host()->decrementSubframeCount(); | |
50 } | |
51 | |
52 // We need to destroy most of the Blink structure here because derived tests
may restore | 45 // We need to destroy most of the Blink structure here because derived tests
may restore |
53 // RuntimeEnabledFeatures setting during teardown, which happens before our
destructor | 46 // RuntimeEnabledFeatures setting during teardown, which happens before our
destructor |
54 // getting invoked, breaking the assumption that REF can't change during Bli
nk lifetime. | 47 // getting invoked, breaking the assumption that REF can't change during Bli
nk lifetime. |
55 m_pageHolder = nullptr; | 48 m_pageHolder = nullptr; |
56 } | 49 } |
57 | 50 |
58 Document& RenderingTest::setupChildIframe(const AtomicString& iframeElementId, c
onst String& htmlContentOfIframe) | |
59 { | |
60 | |
61 HTMLIFrameElement& iframe = *toHTMLIFrameElement(document().getElementById(i
frameElementId)); | |
62 m_frameLoaderClient = FrameLoaderClientWithParent::create(document().frame()
); | |
63 m_subframe = LocalFrame::create(m_frameLoaderClient.get(), document().frame(
)->host(), &iframe); | |
64 m_subframe->setView(FrameView::create(m_subframe.get(), IntSize(500, 500))); | |
65 m_subframe->init(); | |
66 static_cast<SingleChildFrameLoaderClient*>(document().frame()->client())->se
tChild(m_subframe.get()); | |
67 document().frame()->host()->incrementSubframeCount(); | |
68 Document& frameDocument = *iframe.contentDocument(); | |
69 | |
70 frameDocument.setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); | |
71 frameDocument.body()->setInnerHTML(htmlContentOfIframe, ASSERT_NO_EXCEPTION)
; | |
72 return frameDocument; | |
73 } | |
74 | |
75 } // namespace blink | 51 } // namespace blink |
OLD | NEW |