File: popovertarget-reflection.html

package info (click to toggle)
firefox 145.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,653,344 kB
  • sloc: cpp: 7,594,932; javascript: 6,459,612; ansic: 3,752,905; python: 1,403,433; xml: 629,811; asm: 438,677; java: 186,421; sh: 67,287; makefile: 19,169; objc: 13,086; perl: 12,982; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10
file content (53 lines) | stat: -rw-r--r-- 2,962 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://bugs.chromium.org/p/chromium/issues/detail?id=1523410">
<link rel=help href="https://bugzilla.mozilla.org/show_bug.cgi?id=1879001">
<link rel=help href="https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes:element">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<button id=mybutton popovertarget="mypopover">toggle popover</button>
<div id=mypopover popover=auto>popover</div>

<script>
test(() => {
  assert_equals(mybutton.popoverTargetElement.id, "mypopover",
    'Setting element.popoverTargetElement to a valid element should work');

  mybutton.popoverTargetElement = null;
  assert_false(mybutton.hasAttribute('popovertarget'),
    'Setting element.popoverTargetElement to null should unset popovertarget attribute.');
  assert_equals(mybutton.popoverTargetElement, null,
    'Setting element.popoverTargetElement to null should remove the existing element from element.popoverTargetElement.');

  mybutton.popoverTargetElement = mypopover;
  assert_true(mybutton.hasAttribute('popovertarget'),
    'Assigning to element.popoverTargetElement should set the popovertarget attribute.');

  mybutton.removeAttribute('popovertarget');
  assert_equals(mybutton.popoverTargetElement, null,
    'Removing the popovertarget attribute should remove the element from element.popoverTargetElement.');

  mybutton.popoverTargetElement = mypopover;
  assert_true(mybutton.hasAttribute('popovertarget'),
    'Assigning to element.popoverTargetElement should set the popovertarget attribute.');

  mybutton.setAttribute("popovertarget", 'invalid');
  assert_equals(mybutton.popoverTargetElement, null,
    'Setting the popovertarget attribute to a localName that is not attr should remove the existing element from element.popoverTargetElement.');

  mybutton.popoverTargetElement = mypopover;
  mybutton.setAttribute("popovertarget", "");
  assert_equals(mybutton.popoverTargetElement, null,
    'Setting the popovertarget attribute to empty string right after setting explicit element does remove the explicit element.');

  mybutton.setAttribute("popovertarget", "mypopover");
  assert_equals(mybutton.popoverTargetElement.id, "mypopover",
    'Setting the popovertarget attribute to a value should set the popover target element.');
  mybutton.setAttribute("popovertarget", "");
  assert_equals(mybutton.getAttribute('popovertarget'), "",
    'Assigning to element.popoverTargetElement to empty string should update the attribute value to empty string.');
  assert_equals(mybutton.popoverTargetElement, null,
    'Setting the popovertarget attribute to empty string should remove the existing element from element.popoverTargetElement.');
}, 'Element attribute reflection of popoverTargetElement/popovertarget should be kept in sync.');
</script>