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

Side by Side Diff: third_party/WebKit/Source/core/dom/custom/CustomElementDescriptorTest.cpp

Issue 2023093003: Upgrade in-document custom elements when an element is defined. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ASAN failure in test helper. Created 4 years, 6 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/CustomElementDescriptor.h" 5 #include "core/dom/custom/CustomElementDescriptor.h"
6 6
7 #include "core/dom/custom/CustomElementDescriptorHash.h" 7 #include "core/dom/custom/CustomElementDescriptorHash.h"
8 #include "core/dom/custom/CustomElementTestHelpers.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 #include "wtf/HashSet.h" 10 #include "wtf/HashSet.h"
10 #include "wtf/text/AtomicString.h" 11 #include "wtf/text/AtomicString.h"
11 12
12 namespace blink { 13 namespace blink {
13 14
15 class Element;
16
14 TEST(CustomElementDescriptorTest, equal) 17 TEST(CustomElementDescriptorTest, equal)
15 { 18 {
16 CustomElementDescriptor myTypeExtension("my-button", "button"); 19 CustomElementDescriptor myTypeExtension("my-button", "button");
17 CustomElementDescriptor again("my-button", "button"); 20 CustomElementDescriptor again("my-button", "button");
18 EXPECT_TRUE(myTypeExtension == again) 21 EXPECT_TRUE(myTypeExtension == again)
19 << "two descriptors with the same name and local name should be equal"; 22 << "two descriptors with the same name and local name should be equal";
20 } 23 }
21 24
22 TEST(CustomElementDescriptorTest, notEqual) 25 TEST(CustomElementDescriptorTest, notEqual)
23 { 26 {
24 CustomElementDescriptor myTypeExtension("my-button", "button"); 27 CustomElementDescriptor myTypeExtension("my-button", "button");
25 CustomElementDescriptor collidingNewType("my-button", "my-button"); 28 CustomElementDescriptor collidingNewType("my-button", "my-button");
26 EXPECT_FALSE(myTypeExtension == collidingNewType) 29 EXPECT_FALSE(myTypeExtension == collidingNewType)
27 << "type extension should not be equal to a non-type extension"; 30 << "type extension should not be equal to a non-type extension";
28 } 31 }
29 32
30 TEST(CustomElementDescriptorTest, hashable) 33 TEST(CustomElementDescriptorTest, hashable)
31 { 34 {
32 HashSet<CustomElementDescriptor> descriptors; 35 HashSet<CustomElementDescriptor> descriptors;
33 descriptors.add(CustomElementDescriptor("foo-bar", "foo-bar")); 36 descriptors.add(CustomElementDescriptor("foo-bar", "foo-bar"));
34 EXPECT_TRUE( 37 EXPECT_TRUE(
35 descriptors.contains(CustomElementDescriptor("foo-bar", "foo-bar"))) 38 descriptors.contains(CustomElementDescriptor("foo-bar", "foo-bar")))
36 << "the identical descriptor should be found in the hash set"; 39 << "the identical descriptor should be found in the hash set";
37 EXPECT_FALSE(descriptors.contains(CustomElementDescriptor( 40 EXPECT_FALSE(descriptors.contains(CustomElementDescriptor(
38 "bad-poetry", 41 "bad-poetry",
39 "blockquote"))) 42 "blockquote")))
40 << "an unrelated descriptor should not be found in the hash set"; 43 << "an unrelated descriptor should not be found in the hash set";
41 } 44 }
42 45
46 TEST(CustomElementDescriptorTest, matches_autonomous)
47 {
48 CustomElementDescriptor descriptor("a-b", "a-b");
49 Element* element = CreateElement("a-b");
50 EXPECT_TRUE(descriptor.matches(*element));
51 }
52
53 TEST(CustomElementDescriptorTest,
54 matches_autonomous_shouldNotMatchCustomizedBuiltInElement)
55 {
56 CustomElementDescriptor descriptor("a-b", "a-b");
57 Element* element = CreateElement("futuretag").withIsAttribute("a-b");
58 EXPECT_FALSE(descriptor.matches(*element));
59 }
60
61 TEST(CustomElementDescriptorTest, matches_customizedBuiltIn)
62 {
63 CustomElementDescriptor descriptor("a-b", "button");
64 Element* element = CreateElement("button").withIsAttribute("a-b");
65 EXPECT_TRUE(descriptor.matches(*element));
66 }
67
68 TEST(CustomElementDescriptorTest,
69 matches_customizedBuiltIn_shouldNotMatchAutonomousElement)
70 {
71 CustomElementDescriptor descriptor("a-b", "button");
72 Element* element = CreateElement("a-b");
73 EXPECT_FALSE(descriptor.matches(*element));
74 }
75
76 TEST(CustomElementDescriptorTest, matches_elementNotInHTMLNamespaceDoesNotMatch)
77 {
78 CustomElementDescriptor descriptor("a-b", "a-b");
79 Element* element = CreateElement("a-b").inNamespace("data:text/plain,foo");
80 EXPECT_FALSE(descriptor.matches(*element));
81 }
82
43 } // namespace blink 83 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698