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

Side by Side Diff: third_party/WebKit/Source/core/dom/custom/CustomElementRegistryTest.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/dom/custom/CustomElementRegistry.h" 5 #include "core/dom/custom/CustomElementRegistry.h"
6 6
7 #include <memory>
7 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/V8Binding.h"
8 #include "core/dom/Document.h" 10 #include "core/dom/Document.h"
9 #include "core/dom/Element.h" 11 #include "core/dom/Element.h"
10 #include "core/dom/ElementDefinitionOptions.h" 12 #include "core/dom/ElementDefinitionOptions.h"
11 #include "core/dom/custom/CEReactionsScope.h" 13 #include "core/dom/custom/CEReactionsScope.h"
12 #include "core/dom/custom/CustomElementDefinition.h" 14 #include "core/dom/custom/CustomElementDefinition.h"
13 #include "core/dom/custom/CustomElementDefinitionBuilder.h" 15 #include "core/dom/custom/CustomElementDefinitionBuilder.h"
14 #include "core/dom/custom/CustomElementDescriptor.h" 16 #include "core/dom/custom/CustomElementDescriptor.h"
15 #include "core/dom/custom/CustomElementTestHelpers.h" 17 #include "core/dom/custom/CustomElementTestHelpers.h"
16 #include "core/dom/shadow/ShadowRoot.h" 18 #include "core/dom/shadow/ShadowRoot.h"
17 #include "core/dom/shadow/ShadowRootInit.h" 19 #include "core/dom/shadow/ShadowRootInit.h"
18 #include "core/testing/DummyPageHolder.h" 20 #include "core/testing/DummyPageHolder.h"
19 #include "platform/ScriptForbiddenScope.h" 21 #include "platform/ScriptForbiddenScope.h"
20 #include "platform/heap/Handle.h" 22 #include "platform/heap/Handle.h"
21 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
22 #include "wtf/text/AtomicString.h" 24 #include "wtf/text/AtomicString.h"
23 #include <memory>
24 25
25 namespace blink { 26 namespace blink {
26 27
27 class CustomElementRegistryTest : public ::testing::Test { 28 class CustomElementRegistryTest : public ::testing::Test {
28 protected: 29 protected:
29 void SetUp() { 30 void SetUp() {
30 m_page.reset(DummyPageHolder::create(IntSize(1, 1)).release()); 31 m_page.reset(DummyPageHolder::create(IntSize(1, 1)).release());
31 } 32 }
32 33
33 void TearDown() { m_page = nullptr; } 34 void TearDown() { m_page = nullptr; }
34 35
35 Document& document() { return m_page->document(); } 36 Document& document() { return m_page->document(); }
36 37
37 CustomElementRegistry& registry() { 38 CustomElementRegistry& registry() {
38 return *m_page->frame().domWindow()->customElements(); 39 return *m_page->frame().domWindow()->customElements();
39 } 40 }
40 41
41 ScriptState* scriptState() { 42 ScriptState* scriptState() {
42 return ScriptState::forMainWorld(&m_page->frame()); 43 return toScriptStateForMainWorld(&m_page->frame());
43 } 44 }
44 45
45 void collectCandidates(const CustomElementDescriptor& desc, 46 void collectCandidates(const CustomElementDescriptor& desc,
46 HeapVector<Member<Element>>* elements) { 47 HeapVector<Member<Element>>* elements) {
47 registry().collectCandidates(desc, elements); 48 registry().collectCandidates(desc, elements);
48 } 49 }
49 50
50 ShadowRoot* attachShadowTo(Element* element) { 51 ShadowRoot* attachShadowTo(Element* element) {
51 NonThrowableExceptionState noExceptions; 52 NonThrowableExceptionState noExceptions;
52 ShadowRootInit shadowRootInit; 53 ShadowRootInit shadowRootInit;
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 EXPECT_EQ(definitionB, definition); 439 EXPECT_EQ(definitionB, definition);
439 // look up undefined customized built-in element 440 // look up undefined customized built-in element
440 definition = registry().definitionFor(CustomElementDescriptor("a-a", "div")); 441 definition = registry().definitionFor(CustomElementDescriptor("a-a", "div"));
441 EXPECT_EQ(nullptr, definition) << "a-a, div should not be registered"; 442 EXPECT_EQ(nullptr, definition) << "a-a, div should not be registered";
442 } 443 }
443 444
444 // TODO(dominicc): Add tests which adjust the "is" attribute when type 445 // TODO(dominicc): Add tests which adjust the "is" attribute when type
445 // extensions are implemented. 446 // extensions are implemented.
446 447
447 } // namespace blink 448 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698