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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/custom/CustomElementDescriptorTest.cpp
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElementDescriptorTest.cpp b/third_party/WebKit/Source/core/dom/custom/CustomElementDescriptorTest.cpp
index d077ad4f8f3e50a6cb64d0a18b650a7367815d12..6113a519ce079ba81d9a1c764b34855b11c2a266 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElementDescriptorTest.cpp
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElementDescriptorTest.cpp
@@ -5,12 +5,15 @@
#include "core/dom/custom/CustomElementDescriptor.h"
#include "core/dom/custom/CustomElementDescriptorHash.h"
+#include "core/dom/custom/CustomElementTestHelpers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "wtf/HashSet.h"
#include "wtf/text/AtomicString.h"
namespace blink {
+class Element;
+
TEST(CustomElementDescriptorTest, equal)
{
CustomElementDescriptor myTypeExtension("my-button", "button");
@@ -40,4 +43,41 @@ TEST(CustomElementDescriptorTest, hashable)
<< "an unrelated descriptor should not be found in the hash set";
}
+TEST(CustomElementDescriptorTest, matches_autonomous)
+{
+ CustomElementDescriptor descriptor("a-b", "a-b");
+ Element* element = CreateElement("a-b");
+ EXPECT_TRUE(descriptor.matches(*element));
+}
+
+TEST(CustomElementDescriptorTest,
+ matches_autonomous_shouldNotMatchCustomizedBuiltInElement)
+{
+ CustomElementDescriptor descriptor("a-b", "a-b");
+ Element* element = CreateElement("futuretag").withIsAttribute("a-b");
+ EXPECT_FALSE(descriptor.matches(*element));
+}
+
+TEST(CustomElementDescriptorTest, matches_customizedBuiltIn)
+{
+ CustomElementDescriptor descriptor("a-b", "button");
+ Element* element = CreateElement("button").withIsAttribute("a-b");
+ EXPECT_TRUE(descriptor.matches(*element));
+}
+
+TEST(CustomElementDescriptorTest,
+ matches_customizedBuiltIn_shouldNotMatchAutonomousElement)
+{
+ CustomElementDescriptor descriptor("a-b", "button");
+ Element* element = CreateElement("a-b");
+ EXPECT_FALSE(descriptor.matches(*element));
+}
+
+TEST(CustomElementDescriptorTest, matches_elementNotInHTMLNamespaceDoesNotMatch)
+{
+ CustomElementDescriptor descriptor("a-b", "a-b");
+ Element* element = CreateElement("a-b").inNamespace("data:text/plain,foo");
+ EXPECT_FALSE(descriptor.matches(*element));
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698