Skip to content

Commit

Permalink
Test innerText getter for <select>, <optgroup> and <option>
Browse files Browse the repository at this point in the history
Tests for whatwg/html#1717

These all pass in Gecko.
  • Loading branch information
zcorpan authored and domenic committed Nov 3, 2016
1 parent a014b88 commit a99ba66
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
22 changes: 18 additions & 4 deletions innerText/getter-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,6 @@ testText("<fieldset>abc", "abc", "<fieldset> contents preserved");
testText("<fieldset><legend>abc", "abc", "<fieldset> <legend> contents preserved");
testText("<input type='text' value='abc'>", "", "<input> contents ignored");
testText("<textarea>abc", "", "<textarea> contents ignored");
testText("<select size='1'><option>abc</option><option>def", "abc\ndef", "<select size='1'> contents of options preserved");
testText("<select size='2'><option>abc</option><option>def", "abc\ndef", "<select size='2'> contents of options preserved");
testText("<select size='1'><option id='target'>abc</option><option>def", "abc", "<select size='1'> contents of target option preserved");
testText("<select size='2'><option id='target'>abc</option><option>def", "abc", "<select size='2'> contents of target option preserved");
testText("<iframe>abc", "", "<iframe> contents ignored");
testText("<iframe><div id='target'>abc", "", "<iframe> contents ignored");
testText("<iframe src='data:text/html,abc'>", "","<iframe> subdocument ignored");
Expand All @@ -144,6 +140,24 @@ testText("<canvas><div id='target'>abc", "", "<canvas><div id='target'> contents
testText("<img alt='abc'>", "", "<img> alt text ignored");
testText("<img src='about:blank' class='poke'>", "", "<img> contents ignored");

/**** <select>, <optgroup> & <option> ****/

testText("<select size='1'><option>abc</option><option>def", "abc\ndef", "<select size='1'> contents of options preserved");
testText("<select size='2'><option>abc</option><option>def", "abc\ndef", "<select size='2'> contents of options preserved");
testText("<select size='1'><option id='target'>abc</option><option>def", "abc", "<select size='1'> contents of target option preserved");
testText("<select size='2'><option id='target'>abc</option><option>def", "abc", "<select size='2'> contents of target option preserved");
testText("<div>a<select></select>bc", "abc", "empty <select>");
testText("<div>a<select><optgroup></select>bc", "a\nbc", "empty <optgroup> in <select>");
testText("<div>a<select><option></select>bc", "a\nbc", "empty <option> in <select>");
testText("<select class='poke'></select>", "", "<select> containing text node child");
testText("<select><optgroup class='poke-optgroup'></select>", "", "<optgroup> containing <optgroup>");
testText("<select><optgroup><option>abc</select>", "abc", "<optgroup> containing <option>");
testText("<select><option class='poke-div'>123</select>", "123\nabc", "<div> in <option>");
testText("<div>a<optgroup></optgroup>bc", "a\nbc", "empty <optgroup> in <div>");
testText("<div>a<optgroup>123</optgroup>bc", "a\nbc", "<optgroup> in <div>");
testText("<div>a<option></option>bc", "a\nbc", "empty <option> in <div>");
testText("<div>a<option>123</option>bc", "a\n123\nbc", "<option> in <div>");

/**** innerText on replaced element children ****/

testText("<div><button>abc", "abc", "<button> contents preserved");
Expand Down
14 changes: 8 additions & 6 deletions innerText/getter.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@
for (var i = 0; i < pokes.length; ++i) {
pokes[i].textContent = 'abc';
}
pokes = document.getElementsByClassName('poke-rp');
for (var i = 0; i < pokes.length; ++i) {
var rp = document.createElement("rp");
rp.textContent = "abc";
pokes[i].appendChild(rp);
}
['rp', 'optgroup', 'div'].forEach(function(tag) {
pokes = document.getElementsByClassName('poke-' + tag);
for (var i = 0; i < pokes.length; ++i) {
var el = document.createElement(tag);
el.textContent = "abc";
pokes[i].appendChild(el);
}
});
var shadows = document.getElementsByClassName('shadow');
for (var i = 0; i < shadows.length; ++i) {
var s = shadows[i].createShadowRoot();
Expand Down

0 comments on commit a99ba66

Please sign in to comment.