mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 14:55:47 +00:00
bug 914435 fix toolbaritem handling of ambient frames, r=markh
This commit is contained in:
parent
aa41d6f1f2
commit
0268c6abf3
@ -159,10 +159,11 @@ SocialUI = {
|
||||
}
|
||||
break;
|
||||
case "social:profile-changed":
|
||||
// make sure anything that happens here only affects the provider for
|
||||
// which the profile is changing, and that anything we call actually
|
||||
// needs to change based on profile data.
|
||||
if (this._matchesCurrentProvider(data)) {
|
||||
SocialToolbar.updateProvider();
|
||||
SocialMarks.update();
|
||||
SocialChatBar.update();
|
||||
}
|
||||
break;
|
||||
case "social:frameworker-error":
|
||||
@ -868,17 +869,19 @@ SocialToolbar = {
|
||||
toggleNotificationsCommand.setAttribute("hidden", !socialEnabled);
|
||||
|
||||
let parent = document.getElementById("social-notification-panel");
|
||||
while (parent.hasChildNodes()) {
|
||||
let frame = parent.firstChild;
|
||||
SharedFrame.forgetGroup(frame.id);
|
||||
parent.removeChild(frame);
|
||||
}
|
||||
|
||||
let tbi = document.getElementById("social-provider-button");
|
||||
if (tbi) {
|
||||
// buttons after social-provider-button are ambient icons
|
||||
// buttons after social-provider-button are ambient icons, remove the
|
||||
// button and the attached shared frame.
|
||||
while (tbi.nextSibling) {
|
||||
tbi.parentNode.removeChild(tbi.nextSibling);
|
||||
let tb = tbi.nextSibling;
|
||||
let nid = tb.getAttribute("notificationFrameId");
|
||||
let frame = document.getElementById(nid);
|
||||
if (frame) {
|
||||
SharedFrame.forgetGroup(frame.id);
|
||||
parent.removeChild(frame);
|
||||
}
|
||||
tbi.parentNode.removeChild(tb);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -2,18 +2,36 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
let manifest = { // normal provider
|
||||
name: "provider 1",
|
||||
let manifests = [{ // normal provider
|
||||
name: "provider example.com",
|
||||
origin: "https://example.com",
|
||||
workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js",
|
||||
iconURL: "https://example.com/browser/browser/base/content/test/moz.png"
|
||||
};
|
||||
}, { // used for testing install
|
||||
name: "provider test1",
|
||||
origin: "https://test1.example.com",
|
||||
statusURL: "https://test1.example.com/browser/browser/base/content/test/social/social_panel.html",
|
||||
iconURL: "https://test1.example.com/browser/browser/base/content/test/moz.png",
|
||||
}];
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
runSocialTestWithProvider(manifest, function (finishcb) {
|
||||
runSocialTests(tests, undefined, undefined, finishcb);
|
||||
// required to test status button in combination with the toolbaritem
|
||||
Services.prefs.setBoolPref("social.allowMultipleWorkers", true);
|
||||
|
||||
// Preset the currentSet so the statusbutton is in the toolbar on addition. We
|
||||
// bypass the SocialStatus class here since it requires the manifest already
|
||||
// be installed.
|
||||
let tbh = SocialStatus._toolbarHelper;
|
||||
tbh.setPersistentPosition(tbh.idFromOrgin(manifests[1].origin));
|
||||
|
||||
runSocialTestWithProvider(manifests, function (finishcb) {
|
||||
runSocialTests(tests, undefined, undefined, function() {
|
||||
Services.prefs.clearUserPref("social.allowMultipleWorkers");
|
||||
SocialStatus.removePosition(manifests[1].origin);
|
||||
finishcb();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -37,7 +55,7 @@ var tests = {
|
||||
},
|
||||
testProfileSet: function(next) {
|
||||
let statusIcon = document.getElementById("social-provider-button").style.listStyleImage;
|
||||
is(statusIcon, "url(\"" + manifest.iconURL + "\")", "manifest iconURL is showing");
|
||||
is(statusIcon, "url(\"" + manifests[0].iconURL + "\")", "manifest iconURL is showing");
|
||||
let profile = {
|
||||
portrait: "https://example.com/portrait.jpg",
|
||||
userName: "trickster",
|
||||
@ -167,14 +185,32 @@ var tests = {
|
||||
}, "statusIcon was never found");
|
||||
},
|
||||
testProfileUnset: function(next) {
|
||||
Social.provider.updateUserProfile({});
|
||||
// check dom values
|
||||
let ambientIcons = document.querySelectorAll("#social-toolbar-item > box");
|
||||
for (let ambientIcon of ambientIcons) {
|
||||
ok(ambientIcon.collapsed, "ambient icon (" + ambientIcon.id + ") is collapsed");
|
||||
}
|
||||
let panel = document.getElementById("social-notification-panel");
|
||||
// load the status button for provider 2
|
||||
let provider = Social._getProviderFromOrigin(manifests[1].origin);
|
||||
let id = SocialStatus._toolbarHelper.idFromOrgin(provider.origin);
|
||||
let btn = document.getElementById(id)
|
||||
ok(btn, "got a status button");
|
||||
// cheat a little, we want the iframe for the status button to be created,
|
||||
// not testing the statusbutton itself here.
|
||||
SocialStatus._attachNotificatonPanel(btn, provider);
|
||||
|
||||
let numIcons = Object.keys(Social.provider.ambientNotificationIcons).length;
|
||||
let ambientIcons = document.querySelectorAll("#social-toolbar-item > toolbarbutton[type='badged']");
|
||||
is(numIcons, ambientIcons.length, "all ambient icons exist");
|
||||
is(panel.childNodes.length, ambientIcons.length + 1, "frames all exist");
|
||||
|
||||
next();
|
||||
// we need to wait until after social:profile-changed has completed
|
||||
waitForNotification("social:profile-changed", function() {
|
||||
// let the notifications finish first
|
||||
executeSoon(function() {
|
||||
let icons = document.querySelectorAll("#social-toolbar-item > toolbarbutton[type='badged']");
|
||||
is(icons.length, 0, "ambient icons have been removed");
|
||||
is(panel.childNodes.length, 1, "frame still exists");
|
||||
next();
|
||||
});
|
||||
});
|
||||
Social.provider.updateUserProfile({});
|
||||
},
|
||||
testMenuitemsExist: function(next) {
|
||||
let toggleSidebarMenuitems = document.getElementsByClassName("social-toggle-sidebar-menuitem");
|
||||
@ -194,5 +230,5 @@ var tests = {
|
||||
is(cmd.getAttribute("checked"), enabled ? "true" : "false");
|
||||
Services.prefs.clearUserPref("social.toast-notifications.enabled");
|
||||
next();
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -298,6 +298,14 @@ function checkSocialUI(win) {
|
||||
is(numGoodTests, numTests, "The Social UI tests succeeded.")
|
||||
}
|
||||
|
||||
function waitForNotification(topic, cb) {
|
||||
function observer(subject, topic, data) {
|
||||
Services.obs.removeObserver(observer, topic);
|
||||
cb();
|
||||
}
|
||||
Services.obs.addObserver(observer, topic, false);
|
||||
}
|
||||
|
||||
// blocklist testing
|
||||
function updateBlocklist(aCallback) {
|
||||
var blocklistNotifier = Cc["@mozilla.org/extensions/blocklist;1"]
|
||||
|
Loading…
Reference in New Issue
Block a user