Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions tests/custom-elements/reactions/HTMLAreaElement.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<title>Custom Elements: CEReactions on Element interface</title>
<meta name="author" title="zhang xiaoyux" href="mailto:[email protected]">
<meta name="assert" content=" alt, coords, shape, target, download, ping, rel, referrerPolicy of HTMLAreaElement interface must have CEReactions">
<meta name="help" content="https://html.spec.whatwg.org/#the-area-element">
<meta name="help" content="https://w3c.github.io/DOM-Parsing/">
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="./custom-elements-helpers.js"></script>
<script src="./reactions.js"></script>
</head>
<body>
<script>

testReflectAttributeWithContentValuesArea('shape', 'shape', 'circ', 'rect', 'shape on HTMLAreaElement');
testReflectAttributeWithContentValuesArea('href', 'href', 'https://www.intel.cn', 'https://html.spec.whatwg.org', 'href on HTMLAreaElement');
testReflectAttributeWithPreContentValuesArea('href', 'https://www.intel.cn', 'alt', 'sun', 'earth', 'alt on HTMLAreaElement');
testReflectAttributeWithPreContentValuesArea('href', 'https://www.intel.cn', 'target', '_blank', '_top', 'target on HTMLAreaElement');
testReflectAttributeWithPreContentValuesArea('href', 'https://www.intel.cn', 'download', 'a', 'b', 'download on HTMLAreaElement');
testReflectAttributeWithPreContentValuesArea('href', 'https://www.intel.cn', 'ping', 'https://www.intel.cn/track', 'https://www.intel.cn/block', 'ping on HTMLAreaElement');
testReflectAttributeWithPreContentValuesArea('href', 'https://www.intel.cn', 'rel', 'noreferrer', 'noopener', 'rel on HTMLAreaElement');
testReflectAttributeWithPreContentValuesArea('href', 'https://www.intel.cn', 'referrerPolicy', 'never', 'origin', 'referrerPolicy on HTMLAreaElement');

</script>
</body>
</html>
21 changes: 21 additions & 0 deletions tests/custom-elements/reactions/HTMLDivElement.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<title>Custom Elements: CEReactions on Element interface</title>
<meta name="author" title="zhang xiaoyux" href="mailto:[email protected]">
<meta name="assert" content=" align of HTMLButtonElement interface must have CEReactions">
<meta name="help" content="https://html.spec.whatwg.org/multipage/grouping-content.html#htmldivelement">
<meta name="help" content="https://w3c.github.io/DOM-Parsing/">
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="./custom-elements-helpers.js"></script>
<script src="./reactions.js"></script>
</head>
<body>
<script>

testReflectAttributeWithContentValuesNew('align', 'align','center','right','align on HTMLDivElement');

</script>
</body>
</html>
102 changes: 102 additions & 0 deletions tests/custom-elements/reactions/reactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,3 +359,105 @@ function test_mutating_style_property_priority(testFunction, name) {
assert_array_equals(element.takeLog().types(), []);
}, name + ' must enqueue an attributeChanged reaction when it makes a property important but the style attribute is not observed');
}

function testReflectAttributeWithContentValuesNew(jsAttributeName, contentAttributeName, validValue1, validValue2, name) {
test(function () {
let element = define_new_custom_element([contentAttributeName]);
let instance = document.createElement(element.name);
assert_array_equals(element.takeLog().types(), ['constructed']);
instance.setAttribute(jsAttributeName,validValue1);
//instance[jsAttributeName] = validValue1;
let logEntries = element.takeLog();
//alert(logEntries.types());
assert_array_equals(logEntries.types(), ['attributeChanged']);
assert_attribute_log_entry(logEntries.last(), {name: contentAttributeName, oldValue: null, newValue: validValue1, namespace: null});
}, name + ' must enqueue an attributeChanged reaction when adding ' + contentAttributeName + ' content attribute');

test(function () {
let element = define_new_custom_element([contentAttributeName]);
let instance = document.createElement(element.name);
instance.setAttribute(jsAttributeName,validValue1);
//instance[jsAttributeName] = validValue1;
assert_array_equals(element.takeLog().types(), ['constructed', 'attributeChanged']);
instance.setAttribute(jsAttributeName,validValue2);
//instance[jsAttributeName] = validValue2;
let logEntries = element.takeLog();
assert_array_equals(logEntries.types(), ['attributeChanged']);
assert_attribute_log_entry(logEntries.last(), {name: contentAttributeName, oldValue: validValue1, newValue: validValue2, namespace: null});
}, name + ' must enqueue an attributeChanged reaction when replacing an existing attribute');
}

function testReflectAttributeWithContentValuesArea(jsAttributeName, contentAttributeName, validValue1, validValue2, name) {
let container = document.createElement('map');
document.body.appendChild(container);

test(function () {
let element = define_new_custom_element([contentAttributeName]);
let instance = document.createElement(element.name);
assert_array_equals(element.takeLog().types(),['constructed']);
container.appendChild(instance);
assert_array_equals(element.takeLog().types(), ['connected']);
}, name + ' must enqueue a connected reaction');

test(function () {
let element = define_new_custom_element([contentAttributeName]);
let instance = document.createElement(element.name);
assert_array_equals(element.takeLog().types(),['constructed']);
container.appendChild(instance);
assert_array_equals(element.takeLog().types(), ['connected']);
instance.setAttribute(jsAttributeName,validValue1);
//instance[jsAttributeName] = validValue1;
let logEntries = element.takeLog();
assert_array_equals(logEntries.types(), ['attributeChanged']);
assert_attribute_log_entry(logEntries.last(), {name: contentAttributeName, oldValue: null, newValue: validValue1, namespace: null});
}, name + ' must enqueue an attributeChanged reaction when adding ' + contentAttributeName + ' content attribute');

test(function () {
let element = define_new_custom_element([contentAttributeName]);
let instance = document.createElement(element.name);
container.appendChild(instance);
instance.setAttribute(jsAttributeName,validValue1);
//instance[jsAttributeName] = validValue1;
assert_array_equals(element.takeLog().types(), ['constructed', 'connected', 'attributeChanged']);
instance.setAttribute(jsAttributeName,validValue2);
//instance[jsAttributeName] = validValue2;
let logEntries = element.takeLog();
assert_array_equals(logEntries.types(), ['attributeChanged']);
assert_attribute_log_entry(logEntries.last(), {name: contentAttributeName, oldValue: validValue1, newValue: validValue2, namespace: null});
}, name + ' must enqueue an attributeChanged reaction when replacing an existing attribute');

container.parentNode.removeChild(container);
}

function testReflectAttributeWithPreContentValuesArea(preJsAttributeName, preValidValue, jsAttributeName, validValue1, validValue2, name) {
let container = document.createElement('map');
document.body.appendChild(container);

test(function () {
let element = define_new_custom_element([preJsAttributeName]);
let instance = document.createElement(element.name);
container.appendChild(instance);
instance.setAttribute(preJsAttributeName, preValidValue);
//instance[preJsAttributeName] = preValidValue;
assert_array_equals(element.takeLog().types(), ['constructed', 'connected', 'attributeChanged']);
instance.setAttribute(jsAttributeName, validValue1);
assert_array_equals(element.takeLog().types(),[]);
}, name + ' must not enqueue an attributeChanged reaction when it is unobserved attribute');

test(function () {
let element = define_new_custom_element([preJsAttributeName]);
let instance = document.createElement(element.name);
container.appendChild(instance);
instance.setAttribute(preJsAttributeName, preValidValue);
//instance[preJsAttributeName] = preValidValue;
assert_array_equals(element.takeLog().types(), ['constructed', 'connected', 'attributeChanged']);
instance.setAttribute(jsAttributeName, validValue1);
assert_array_equals(element.takeLog().types(),[]);
instance.setAttribute(jsAttributeName, validValue2);
//instance[jsAttributeName] = validValue2;
let logEntries = element.takeLog();
assert_array_equals(logEntries.types(), []);
}, name + ' must not enqueue an attributeChanged reaction when alter an existing unobserved attribute');

container.parentNode.removeChild(container);
}