From a6176f674f7c1612cd16eac48e06c8d49be0c6d0 Mon Sep 17 00:00:00 2001 From: xiaoyu3x Date: Mon, 19 Mar 2018 16:35:22 +0800 Subject: [PATCH] Add HTMLButtonElement interface to custom element test --- .../reactions/HTMLButtonElement.html | 112 ++++++++++++++++++ tests/custom-elements/reactions/reactions.js | 24 ++-- 2 files changed, 129 insertions(+), 7 deletions(-) create mode 100644 tests/custom-elements/reactions/HTMLButtonElement.html diff --git a/tests/custom-elements/reactions/HTMLButtonElement.html b/tests/custom-elements/reactions/HTMLButtonElement.html new file mode 100644 index 0000000..974ff8d --- /dev/null +++ b/tests/custom-elements/reactions/HTMLButtonElement.html @@ -0,0 +1,112 @@ + +Custom Elements: CEReactions on HTMLButtonElement interface + + + + + + + + + + diff --git a/tests/custom-elements/reactions/reactions.js b/tests/custom-elements/reactions/reactions.js index 43ce4fd..8a4a142 100644 --- a/tests/custom-elements/reactions/reactions.js +++ b/tests/custom-elements/reactions/reactions.js @@ -126,10 +126,15 @@ function testCloner(testFunction, name) { }, name + ' must enqueue an attributeChanged reaction when cloning an element only for observed attributes'); } -function testReflectAttributeWithContentValues(jsAttributeName, contentAttributeName, validValue1, contentValue1, validValue2, contentValue2, name) { +function testReflectAttributeWithContentValues(jsAttributeName, contentAttributeName, validValue1, contentValue1, validValue2, contentValue2, name, elementName, interfaceName) { test(function () { - var element = define_new_custom_element([contentAttributeName]); - var instance = document.createElement(element.name); + if(elementName === undefined) { + var element = define_new_custom_element([contentAttributeName]); + var instance = document.createElement(element.name); + } else { + var element = define_build_in_custom_element([contentAttributeName], interfaceName, elementName); + var instance = document.createElement(elementName, { is: element.name}); + } assert_array_equals(element.takeLog().types(), ['constructed']); instance[jsAttributeName] = validValue1; var logEntries = element.takeLog(); @@ -139,8 +144,13 @@ function testReflectAttributeWithContentValues(jsAttributeName, contentAttribute }, name + ' must enqueue an attributeChanged reaction when adding ' + contentAttributeName + ' content attribute'); test(function () { - var element = define_new_custom_element([contentAttributeName]); - var instance = document.createElement(element.name); + if(elementName === undefined) { + var element = define_new_custom_element([contentAttributeName]); + var instance = document.createElement(element.name); + } else { + var element = define_build_in_custom_element([contentAttributeName], interfaceName, elementName); + var instance = document.createElement(elementName, { is: element.name}); + } instance[jsAttributeName] = validValue1; assert_array_equals(element.takeLog().types(), ['constructed', 'attributeChanged']); instance[jsAttributeName] = validValue2; @@ -150,8 +160,8 @@ function testReflectAttributeWithContentValues(jsAttributeName, contentAttribute }, name + ' must enqueue an attributeChanged reaction when replacing an existing attribute'); } -function testReflectAttribute(jsAttributeName, contentAttributeName, validValue1, validValue2, name) { - testReflectAttributeWithContentValues(jsAttributeName, contentAttributeName, validValue1, validValue1, validValue2, validValue2, name); +function testReflectAttribute(jsAttributeName, contentAttributeName, validValue1, validValue2, name, elementName, interfaceName) { + testReflectAttributeWithContentValues(jsAttributeName, contentAttributeName, validValue1, validValue1, validValue2, validValue2, name, elementName, interfaceName); } function testReflectBooleanAttribute(jsAttributeName, contentAttributeName, name) {