Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/ScopedStyleResolverTest.cpp

Issue 2796653003: Move ScriptState::forWorld/ScriptState::forMainWorld (Part 2) (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "core/css/resolver/ScopedStyleResolver.h" 5 #include "core/css/resolver/ScopedStyleResolver.h"
6 6
7 #include "bindings/core/v8/V8Binding.h"
7 #include "core/dom/shadow/ShadowRoot.h" 8 #include "core/dom/shadow/ShadowRoot.h"
8 #include "core/dom/shadow/ShadowRootInit.h" 9 #include "core/dom/shadow/ShadowRootInit.h"
9 #include "core/frame/FrameView.h" 10 #include "core/frame/FrameView.h"
10 #include "core/html/HTMLElement.h" 11 #include "core/html/HTMLElement.h"
11 #include "core/testing/DummyPageHolder.h" 12 #include "core/testing/DummyPageHolder.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace blink { 15 namespace blink {
15 16
16 class ScopedStyleResolverTest : public ::testing::Test { 17 class ScopedStyleResolverTest : public ::testing::Test {
17 protected: 18 protected:
18 void SetUp() override { 19 void SetUp() override {
19 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); 20 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
20 } 21 }
21 22
22 Document& document() { return m_dummyPageHolder->document(); } 23 Document& document() { return m_dummyPageHolder->document(); }
23 StyleEngine& styleEngine() { return document().styleEngine(); } 24 StyleEngine& styleEngine() { return document().styleEngine(); }
24 ShadowRoot& attachShadow(Element& host); 25 ShadowRoot& attachShadow(Element& host);
25 26
26 private: 27 private:
27 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; 28 std::unique_ptr<DummyPageHolder> m_dummyPageHolder;
28 }; 29 };
29 30
30 ShadowRoot& ScopedStyleResolverTest::attachShadow(Element& host) { 31 ShadowRoot& ScopedStyleResolverTest::attachShadow(Element& host) {
31 ShadowRootInit init; 32 ShadowRootInit init;
32 init.setMode("open"); 33 init.setMode("open");
33 ShadowRoot* shadowRoot = host.attachShadow( 34 ShadowRoot* shadowRoot = host.attachShadow(
34 ScriptState::forMainWorld(document().frame()), init, ASSERT_NO_EXCEPTION); 35 toScriptStateForMainWorld(document().frame()), init, ASSERT_NO_EXCEPTION);
35 EXPECT_TRUE(shadowRoot); 36 EXPECT_TRUE(shadowRoot);
36 return *shadowRoot; 37 return *shadowRoot;
37 } 38 }
38 39
39 TEST_F(ScopedStyleResolverTest, HasSameStylesNullNull) { 40 TEST_F(ScopedStyleResolverTest, HasSameStylesNullNull) {
40 EXPECT_TRUE(ScopedStyleResolver::haveSameStyles(nullptr, nullptr)); 41 EXPECT_TRUE(ScopedStyleResolver::haveSameStyles(nullptr, nullptr));
41 } 42 }
42 43
43 TEST_F(ScopedStyleResolverTest, HasSameStylesNullEmpty) { 44 TEST_F(ScopedStyleResolverTest, HasSameStylesNullEmpty) {
44 ScopedStyleResolver& resolver = document().ensureScopedStyleResolver(); 45 ScopedStyleResolver& resolver = document().ensureScopedStyleResolver();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // the case when the source text is the same. The comparison will fail when 95 // the case when the source text is the same. The comparison will fail when
95 // adding an extra space to one of the sheets. 96 // adding an extra space to one of the sheets.
96 root1.setInnerHTML("<style>::slotted(#dummy){color:pink}</style>"); 97 root1.setInnerHTML("<style>::slotted(#dummy){color:pink}</style>");
97 root2.setInnerHTML("<style>::slotted(#dummy){ color:pink}</style>"); 98 root2.setInnerHTML("<style>::slotted(#dummy){ color:pink}</style>");
98 document().view()->updateAllLifecyclePhases(); 99 document().view()->updateAllLifecyclePhases();
99 EXPECT_FALSE(ScopedStyleResolver::haveSameStyles( 100 EXPECT_FALSE(ScopedStyleResolver::haveSameStyles(
100 &root1.ensureScopedStyleResolver(), &root2.ensureScopedStyleResolver())); 101 &root1.ensureScopedStyleResolver(), &root2.ensureScopedStyleResolver()));
101 } 102 }
102 103
103 } // namespace blink 104 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698