зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset b04123c901ac (bug 1121210) for Mn failures
This commit is contained in:
Родитель
90ad8ca3b5
Коммит
ba6b80db37
|
@ -13,50 +13,16 @@ XPCOMUtils.defineLazyModuleGetter(this, "PanelFrame", "resource:///modules/Panel
|
|||
|
||||
(function() {
|
||||
LoopUI = {
|
||||
/**
|
||||
* @var {XULWidgetSingleWrapper} toolbarButton Getter for the Loop toolbarbutton
|
||||
* instance for this window.
|
||||
*/
|
||||
get toolbarButton() {
|
||||
delete this.toolbarButton;
|
||||
return this.toolbarButton = CustomizableUI.getWidget("loop-button").forWindow(window);
|
||||
},
|
||||
|
||||
/**
|
||||
* @var {XULElement} panel Getter for the Loop panel element.
|
||||
*/
|
||||
get panel() {
|
||||
delete this.panel;
|
||||
return this.panel = document.getElementById("loop-notification-panel");
|
||||
},
|
||||
|
||||
/**
|
||||
* @var {XULElement|null} browser Getter for the Loop panel browser element.
|
||||
* Will be NULL if the panel hasn't loaded yet.
|
||||
*/
|
||||
get browser() {
|
||||
let browser = document.querySelector("#loop-notification-panel > #loop-panel-iframe");
|
||||
if (browser) {
|
||||
delete this.browser;
|
||||
this.browser = browser;
|
||||
}
|
||||
return browser;
|
||||
},
|
||||
|
||||
/**
|
||||
* @var {String|null} selectedTab Getter for the name of the currently selected
|
||||
* tab inside the Loop panel. Will be NULL if
|
||||
* the panel hasn't loaded yet.
|
||||
*/
|
||||
get selectedTab() {
|
||||
if (!this.browser) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let selectedTab = this.browser.contentDocument.querySelector(".tab-view > .selected");
|
||||
return selectedTab && selectedTab.getAttribute("data-tab-name");
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {Promise}
|
||||
*/
|
||||
|
@ -73,24 +39,12 @@ XPCOMUtils.defineLazyModuleGetter(this, "PanelFrame", "resource:///modules/Panel
|
|||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle between opening or hiding the Loop panel.
|
||||
*
|
||||
* @param {DOMEvent} [event] Optional event that triggered the call to this
|
||||
* function.
|
||||
* @param {String} [tabId] Optional name of the tab to select after the panel
|
||||
* has opened. Does nothing when the panel is hidden.
|
||||
* @return {Promise}
|
||||
*/
|
||||
togglePanel: function(event, tabId = null) {
|
||||
if (this.panel.state == "open") {
|
||||
return new Promise(resolve => {
|
||||
this.panel.hidePopup();
|
||||
resolve();
|
||||
});
|
||||
this.panel.hidePopup();
|
||||
} else {
|
||||
this.openCallPanel(event, tabId);
|
||||
}
|
||||
|
||||
return this.openCallPanel(event, tabId);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -738,15 +738,13 @@ function injectLoopAPI(targetWindow) {
|
|||
* Notifies the UITour module that an event occurred that it might be
|
||||
* interested in.
|
||||
*
|
||||
* @param {String} subject Subject of the notification
|
||||
* @param {mixed} [params] Optional parameters, providing more details to
|
||||
* the notification subject
|
||||
* @param {String} subject Subject of the notification
|
||||
*/
|
||||
notifyUITour: {
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
value: function(subject, params) {
|
||||
UITour.notify(subject, params);
|
||||
value: function(subject) {
|
||||
UITour.notify(subject);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -25,8 +25,7 @@ loop.panel = (function(_, mozL10n) {
|
|||
propTypes: {
|
||||
buttonsHidden: React.PropTypes.array,
|
||||
// The selectedTab prop is used by the UI showcase.
|
||||
selectedTab: React.PropTypes.string,
|
||||
mozLoop: React.PropTypes.object
|
||||
selectedTab: React.PropTypes.string
|
||||
},
|
||||
|
||||
getDefaultProps: function() {
|
||||
|
@ -35,14 +34,6 @@ loop.panel = (function(_, mozL10n) {
|
|||
};
|
||||
},
|
||||
|
||||
shouldComponentUpdate: function(nextProps, nextState) {
|
||||
var tabChange = this.state.selectedTab !== nextState.selectedTab;
|
||||
if (tabChange) {
|
||||
this.props.mozLoop.notifyUITour("Loop:PanelTabChanged", nextState.selectedTab);
|
||||
}
|
||||
return tabChange;
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
// XXX Work around props.selectedTab being undefined initially.
|
||||
// When we don't need to rely on the pref, this can move back to
|
||||
|
@ -808,7 +799,7 @@ loop.panel = (function(_, mozL10n) {
|
|||
React.createElement(NotificationListView, {notifications: this.props.notifications,
|
||||
clearOnDocumentHidden: true}),
|
||||
React.createElement(TabView, {ref: "tabView", selectedTab: this.props.selectedTab,
|
||||
buttonsHidden: hideButtons, mozLoop: this.props.mozLoop},
|
||||
buttonsHidden: hideButtons},
|
||||
React.createElement(Tab, {name: "rooms"},
|
||||
React.createElement(RoomList, {dispatcher: this.props.dispatcher,
|
||||
store: this.props.roomStore,
|
||||
|
|
|
@ -25,8 +25,7 @@ loop.panel = (function(_, mozL10n) {
|
|||
propTypes: {
|
||||
buttonsHidden: React.PropTypes.array,
|
||||
// The selectedTab prop is used by the UI showcase.
|
||||
selectedTab: React.PropTypes.string,
|
||||
mozLoop: React.PropTypes.object
|
||||
selectedTab: React.PropTypes.string
|
||||
},
|
||||
|
||||
getDefaultProps: function() {
|
||||
|
@ -35,14 +34,6 @@ loop.panel = (function(_, mozL10n) {
|
|||
};
|
||||
},
|
||||
|
||||
shouldComponentUpdate: function(nextProps, nextState) {
|
||||
var tabChange = this.state.selectedTab !== nextState.selectedTab;
|
||||
if (tabChange) {
|
||||
this.props.mozLoop.notifyUITour("Loop:PanelTabChanged", nextState.selectedTab);
|
||||
}
|
||||
return tabChange;
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
// XXX Work around props.selectedTab being undefined initially.
|
||||
// When we don't need to rely on the pref, this can move back to
|
||||
|
@ -808,7 +799,7 @@ loop.panel = (function(_, mozL10n) {
|
|||
<NotificationListView notifications={this.props.notifications}
|
||||
clearOnDocumentHidden={true} />
|
||||
<TabView ref="tabView" selectedTab={this.props.selectedTab}
|
||||
buttonsHidden={hideButtons} mozLoop={this.props.mozLoop}>
|
||||
buttonsHidden={hideButtons}>
|
||||
<Tab name="rooms">
|
||||
<RoomList dispatcher={this.props.dispatcher}
|
||||
store={this.props.roomStore}
|
||||
|
|
|
@ -11,17 +11,6 @@ Components.utils.import("resource://gre/modules/Promise.jsm", this);
|
|||
const {LoopRoomsInternal} = Components.utils.import("resource:///modules/loop/LoopRooms.jsm", {});
|
||||
Services.prefs.setBoolPref("loop.gettingStarted.seen", true);
|
||||
|
||||
const fxASampleToken = {
|
||||
token_type: "bearer",
|
||||
access_token: "1bad3e44b12f77a88fe09f016f6a37c42e40f974bc7a8b432bb0d2f0e37e1752",
|
||||
scope: "profile"
|
||||
};
|
||||
|
||||
const fxASampleProfile = {
|
||||
email: "test@example.com",
|
||||
uid: "abcd1234"
|
||||
};
|
||||
|
||||
registerCleanupFunction(function*() {
|
||||
MozLoopService.doNotDisturb = false;
|
||||
MozLoopServiceInternal.fxAOAuthProfile = null;
|
||||
|
@ -29,42 +18,6 @@ registerCleanupFunction(function*() {
|
|||
Services.prefs.clearUserPref("loop.gettingStarted.seen");
|
||||
});
|
||||
|
||||
add_task(function* test_LoopUI_getters() {
|
||||
Assert.ok(LoopUI.panel, "LoopUI panel element should be set");
|
||||
Assert.strictEqual(LoopUI.browser, null, "Browser element should not be there yet");
|
||||
Assert.strictEqual(LoopUI.selectedTab, null, "No tab should be selected yet");
|
||||
|
||||
// Load and show the Loop panel for the very first time this session.
|
||||
yield loadLoopPanel();
|
||||
Assert.ok(LoopUI.browser, "Browser element should be there");
|
||||
Assert.strictEqual(LoopUI.selectedTab, "rooms", "Initially the rooms tab should be selected");
|
||||
|
||||
// Hide the panel.
|
||||
yield LoopUI.togglePanel();
|
||||
Assert.strictEqual(LoopUI.selectedTab, "rooms", "Rooms tab should still be selected");
|
||||
|
||||
// Make sure the contacts tab shows up by simulating a login.
|
||||
MozLoopServiceInternal.fxAOAuthTokenData = fxASampleToken;
|
||||
MozLoopServiceInternal.fxAOAuthProfile = fxASampleProfile;
|
||||
yield MozLoopServiceInternal.notifyStatusChanged("login");
|
||||
|
||||
// Programmatically select the contacts tab.
|
||||
yield LoopUI.togglePanel(null, "contacts");
|
||||
Assert.strictEqual(LoopUI.selectedTab, "contacts", "Contacts tab should be selected now");
|
||||
|
||||
// Switch back to the rooms tab.
|
||||
yield LoopUI.openCallPanel(null, "rooms");
|
||||
Assert.strictEqual(LoopUI.selectedTab, "rooms", "Rooms tab should be selected now");
|
||||
|
||||
// Hide the panel.
|
||||
yield LoopUI.togglePanel();
|
||||
|
||||
// Logout to prevent interfering with the tests after this one.
|
||||
MozLoopServiceInternal.fxAOAuthTokenData =
|
||||
MozLoopServiceInternal.fxAOAuthProfile = null;
|
||||
yield MozLoopServiceInternal.notifyStatusChanged();
|
||||
});
|
||||
|
||||
add_task(function* test_doNotDisturb() {
|
||||
Assert.strictEqual(LoopUI.toolbarButton.node.getAttribute("state"), "", "Check button is in default state");
|
||||
yield MozLoopService.doNotDisturb = true;
|
||||
|
@ -77,8 +30,8 @@ add_task(function* test_doNotDisturb_with_login() {
|
|||
Assert.strictEqual(LoopUI.toolbarButton.node.getAttribute("state"), "", "Check button is in default state");
|
||||
yield MozLoopService.doNotDisturb = true;
|
||||
Assert.strictEqual(LoopUI.toolbarButton.node.getAttribute("state"), "disabled", "Check button is in disabled state");
|
||||
MozLoopServiceInternal.fxAOAuthTokenData = fxASampleToken;
|
||||
MozLoopServiceInternal.fxAOAuthProfile = fxASampleProfile;
|
||||
MozLoopServiceInternal.fxAOAuthTokenData = {token_type:"bearer",access_token:"1bad3e44b12f77a88fe09f016f6a37c42e40f974bc7a8b432bb0d2f0e37e1752",scope:"profile"};
|
||||
MozLoopServiceInternal.fxAOAuthProfile = {email: "test@example.com", uid: "abcd1234"};
|
||||
yield MozLoopServiceInternal.notifyStatusChanged("login");
|
||||
Assert.strictEqual(LoopUI.toolbarButton.node.getAttribute("state"), "active", "Check button is in active state");
|
||||
yield loadLoopPanel();
|
||||
|
@ -103,7 +56,7 @@ add_task(function* test_error_with_login() {
|
|||
Assert.strictEqual(LoopUI.toolbarButton.node.getAttribute("state"), "", "Check button is in default state");
|
||||
yield MozLoopServiceInternal.setError("testing", {});
|
||||
Assert.strictEqual(LoopUI.toolbarButton.node.getAttribute("state"), "error", "Check button is in error state");
|
||||
MozLoopServiceInternal.fxAOAuthProfile = fxASampleProfile;
|
||||
MozLoopServiceInternal.fxAOAuthProfile = {email: "test@example.com", uid: "abcd1234"};
|
||||
MozLoopServiceInternal.notifyStatusChanged("login");
|
||||
Assert.strictEqual(LoopUI.toolbarButton.node.getAttribute("state"), "error", "Check button is in error state");
|
||||
yield MozLoopServiceInternal.clearError("testing");
|
||||
|
@ -115,8 +68,8 @@ add_task(function* test_error_with_login() {
|
|||
|
||||
add_task(function* test_active() {
|
||||
Assert.strictEqual(LoopUI.toolbarButton.node.getAttribute("state"), "", "Check button is in default state");
|
||||
MozLoopServiceInternal.fxAOAuthTokenData = fxASampleToken;
|
||||
MozLoopServiceInternal.fxAOAuthProfile = fxASampleProfile;
|
||||
MozLoopServiceInternal.fxAOAuthTokenData = {token_type:"bearer",access_token:"1bad3e44b12f77a88fe09f016f6a37c42e40f974bc7a8b432bb0d2f0e37e1752",scope:"profile"};
|
||||
MozLoopServiceInternal.fxAOAuthProfile = {email: "test@example.com", uid: "abcd1234"};
|
||||
yield MozLoopServiceInternal.notifyStatusChanged("login");
|
||||
Assert.strictEqual(LoopUI.toolbarButton.node.getAttribute("state"), "active", "Check button is in active state");
|
||||
yield loadLoopPanel();
|
||||
|
|
|
@ -139,23 +139,23 @@ this.UITour = {
|
|||
["loop-newRoom", {
|
||||
infoPanelPosition: "leftcenter topright",
|
||||
query: (aDocument) => {
|
||||
let loopUI = aDocument.defaultView.LoopUI;
|
||||
if (loopUI.selectedTab != "rooms") {
|
||||
let loopBrowser = aDocument.querySelector("#loop-notification-panel > #loop-panel-iframe");
|
||||
if (!loopBrowser) {
|
||||
return null;
|
||||
}
|
||||
// Use the parentElement full-width container of the button so our arrow
|
||||
// doesn't overlap the panel contents much.
|
||||
return loopUI.browser.contentDocument.querySelector(".new-room-button").parentElement;
|
||||
return loopBrowser.contentDocument.querySelector(".new-room-button").parentElement;
|
||||
},
|
||||
}],
|
||||
["loop-roomList", {
|
||||
infoPanelPosition: "leftcenter topright",
|
||||
query: (aDocument) => {
|
||||
let loopUI = aDocument.defaultView.LoopUI;
|
||||
if (loopUI.selectedTab != "rooms") {
|
||||
let loopBrowser = aDocument.querySelector("#loop-notification-panel > #loop-panel-iframe");
|
||||
if (!loopBrowser) {
|
||||
return null;
|
||||
}
|
||||
return loopUI.browser.contentDocument.querySelector(".room-list");
|
||||
return loopBrowser.contentDocument.querySelector(".room-list");
|
||||
},
|
||||
}],
|
||||
["loop-selectedRoomButtons", {
|
||||
|
@ -178,7 +178,7 @@ this.UITour = {
|
|||
}],
|
||||
["loop-signInUpLink", {
|
||||
query: (aDocument) => {
|
||||
let loopBrowser = aDocument.defaultView.LoopUI.browser;
|
||||
let loopBrowser = aDocument.querySelector("#loop-notification-panel > #loop-panel-iframe");
|
||||
if (!loopBrowser) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ let loopPanel = document.getElementById("loop-notification-panel");
|
|||
|
||||
Components.utils.import("resource:///modules/UITour.jsm");
|
||||
const { LoopRooms } = Components.utils.import("resource:///modules/loop/LoopRooms.jsm", {});
|
||||
const { MozLoopServiceInternal } = Cu.import("resource:///modules/loop/MozLoopService.jsm", {});
|
||||
|
||||
function test() {
|
||||
UITourTest();
|
||||
|
@ -182,53 +181,6 @@ let tests = [
|
|||
});
|
||||
});
|
||||
},
|
||||
taskify(function* test_panelTabChangeNotifications() {
|
||||
// First make sure the Loop panel looks like we're logged in to have more than
|
||||
// just one tab to switch to.
|
||||
const fxASampleToken = {
|
||||
token_type: "bearer",
|
||||
access_token: "1bad3e44b12f77a88fe09f016f6a37c42e40f974bc7a8b432bb0d2f0e37e1752",
|
||||
scope: "profile"
|
||||
};
|
||||
const fxASampleProfile = {
|
||||
email: "test@example.com",
|
||||
uid: "abcd1234"
|
||||
};
|
||||
MozLoopServiceInternal.fxAOAuthTokenData = fxASampleToken;
|
||||
MozLoopServiceInternal.fxAOAuthProfile = fxASampleProfile;
|
||||
yield MozLoopServiceInternal.notifyStatusChanged("login");
|
||||
|
||||
// Show the Loop menu.
|
||||
yield showMenuPromise("loop");
|
||||
|
||||
// Listen for and test the notifications that will arrive from now on.
|
||||
let tabChangePromise = new Promise(resolve => {
|
||||
gContentAPI.observe((event, params) => {
|
||||
is(event, "Loop:PanelTabChanged", "Check Loop:PanelTabChanged notification");
|
||||
is(params, "contacts", "Check the tab name param");
|
||||
|
||||
gContentAPI.observe((event, params) => {
|
||||
is(event, "Loop:PanelTabChanged", "Check Loop:PanelTabChanged notification");
|
||||
is(params, "rooms", "Check the tab name param");
|
||||
|
||||
gContentAPI.observe((event, params) => {
|
||||
ok(false, "No more notifications should have arrived");
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Switch to the contacts tab.
|
||||
yield window.LoopUI.openCallPanel(null, "contacts");
|
||||
|
||||
// Logout. The panel tab will switch back to 'rooms'.
|
||||
MozLoopServiceInternal.fxAOAuthTokenData =
|
||||
MozLoopServiceInternal.fxAOAuthProfile = null;
|
||||
yield MozLoopServiceInternal.notifyStatusChanged();
|
||||
|
||||
yield tabChangePromise;
|
||||
}),
|
||||
runOffline(function test_notifyLoopChatWindowOpenedClosed(done) {
|
||||
gContentAPI.observe((event, params) => {
|
||||
is(event, "Loop:ChatWindowOpened", "Check Loop:ChatWindowOpened notification");
|
||||
|
|
Загрузка…
Ссылка в новой задаче