Bug 1350670 - Extend the MutationObserver to cover attributes in case the page sets styles through style, class, ID or other attributes. r=mossop

MozReview-Commit-ID: 3tYjbqH9zYb

--HG--
extra : rebase_source : ae593c3f8ac627ebb058d5f486d5b34ea2f63c9e
This commit is contained in:
Jared Wein 2017-03-29 12:47:13 -04:00
Родитель 7c4e46f7ce
Коммит ea4c7c16b9
2 изменённых файлов: 31 добавлений и 1 удалений

Просмотреть файл

@ -120,6 +120,16 @@ const SELECT_STYLE_OF_OPTION_IS_BASED_ON_FOCUS_OF_SELECT =
' <option selected="true">{"end": "true"}</option>' +
"</select></body></html>";
const SELECT_STYLE_OF_OPTION_CHANGES_AFTER_FOCUS_EVENT =
"<html><body><select id='one'>" +
' <option>{"color": "rgb(255, 0, 0)", "backgroundColor": "rgba(0, 0, 0, 0)"}</option>' +
' <option selected="true">{"end": "true"}</option>' +
"</select></body><scr" +
"ipt>" +
" var select = document.getElementById('one');" +
" select.addEventListener('focus', () => select.style.color = 'red');" +
"</script></html>";
function getSystemColor(color) {
// Need to convert system color to RGB color.
let textarea = document.createElementNS("http://www.w3.org/1999/xhtml", "textarea");
@ -169,6 +179,15 @@ function* testSelectColors(select, itemCount, options) {
yield BrowserTestUtils.synthesizeMouseAtCenter("#one", { type: "mousedown" }, gBrowser.selectedBrowser);
yield popupShownPromise;
if (options.waitForComputedStyle) {
let property = options.waitForComputedStyle.property;
let value = options.waitForComputedStyle.value;
yield BrowserTestUtils.waitForCondition(() => {
info(`<select> has ${property}: ${getComputedStyle(selectPopup)[property]}`);
return getComputedStyle(selectPopup)[property] == value;
}, `Waiting for <select> to have ${property}: ${value}`);
}
is(selectPopup.parentNode.itemCount, itemCount, "Correct number of items");
let child = selectPopup.firstChild;
let idx = 1;
@ -335,3 +354,14 @@ add_task(function* test_style_of_options_is_dependent_on_focus_of_select() {
yield testSelectColors(SELECT_STYLE_OF_OPTION_IS_BASED_ON_FOCUS_OF_SELECT, 2, options);
});
add_task(function* test_style_of_options_is_dependent_on_focus_of_select() {
let options = {
skipSelectColorTest: true,
waitForComputedStyle: {
property: "color",
value: "rgb(255, 0, 0)"
}
};
yield testSelectColors(SELECT_STYLE_OF_OPTION_CHANGES_AFTER_FOCUS_EVENT, 2, options);
});

Просмотреть файл

@ -70,7 +70,7 @@ this.SelectContentHelper.prototype = {
// in the very near future.
this._updateTimer.arm();
});
this.mut.observe(this.element, {childList: true, subtree: true});
this.mut.observe(this.element, {childList: true, subtree: true, attributes: true});
},
uninit() {