Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/custom-elements/imports/attribute-changed-callback.html |
| diff --git a/third_party/WebKit/LayoutTests/custom-elements/imports/attribute-changed-callback.html b/third_party/WebKit/LayoutTests/custom-elements/imports/attribute-changed-callback.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..38c00606f58e4bd9d394125524786c41663fef03 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/custom-elements/imports/attribute-changed-callback.html |
| @@ -0,0 +1,49 @@ |
| +<!DOCTYPE html> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<link id="import1" rel="import" href="resources/attribute-upgrade.html"> |
| +<script> |
| +'use strict'; |
| + |
| +let reactions = []; |
| + |
| +customElements.define('a-a', class extends HTMLElement { |
| + static get observedAttributes() { return ['attr']; } |
| + attributeChangedCallback() { |
| + reactions.push(this); |
| + } |
| +}); |
| +</script> |
| +<link id="import2" rel="import" href="resources/attribute-parsercreate.html"> |
| +<script> |
| +'use strict'; |
| + |
| +test(() => { |
| + let importDoc1 = import1.import; |
| + let importDoc2 = import2.import; |
| + |
| + let a = importDoc1.querySelector('#a'); |
| + let b = importDoc1.querySelector('#b'); |
| + let c = importDoc2.querySelector('#c'); |
| + let d = importDoc2.querySelector('#d'); |
| + |
| + assert_array_equals(reactions, [b, d], |
| + 'attributeChangedCallback should have called for both upgrade and create.'); |
|
dominicc (has gone to gerrit)
2016/09/02 01:01:55
grammar: have called -> have been called (have cal
kochi
2016/09/02 02:59:15
Done.
|
| + |
| + a.setAttribute('attr', 'a'); |
| + b.setAttribute('attr', 'b'); |
| + c.setAttribute('attr', 'c'); |
| + d.setAttribute('attr', 'd'); |
| + |
| + assert_array_equals(reactions, [b, d, a, b, c, d], |
| + 'attributeChangedCallback should have called for setAttribute().'); |
| + |
| + d.removeAttribute('attr', 'd'); |
| + c.removeAttribute('attr', 'c'); |
| + b.removeAttribute('attr', 'b'); |
| + a.removeAttribute('attr', 'a'); |
| + |
| + assert_array_equals(reactions, [b, d, a, b, c, d, d, c, b, a], |
|
dominicc (has gone to gerrit)
2016/09/02 01:01:55
This list is getting long. What do you think about
kochi
2016/09/02 02:59:15
That makes sense.
Done.
|
| + 'attributeChangedCallback should have called for removeAttribute().'); |
| +}, 'attributeChangedCallback should be invoked for elements in import'); |
| +</script> |