Skip to content

Commit

Permalink
Update <selectedcontent> test for OpenUI resolution
Browse files Browse the repository at this point in the history
This patch adds test cases corresponding to this OpenUI resolution:
openui/open-ui#1119 (comment)

It also cleans up the leftover queueMicrotask calls which are no longer
needed now that things are synchronous.

Change-Id: I1031d2899197e313dd9eb20a142868930b886a28
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6086797
Reviewed-by: Traian Captan <[email protected]>
Commit-Queue: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1395174}
  • Loading branch information
josepharhar authored and chromium-wpt-export-bot committed Dec 12, 2024
1 parent 1b5c481 commit d5265e8
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,32 @@
'The innerHTML of <selectedcontent> should initially match the innerHTML of the selected <option>.');

select.value = 'two';
await new Promise(queueMicrotask);
assert_equals(selectedcontent.innerHTML, optionTwo.innerHTML,
'The innerHTML of <selectedcontent> should change after the selected option is changed.');

let oldInnerHTML = optionTwo.innerHTML;
spanTwo.textContent = 'new span';
await new Promise(queueMicrotask);
assert_equals(selectedcontent.innerHTML, oldInnerHTML,
'<selectedcontent> should not respond to <option> text content changes.');

spanTwo.appendChild(document.createElement('div'));
await new Promise(queueMicrotask);
assert_equals(selectedcontent.innerHTML, oldInnerHTML,
'<selectedcontent> should not respond to new elements being added to descendants of <option>.');

spanTwo.setAttribute('data-foo', 'bar');
await new Promise(queueMicrotask);
assert_equals(selectedcontent.innerHTML, oldInnerHTML,
'<selectedcontent> should not respond to attributes being added to descendants of <option>.');

select.value = select.value;
assert_equals(selectedcontent.innerHTML, optionTwo.innerHTML,
'<selectedcontent> should be updated in response to re-assigning select.value.');

spanTwo.firstElementChild.remove();
select.selectedIndex = select.selectedIndex;
assert_equals(selectedcontent.innerHTML, optionTwo.innerHTML,
'<selectedcontent> should be updated in response to re-assigning select.selectedIndex.');

form.reset();
await new Promise(queueMicrotask);
assert_equals(select.value, 'one',
'form.reset() should change the selects value to one.');
assert_equals(selectedcontent.innerHTML, optionOne.innerHTML,
Expand All @@ -70,22 +74,19 @@
await test_driver.bless();
select.showPicker();
await test_driver.click(optionTwo);
await new Promise(queueMicrotask);
assert_equals(select.value, 'two',
'Clicking on another option should change select.value.');
assert_equals(selectedcontent.innerHTML, optionTwo.innerHTML,
'Clicking on an option element should update the <selectedcontent>.');

selectedcontent.remove();
await new Promise(queueMicrotask);
assert_equals(selectedcontent.innerHTML, '',
'Removing the <selectedcontent> from the <select> should make it clear its contents.');
button.appendChild(selectedcontent);
assert_equals(selectedcontent.innerHTML, optionTwo.innerHTML,
'Re-inserting the <selectedcontent> should make it update its contents.');

optionTwo.remove();
await new Promise(queueMicrotask);
assert_equals(selectedcontent.innerHTML, optionOne.innerHTML,
'The innerHTML of <selectedcontent> should be updated in response to selected <option> removal.');
optionOne.remove();
Expand Down

0 comments on commit d5265e8

Please sign in to comment.