|
1 | 1 | <!DOCTYPE html>
|
2 | 2 | <link rel= author href=" mailto:[email protected]" >
|
3 | 3 | <link rel=help href="https://bugs.chromium.org/p/chromium/issues/detail?id=1523410">
|
| 4 | +<link rel=help href="https://bugzilla.mozilla.org/show_bug.cgi?id=1879001"> |
4 | 5 | <link rel=help href="https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes:element">
|
5 | 6 | <script src="/resources/testharness.js"></script>
|
6 | 7 | <script src="/resources/testharnessreport.js"></script>
|
7 | 8 |
|
8 |
| -<button id=mybutton>toggle popover</button> |
| 9 | +<button id=mybutton popovertarget="mypopover">toggle popover</button> |
9 | 10 | <div id=mypopover popover=auto>popover</div>
|
10 | 11 |
|
11 | 12 | <script>
|
12 | 13 | test(() => {
|
| 14 | + assert_equals(mybutton.popoverTargetElement.id, "mypopover", |
| 15 | + 'Setting element.popoverTargetElement to a valid element should work'); |
| 16 | + |
| 17 | + mybutton.popoverTargetElement = null; |
| 18 | + assert_false(mybutton.hasAttribute('popovertarget'), |
| 19 | + 'Setting element.popoverTargetElement to null should unset popovertarget attribute.'); |
| 20 | + assert_equals(mybutton.popoverTargetElement, null, |
| 21 | + 'Setting element.popoverTargetElement to null should remove the existing element from element.popoverTargetElement.'); |
| 22 | + |
13 | 23 | mybutton.popoverTargetElement = mypopover;
|
14 | 24 | assert_true(mybutton.hasAttribute('popovertarget'),
|
15 | 25 | 'Assigning to element.popoverTargetElement should set the popovertarget attribute.');
|
16 | 26 |
|
17 | 27 | mybutton.removeAttribute('popovertarget');
|
18 | 28 | assert_equals(mybutton.popoverTargetElement, null,
|
19 | 29 | 'Removing the popovertarget attribute should remove the element from element.popoverTargetElement.');
|
| 30 | + |
| 31 | + mybutton.popoverTargetElement = mypopover; |
| 32 | + assert_true(mybutton.hasAttribute('popovertarget'), |
| 33 | + 'Assigning to element.popoverTargetElement should set the popovertarget attribute.'); |
| 34 | + |
| 35 | + mybutton.setAttribute("popovertarget", 'invalid'); |
| 36 | + assert_equals(mybutton.popoverTargetElement, null, |
| 37 | + 'Setting the popovertarget attribute to a localName that is not attr should remove the existing element from element.popoverTargetElement.'); |
| 38 | + |
| 39 | + mybutton.popoverTargetElement = mypopover; |
| 40 | + mybutton.setAttribute("popovertarget", ""); |
| 41 | + assert_equals(mybutton.popoverTargetElement.id, "mypopover", |
| 42 | + 'Setting the popovertarget attribute to empty string right after explicitly setting attribute element should have no effect.'); |
| 43 | + |
| 44 | + mybutton.setAttribute("popovertarget", "mypopover"); |
| 45 | + assert_equals(mybutton.popoverTargetElement.id, "mypopover", |
| 46 | + 'Setting the popovertarget attribute to a value should set the popover target element.'); |
| 47 | + mybutton.setAttribute("popovertarget", ""); |
| 48 | + assert_equals(mybutton.getAttribute('popovertarget'), "", |
| 49 | + 'Assigning to element.popoverTargetElement to empty string should update the attribute value to empty string.'); |
| 50 | + assert_equals(mybutton.popoverTargetElement, null, |
| 51 | + 'Setting the popovertarget attribute to empty string should remove the existing element from element.popoverTargetElement.'); |
20 | 52 | }, 'Element attribute reflection of popoverTargetElement/popovertarget should be kept in sync.');
|
21 | 53 | </script>
|
0 commit comments