Bug 1002914 (part 2) - remove SocialChatBar, add chat specific tests and refactor social tests. r=mixedpuppy
This commit is contained in:
@@ -399,7 +399,7 @@ function get3ChatsForCollapsing(mode, cb) {
|
||||
// To make our life easier we don't go via the worker and ports so we get
|
||||
// more control over creation *and* to make the code much simpler. We
|
||||
// assume the worker/port stuff is individually tested above.
|
||||
let chatbar = window.SocialChatBar.chatbar;
|
||||
let chatbar = getChatBar();
|
||||
let chatWidth = undefined;
|
||||
let num = 0;
|
||||
is(chatbar.childNodes.length, 0, "chatbar starting empty");
|
||||
@@ -443,23 +443,21 @@ function makeChat(mode, uniqueid, cb) {
|
||||
info("making a chat window '" + uniqueid +"'");
|
||||
let provider = SocialSidebar.provider;
|
||||
const chatUrl = provider.origin + "/browser/browser/base/content/test/social/social_chat.html";
|
||||
let isOpened = window.SocialChatBar.openChat(provider, chatUrl + "?id=" + uniqueid, function(chat) {
|
||||
// Note that we use promiseChatLoaded instead of the callback to ensure the
|
||||
// content has started loading.
|
||||
let chatbox = getChatBar().openChat(provider.origin, provider.name,
|
||||
chatUrl + "?id=" + uniqueid, mode);
|
||||
chatbox.promiseChatLoaded.then(
|
||||
() => {
|
||||
info("chat window has opened");
|
||||
// we can't callback immediately or we might close the chat during
|
||||
// this event which upsets the implementation - it is only 1/2 way through
|
||||
// handling the load event.
|
||||
chat.document.title = uniqueid;
|
||||
executeSoon(cb);
|
||||
}, mode);
|
||||
if (!isOpened) {
|
||||
ok(false, "unable to open chat window, no provider? more failures to come");
|
||||
executeSoon(cb);
|
||||
}
|
||||
chatbox.contentDocument.title = uniqueid;
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
||||
function checkPopup() {
|
||||
// popup only showing if any collapsed popup children.
|
||||
let chatbar = window.SocialChatBar.chatbar;
|
||||
let chatbar = getChatBar();
|
||||
let numCollapsed = 0;
|
||||
for (let chat of chatbar.childNodes) {
|
||||
if (chat.collapsed) {
|
||||
@@ -478,7 +476,7 @@ function checkPopup() {
|
||||
// Does a callback passing |true| if the window is now big enough or false
|
||||
// if we couldn't resize large enough to satisfy the test requirement.
|
||||
function resizeWindowToChatAreaWidth(desired, cb, count = 0) {
|
||||
let current = window.SocialChatBar.chatbar.getBoundingClientRect().width;
|
||||
let current = getChatBar().getBoundingClientRect().width;
|
||||
let delta = desired - current;
|
||||
info(count + ": resizing window so chat area is " + desired + " wide, currently it is "
|
||||
+ current + ". Screen avail is " + window.screen.availWidth
|
||||
@@ -511,7 +509,7 @@ function resizeWindowToChatAreaWidth(desired, cb, count = 0) {
|
||||
}
|
||||
function resize_handler(event) {
|
||||
// we did resize - but did we get far enough to be able to continue?
|
||||
let newSize = window.SocialChatBar.chatbar.getBoundingClientRect().width;
|
||||
let newSize = getChatBar().getBoundingClientRect().width;
|
||||
let sizedOk = widthDeltaCloseEnough(newSize - desired);
|
||||
if (!sizedOk)
|
||||
return;
|
||||
@@ -559,8 +557,13 @@ function resizeAndCheckWidths(first, second, third, checks, cb) {
|
||||
}, count);
|
||||
}
|
||||
|
||||
function getChatBar() {
|
||||
return document.getElementById("pinnedchats");
|
||||
}
|
||||
|
||||
function getPopupWidth() {
|
||||
let popup = window.SocialChatBar.chatbar.menupopup;
|
||||
let chatbar = getChatBar();
|
||||
let popup = chatbar.menupopup;
|
||||
ok(!popup.parentNode.collapsed, "asking for popup width when it is visible");
|
||||
let cs = document.defaultView.getComputedStyle(popup.parentNode);
|
||||
let margins = parseInt(cs.marginLeft) + parseInt(cs.marginRight);
|
||||
@@ -568,6 +571,8 @@ function getPopupWidth() {
|
||||
}
|
||||
|
||||
function closeAllChats() {
|
||||
let chatbar = window.SocialChatBar.chatbar;
|
||||
chatbar.removeAll();
|
||||
let chatbar = getChatBar();
|
||||
while (chatbar.selectedChat) {
|
||||
chatbar.selectedChat.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user