| OLD | NEW |
| 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/CustomElement.h" | 5 #include "core/dom/custom/CustomElement.h" |
| 6 | 6 |
| 7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
| 8 #include "core/SVGNames.h" | 8 #include "core/SVGNames.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/html/HTMLElement.h" | 10 #include "core/html/HTMLElement.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 {false, "a-A"}, | 66 {false, "a-A"}, |
| 67 {false, "a-Z"}, | 67 {false, "a-Z"}, |
| 68 }; | 68 }; |
| 69 for (auto test : tests) | 69 for (auto test : tests) |
| 70 testIsPotentialCustomElementName(test.str, test.expected); | 70 testIsPotentialCustomElementName(test.str, test.expected); |
| 71 } | 71 } |
| 72 | 72 |
| 73 TEST(CustomElementTest, TestIsValidNamePotentialCustomElementNameChar) { | 73 TEST(CustomElementTest, TestIsValidNamePotentialCustomElementNameChar) { |
| 74 struct { | 74 struct { |
| 75 UChar32 from, to; | 75 UChar32 from, to; |
| 76 } ranges[] = | 76 } ranges[] = { |
| 77 { | 77 // "-" | "." need to merge to test -1/+1. |
| 78 {'-', '.'}, // "-" | "." need to merge to test -1/+1. | 78 {'-', '.'}, |
| 79 {'0', '9'}, {'_', '_'}, {'a', 'z'}, | 79 {'0', '9'}, |
| 80 {0xB7, 0xB7}, {0xC0, 0xD6}, {0xD8, 0xF6}, | 80 {'_', '_'}, |
| 81 {0xF8, 0x37D}, // [#xF8-#x2FF] | [#x300-#x37D] need to merge to test
-1/+1. | 81 {'a', 'z'}, |
| 82 {0x37F, 0x1FFF}, {0x200C, 0x200D}, {0x203F, 0x2040}, | 82 {0xB7, 0xB7}, |
| 83 {0x2070, 0x218F}, {0x2C00, 0x2FEF}, {0x3001, 0xD7FF}, | 83 {0xC0, 0xD6}, |
| 84 {0xF900, 0xFDCF}, {0xFDF0, 0xFFFD}, {0x10000, 0xEFFFF}, | 84 {0xD8, 0xF6}, |
| 85 }; | 85 // [#xF8-#x2FF] | [#x300-#x37D] need to merge to test -1/+1. |
| 86 {0xF8, 0x37D}, |
| 87 {0x37F, 0x1FFF}, |
| 88 {0x200C, 0x200D}, |
| 89 {0x203F, 0x2040}, |
| 90 {0x2070, 0x218F}, |
| 91 {0x2C00, 0x2FEF}, |
| 92 {0x3001, 0xD7FF}, |
| 93 {0xF900, 0xFDCF}, |
| 94 {0xFDF0, 0xFFFD}, |
| 95 {0x10000, 0xEFFFF}, |
| 96 }; |
| 86 for (auto range : ranges) { | 97 for (auto range : ranges) { |
| 87 testIsPotentialCustomElementNameChar(range.from - 1, false); | 98 testIsPotentialCustomElementNameChar(range.from - 1, false); |
| 88 for (UChar32 c = range.from; c <= range.to; ++c) | 99 for (UChar32 c = range.from; c <= range.to; ++c) |
| 89 testIsPotentialCustomElementNameChar(c, true); | 100 testIsPotentialCustomElementNameChar(c, true); |
| 90 testIsPotentialCustomElementNameChar(range.to + 1, false); | 101 testIsPotentialCustomElementNameChar(range.to + 1, false); |
| 91 } | 102 } |
| 92 } | 103 } |
| 93 | 104 |
| 94 TEST(CustomElementTest, TestIsValidNamePotentialCustomElementName8BitChar) { | 105 TEST(CustomElementTest, TestIsValidNamePotentialCustomElementName8BitChar) { |
| 95 // isPotentialCustomElementName8BitChar must match | 106 // isPotentialCustomElementName8BitChar must match |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 element = document.createElementNS(SVGNames::svgNamespaceURI, data.name, | 195 element = document.createElementNS(SVGNames::svgNamespaceURI, data.name, |
| 185 ASSERT_NO_EXCEPTION); | 196 ASSERT_NO_EXCEPTION); |
| 186 EXPECT_EQ(CustomElementState::Uncustomized, | 197 EXPECT_EQ(CustomElementState::Uncustomized, |
| 187 element->getCustomElementState()) | 198 element->getCustomElementState()) |
| 188 << data.name; | 199 << data.name; |
| 189 EXPECT_EQ(data.v0state, element->getV0CustomElementState()) << data.name; | 200 EXPECT_EQ(data.v0state, element->getV0CustomElementState()) << data.name; |
| 190 } | 201 } |
| 191 } | 202 } |
| 192 | 203 |
| 193 } // namespace blink | 204 } // namespace blink |
| OLD | NEW |