Bug 1133058 - OptionsView button, when clicked, should have an 'open' attribute. r=vp

This commit is contained in:
Jordan Santell 2015-02-23 10:31:00 +01:00
parent 637be57afe
commit dda6fdfa37
2 changed files with 7 additions and 0 deletions

View File

@ -21,6 +21,9 @@ const OptionsView = function (options={}) {
let { document } = this.window;
this.$ = document.querySelector.bind(document);
this.$$ = document.querySelectorAll.bind(document);
// Get the corresponding button that opens the popup by looking
// for an element with a `popup` attribute matching the menu's ID
this.button = this.$(`[popup=${this.menupopup.getAttribute("id")}]`);
this.prefObserver = new PrefObserver(this.branchName);
@ -126,6 +129,7 @@ OptionsView.prototype = {
* Fires an event used in tests.
*/
_onPopupShown: function () {
this.button.setAttribute("open", true);
this.emit(OPTIONS_SHOWN_EVENT);
},
@ -134,6 +138,7 @@ OptionsView.prototype = {
* Fires an event used in tests.
*/
_onPopupHidden: function () {
this.button.removeAttribute("open");
this.emit(OPTIONS_HIDDEN_EVENT);
}
};

View File

@ -95,7 +95,9 @@ function* click(view, win, menuitem) {
let button = win.document.querySelector("#options-button");
EventUtils.synthesizeMouseAtCenter(button, {}, win);
yield opened;
is(button.getAttribute("open"), "true", "button has `open` attribute");
EventUtils.synthesizeMouseAtCenter(menuitem, {}, win);
yield closed;
ok(!button.hasAttribute("open"), "button does not have `open` attribute");
}