зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1080948: UITour: tell the page when a URL is copied or emailed. r=MattN,dmose
This commit is contained in:
Родитель
4fbbe9c72d
Коммит
1d577898d9
|
@ -570,6 +570,27 @@ this.LoopRooms = {
|
|||
return LoopRoomsInternal.maybeRefresh(user);
|
||||
},
|
||||
|
||||
/**
|
||||
* This method is only useful for unit tests to set the rooms cache to contain
|
||||
* a list of fake room data that can be asserted in tests.
|
||||
*
|
||||
* @param {Map} stub Stub cache containing fake rooms data
|
||||
*/
|
||||
stubCache: function(stub) {
|
||||
LoopRoomsInternal.rooms.clear();
|
||||
if (stub) {
|
||||
// Fill up the rooms cache with room objects provided in the `stub` Map.
|
||||
for (let [key, value] of stub.entries()) {
|
||||
LoopRoomsInternal.rooms.set(key, value);
|
||||
}
|
||||
gDirty = false;
|
||||
} else {
|
||||
// Restore the cache to not be stubbed anymore, but it'll need a refresh
|
||||
// from the server for sure.
|
||||
gDirty = true;
|
||||
}
|
||||
},
|
||||
|
||||
promise: function(method, ...params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this[method](...params, (error, result) => {
|
||||
|
|
|
@ -23,6 +23,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "hookWindowCloseForPanelClose",
|
|||
"resource://gre/modules/MozSocialAPI.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
|
||||
"resource://gre/modules/PluralForm.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "UITour",
|
||||
"resource:///modules/UITour.jsm");
|
||||
XPCOMUtils.defineLazyGetter(this, "appInfo", function() {
|
||||
return Cc["@mozilla.org/xre/app-info;1"]
|
||||
.getService(Ci.nsIXULAppInfo)
|
||||
|
@ -735,7 +737,21 @@ function injectLoopAPI(targetWindow) {
|
|||
callId: callid
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Notifies the UITour module that an event occurred that it might be
|
||||
* interested in.
|
||||
*
|
||||
* @param {String} subject Subject of the notification
|
||||
*/
|
||||
notifyUITour: {
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
value: function(subject) {
|
||||
UITour.notify(subject);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
function onStatusChanged(aSubject, aTopic, aData) {
|
||||
|
|
|
@ -298,6 +298,7 @@ loop.store = loop.store || {};
|
|||
*/
|
||||
copyRoomUrl: function(actionData) {
|
||||
this._mozLoop.copyString(actionData.roomUrl);
|
||||
this._mozLoop.notifyUITour("Loop:RoomURLCopied");
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -307,6 +308,7 @@ loop.store = loop.store || {};
|
|||
*/
|
||||
emailRoomUrl: function(actionData) {
|
||||
loop.shared.utils.composeCallUrlEmail(actionData.roomUrl);
|
||||
this._mozLoop.notifyUITour("Loop:RoomURLEmailed");
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -103,6 +103,58 @@ let tests = [
|
|||
});
|
||||
LoopRooms.open("fakeTourRoom");
|
||||
},
|
||||
function test_notifyLoopRoomURLCopied(done) {
|
||||
gContentAPI.observe((event, params) => {
|
||||
is(event, "Loop:ChatWindowOpened", "Loop chat window should've opened");
|
||||
gContentAPI.observe((event, params) => {
|
||||
is(event, "Loop:ChatWindowShown", "Check Loop:ChatWindowShown notification");
|
||||
|
||||
let chat = document.querySelector("#pinnedchats > chatbox");
|
||||
gContentAPI.observe((event, params) => {
|
||||
is(event, "Loop:RoomURLCopied", "Check Loop:RoomURLCopied notification");
|
||||
gContentAPI.observe((event, params) => {
|
||||
is(event, "Loop:ChatWindowClosed", "Check Loop:ChatWindowClosed notification");
|
||||
});
|
||||
chat.close();
|
||||
done();
|
||||
});
|
||||
chat.content.contentDocument.querySelector(".btn-copy").click();
|
||||
});
|
||||
});
|
||||
setupFakeRoom();
|
||||
LoopRooms.open("fakeTourRoom");
|
||||
},
|
||||
function test_notifyLoopRoomURLEmailed(done) {
|
||||
gContentAPI.observe((event, params) => {
|
||||
is(event, "Loop:ChatWindowOpened", "Loop chat window should've opened");
|
||||
gContentAPI.observe((event, params) => {
|
||||
is(event, "Loop:ChatWindowShown", "Check Loop:ChatWindowShown notification");
|
||||
|
||||
let chat = document.querySelector("#pinnedchats > chatbox");
|
||||
let composeEmailCalled = false;
|
||||
|
||||
gContentAPI.observe((event, params) => {
|
||||
is(event, "Loop:RoomURLEmailed", "Check Loop:RoomURLEmailed notification");
|
||||
ok(composeEmailCalled, "mozLoop.composeEmail should be called");
|
||||
gContentAPI.observe((event, params) => {
|
||||
is(event, "Loop:ChatWindowClosed", "Check Loop:ChatWindowClosed notification");
|
||||
});
|
||||
chat.close();
|
||||
done();
|
||||
});
|
||||
|
||||
let chatWin = chat.content.contentWindow;
|
||||
let oldComposeEmail = chatWin.navigator.wrappedJSObject.mozLoop.composeEmail;
|
||||
chatWin.navigator.wrappedJSObject.mozLoop.composeEmail = function(recipient, subject, body) {
|
||||
ok(recipient, "composeEmail should be invoked with at least a recipient value");
|
||||
composeEmailCalled = true;
|
||||
chatWin.navigator.wrappedJSObject.mozLoop.composeEmail = oldComposeEmail;
|
||||
};
|
||||
chatWin.document.querySelector(".btn-email").click();
|
||||
});
|
||||
});
|
||||
LoopRooms.open("fakeTourRoom");
|
||||
},
|
||||
taskify(function* test_arrow_panel_position() {
|
||||
ise(loopButton.open, false, "Menu should initially be closed");
|
||||
let popup = document.getElementById("UITourTooltip");
|
||||
|
@ -132,6 +184,15 @@ function checkLoopPanelIsHidden() {
|
|||
is(loopButton.hasAttribute("open"), false, "Loop button should know that the panel is closed");
|
||||
}
|
||||
|
||||
function setupFakeRoom() {
|
||||
let room = {};
|
||||
for (let prop of ["roomToken", "roomName", "roomOwner", "roomUrl", "participants"])
|
||||
room[prop] = "fakeTourRoom";
|
||||
LoopRooms.stubCache(new Map([
|
||||
[room.roomToken, room]
|
||||
]));
|
||||
}
|
||||
|
||||
if (Services.prefs.getBoolPref("loop.enabled")) {
|
||||
loopButton = window.LoopUI.toolbarButton.node;
|
||||
// The targets to highlight only appear after getting started is launched.
|
||||
|
|
Загрузка…
Ссылка в новой задаче