mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 1195931, use option.text instead of option.textContent so that spaces get handled properly in select lists, r=felipe
This commit is contained in:
parent
7ec5cb2fcf
commit
8a41f6bd15
@ -5,6 +5,8 @@
|
||||
// in a child process. This is different than single-process as a <menulist> is used
|
||||
// to implement the dropdown list.
|
||||
|
||||
const XHTML_DTD = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
|
||||
|
||||
const PAGECONTENT =
|
||||
"<html xmlns='http://www.w3.org/1999/xhtml'>" +
|
||||
"<body onload='gChangeEvents = 0; document.body.firstChild.focus()'><select onchange='gChangeEvents++'>" +
|
||||
@ -19,8 +21,8 @@ const PAGECONTENT =
|
||||
" </optgroup>" +
|
||||
" <option value='Six' disabled='true'>Six</option>" +
|
||||
" <optgroup label='Third Group'>" +
|
||||
" <option value='Seven'>Seven</option>" +
|
||||
" <option value='Eight'>Eight</option>" +
|
||||
" <option value='Seven'> Seven </option>" +
|
||||
" <option value='Eight'> Eight </option>" +
|
||||
" </optgroup></select><input />" +
|
||||
"</body></html>";
|
||||
|
||||
@ -58,11 +60,11 @@ function getChangeEvents()
|
||||
});
|
||||
}
|
||||
|
||||
function doSelectTests(contentType)
|
||||
function doSelectTests(contentType, dtd)
|
||||
{
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab();
|
||||
let browser = gBrowser.getBrowserForTab(tab);
|
||||
yield promiseTabLoadEvent(tab, "data:" + contentType + "," + escape(PAGECONTENT));
|
||||
yield promiseTabLoadEvent(tab, "data:" + contentType + "," + escape(dtd + "\n" + PAGECONTENT));
|
||||
|
||||
yield SimpleTest.promiseFocus(browser.contentWindow);
|
||||
|
||||
@ -127,15 +129,17 @@ function doSelectTests(contentType)
|
||||
EventUtils.synthesizeKey("VK_TAB", { shiftKey: true });
|
||||
is((yield getChangeEvents()), isWindows ? 2 : 1, "Tab away from select with change - number of change events");
|
||||
|
||||
is(selectPopup.lastChild.previousSibling.label, "Seven", "Spaces collapsed");
|
||||
is(selectPopup.lastChild.label, "\xA0\xA0Eight\xA0\xA0", "Non-breaking spaces not collapsed");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
}
|
||||
|
||||
add_task(function*() {
|
||||
yield doSelectTests("text/html");
|
||||
yield doSelectTests("text/html", "");
|
||||
});
|
||||
|
||||
add_task(function*() {
|
||||
yield doSelectTests("application/xhtml+xml");
|
||||
yield doSelectTests("application/xhtml+xml", XHTML_DTD);
|
||||
});
|
||||
|
||||
|
||||
|
@ -101,12 +101,9 @@ function buildOptionListForChildren(node) {
|
||||
if (tagName == 'OPTION' || tagName == 'OPTGROUP') {
|
||||
let textContent =
|
||||
tagName == 'OPTGROUP' ? child.getAttribute("label")
|
||||
: child.textContent;
|
||||
|
||||
if (textContent != null) {
|
||||
textContent = textContent.trim();
|
||||
} else {
|
||||
textContent = ""
|
||||
: child.text;
|
||||
if (textContent == null) {
|
||||
textContent = "";
|
||||
}
|
||||
|
||||
let info = {
|
||||
|
Loading…
Reference in New Issue
Block a user