author | Shane Caraveo <scaraveo@mozilla.com> |
Mon, 30 Sep 2013 11:05:17 -0700 | |
changeset 149343 | 3fb7c71990d06392ec23a41a089ce6bff37afe15 |
parent 149309 | 1cae2cc4b5c17b0be10e98df2e19d6d2ddb249a4 |
child 149344 | 533241317d0f430971f66f11aa8dd688c0da0408 |
push id | 25385 |
push user | emorley@mozilla.com |
push date | Tue, 01 Oct 2013 09:25:32 +0000 |
treeherder | mozilla-central@a55240c523be [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | markh |
bugs | 914435 |
milestone | 27.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/browser/base/content/browser-social.js +++ b/browser/base/content/browser-social.js @@ -154,20 +154,21 @@ SocialUI = { case "social:ambient-notification-changed": SocialStatus.updateNotification(data); if (this._matchesCurrentProvider(data)) { SocialToolbar.updateButton(); SocialMenu.populate(); } 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": if (this.enabled && Social.provider.origin == data) { SocialSidebar.setSidebarErrorMessage(); } break; @@ -1441,19 +1442,29 @@ SocialStatus = { return; let tbh = this._toolbarHelper; tbh.removePersistence(tbh.idFromOrgin(origin)); }, removeProvider: function(origin) { if (!Social.allowMultipleWorkers) return; + this._removeFrame(origin); this._toolbarHelper.removeProviderButton(origin); }, + _removeFrame: function(origin) { + let notificationFrameId = "social-status-" + origin; + let frame = document.getElementById(notificationFrameId); + if (frame) { + SharedFrame.forgetGroup(frame.id); + frame.parentNode.removeChild(frame); + } + }, + get _toolbarHelper() { delete this._toolbarHelper; this._toolbarHelper = new ToolbarHelper("social-status-button", this._createButton.bind(this)); return this._toolbarHelper; }, get _dynamicResizer() { delete this._dynamicResizer;
--- a/browser/base/content/test/social/Makefile.in +++ b/browser/base/content/test/social/Makefile.in @@ -26,16 +26,17 @@ MOCHITEST_BROWSER_FILES = \ browser_social_status.js \ browser_social_window.js \ social_activate.html \ social_activate_iframe.html \ browser_share.js \ social_panel.html \ social_mark.html \ social_sidebar.html \ + social_sidebar_empty.html \ social_chat.html \ social_flyout.html \ social_window.html \ social_worker.js \ share.html \ checked.jpg \ unchecked.jpg \ $(NULL)
--- a/browser/base/content/test/social/browser_social_toolbar.js +++ b/browser/base/content/test/social/browser_social_toolbar.js @@ -1,24 +1,42 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * 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 +let manifests = [{ name: "provider 1", origin: "https://example.com", - workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js", + sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar_empty.html", iconURL: "https://example.com/browser/browser/base/content/test/general/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/general/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(); + }); }); } var tests = { testProfileNone: function(next, useNull) { let profile = useNull ? null : {}; Social.provider.updateUserProfile(profile); // check dom values @@ -32,17 +50,17 @@ var tests = { is(userButton.getAttribute("label"), notLoggedInStatusValue, "label reflects not being logged in"); next(); }, testProfileNull: function(next) { this.testProfileNone(next, true); }, 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", displayName: "Kuma Lisa", profileURL: "http://example.com/Kuma_Lisa", iconURL: "https://example.com/browser/browser/base/content/test/general/moz.png" } Social.provider.updateUserProfile(profile); @@ -161,26 +179,16 @@ var tests = { let menuitem = socialToggleMore.querySelector(".ambient-menuitem"); is(menuitem.getAttribute("label"), "Test Ambient 1 \u2046", "Keyboard accessible ambient menuitem should have specified label"); toolsPopup.hidePopup(); next(); }, false); document.getElementById("menu_ToolsPopup").openPopup(); }, "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"); - } - - next(); - }, testMenuitemsExist: function(next) { let toggleSidebarMenuitems = document.getElementsByClassName("social-toggle-sidebar-menuitem"); is(toggleSidebarMenuitems.length, 2, "Toggle Sidebar menuitems exist"); let toggleDesktopNotificationsMenuitems = document.getElementsByClassName("social-toggle-notifications-menuitem"); is(toggleDesktopNotificationsMenuitems.length, 2, "Toggle notifications menuitems exist"); let toggleSocialMenuitems = document.getElementsByClassName("social-toggle-menuitem"); is(toggleSocialMenuitems.length, 2, "Toggle Social menuitems exist"); next(); @@ -189,10 +197,10 @@ var tests = { let enabled = Services.prefs.getBoolPref("social.toast-notifications.enabled"); let cmd = document.getElementById("Social:ToggleNotifications"); is(cmd.getAttribute("checked"), enabled ? "true" : "false"); enabled = !enabled; Services.prefs.setBoolPref("social.toast-notifications.enabled", enabled); is(cmd.getAttribute("checked"), enabled ? "true" : "false"); Services.prefs.clearUserPref("social.toast-notifications.enabled"); next(); - }, + } }
--- a/browser/base/content/test/social/browser_social_window.js +++ b/browser/base/content/test/social/browser_social_window.js @@ -26,22 +26,34 @@ function openWindowAndWaitForInit(callba createdWindows.push(w); Services.obs.addObserver(function providerSet(subject, topic, data) { Services.obs.removeObserver(providerSet, topic); info(topic + " observer was notified - continuing test"); executeSoon(() => callback(w)); }, topic, false); } +function closeOneWindow(cb) { + let w = createdWindows.pop(); + if (!w) { + cb(); + return; + } + waitForCondition(function() w.closed, + function() { + closeOneWindow(cb); + }, "window did not close"); + w.close(); +} + function postTestCleanup(cb) { - for (let w of createdWindows) - w.close(); - createdWindows = []; - Services.prefs.clearUserPref("social.enabled"); - cb(); + closeOneWindow(function() { + Services.prefs.clearUserPref("social.enabled"); + cb(); + }); } let manifest = { // normal provider name: "provider 1", origin: "https://example.com", sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html", workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js", iconURL: "https://example.com/browser/browser/base/content/test/general/moz.png"
--- a/browser/base/content/test/social/head.js +++ b/browser/base/content/test/social/head.js @@ -293,16 +293,24 @@ function checkSocialUI(win) { isbool(doc.getElementById("Social:FocusChat").getAttribute("disabled"), enabled ? "false" : "true", "Social:FocusChat disabled?"); // broadcasters. isbool(!doc.getElementById("socialActiveBroadcaster").hidden, active, "socialActiveBroadcaster hidden?"); // and report on overall success of failure of the various checks here. 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"] .getService(Ci.nsITimerCallback); var observer = function() { Services.obs.removeObserver(observer, "blocklist-updated"); if (aCallback) executeSoon(aCallback);