Navigation Menu

Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1163953 - merge pull request #30021 from albertopq:1163953-action…
Browse files Browse the repository at this point in the history
…-menu-multiple to mozilla-b2g:master
  • Loading branch information
mozilla-autolander-deprecated committed May 26, 2015
2 parents 48dad15 + cc2c066 commit 0359bf8
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 9 deletions.
2 changes: 1 addition & 1 deletion apps/system/js/action_menu.js
Expand Up @@ -35,7 +35,7 @@
ActionMenu.prototype.EVENT_PREFIX = 'actionmenu';

ActionMenu.prototype.view = function spd_view() {
return `<div id="action-menu" hidden>
return `<div id="action-menu" class="action-menu" hidden>
<form id="action-menu-form" data-z-index-level="action-menu"
role="dialog" data-type="action">
<header id="action-menu-header" data-l10n-id=""></header>
Expand Down
14 changes: 9 additions & 5 deletions apps/system/js/activities.js
Expand Up @@ -55,7 +55,6 @@
case 'appopened':
if (this.actionMenu) {
this.actionMenu.hide();
this.actionMenu = null;
}
break;
case 'applicationinstall':
Expand Down Expand Up @@ -197,7 +196,7 @@
var askForDefault = config !== undefined;
var items = this._listItems(choices);

if (!this.actionMenu || !this.actionMenu.active) {
if (!this.actionMenu) {
var controller = {
successCb: this.choose.bind(this),
cancelCb: this.cancel.bind(this)
Expand All @@ -207,6 +206,8 @@
this.actionMenu = new ActionMenu(controller);
this.actionMenu.show(items, titleId, askForDefault);
}.bind(this));
} else if (!this.actionMenu.active) {
this.actionMenu.show(items, titleId, askForDefault);
}
}).bind(this));
}
Expand All @@ -219,8 +220,9 @@
* @param {Boolean} setAsDefault Should this be set as the default activity.
*/
choose: function(choice, setAsDefault) {
this.actionMenu = null;

if (this.actionMenu) {
this.actionMenu.hide();
}
var returnedChoice = {
id: this._detail.id,
type: 'activity-choice',
Expand All @@ -244,7 +246,9 @@
* @memberof Activities.prototype
*/
cancel: function() {
this.actionMenu = null;
if (this.actionMenu) {
this.actionMenu.hide();
}

var returnedChoice = {
id: this._detail.id,
Expand Down
21 changes: 21 additions & 0 deletions apps/system/test/marionette/activity_action_menu_test.js
Expand Up @@ -3,6 +3,7 @@
(function() {
var Messages = require('../../../sms/test/marionette/lib/messages');
var UtilityTray = require('./lib/utility_tray');
var assert = require('assert');

marionette('activity action menu test', function() {
var messagesApp, system, utilityTray;
Expand Down Expand Up @@ -60,5 +61,25 @@
done();
}, 1000);
});

test('it only creates 1 action menu div', function() {
messagesApp.launch();
messagesApp.Inbox.navigateToComposer();
var composer = messagesApp.Composer;

client.waitFor(function() {
return composer.attachButton.enabled();
});
composer.attachButton.tap();
client.switchToFrame();
system.waitForActivityMenu();
system.cancelActivity.tap();
messagesApp.switchTo();
composer.attachButton.tap();
client.switchToFrame();
system.waitForActivityMenu();
var actionMenus = client.findElements('.action-menu');
assert.ok(actionMenus.length === 1);
});
});
}());
9 changes: 9 additions & 0 deletions apps/system/test/unit/activities_test.js
Expand Up @@ -367,6 +367,15 @@ suite('system/Activities', function() {
subject.cancel();
assert.ok(stub.calledWith(formatted));
});

test('does not destroy the action menu', function() {
subject._detail = {
id: 'foo'
};
var stub = this.sinon.stub(subject.actionMenu, 'hide');
subject.cancel();
assert.ok(stub.called);
});
});
});

Expand Down
Expand Up @@ -4,13 +4,12 @@

from gaiatest import GaiaTestCase
from gaiatest.apps.homescreen.app import Homescreen
from marionette_driver import By
from marionette_driver import expected, By, Wait


class TestMarketplaceLaunch(GaiaTestCase):

_marketplace_iframe_locator = (By.CSS_SELECTOR, 'iframe[src*="marketplace"]')
_loading_fragment_locator = (By.ID, 'splash-overlay')
_site_header_locator = (By.ID, 'site-header')

def setUp(self):
Expand All @@ -28,7 +27,7 @@ def test_marketplace_launch(self):
marketplace = homescreen.installed_app(app_name)
marketplace.tap_icon()

self.wait_for_element_not_displayed(*self._loading_fragment_locator)
Wait(self.marionette, timeout=60).until(expected.element_present(*self._marketplace_iframe_locator))

iframe = self.marionette.find_element(*self._marketplace_iframe_locator)
self.marionette.switch_to_frame(iframe)
Expand Down

0 comments on commit 0359bf8

Please sign in to comment.