mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 906212 fix socialapi ui startup regressions, r=markh
This commit is contained in:
parent
75bf650b68
commit
17d2b6a41e
@ -111,7 +111,7 @@
|
||||
<command id="Browser:ToggleAddonBar" oncommand="toggleAddonBar();"/>
|
||||
<command id="Social:TogglePageMark" oncommand="SocialMark.togglePageMark();" disabled="true"/>
|
||||
<command id="Social:SharePage" oncommand="SocialShare.sharePage();" disabled="true"/>
|
||||
<command id="Social:ToggleSidebar" oncommand="Social.toggleSidebar();"/>
|
||||
<command id="Social:ToggleSidebar" oncommand="Social.toggleSidebar();" hidden="true"/>
|
||||
<command id="Social:ToggleNotifications" oncommand="Social.toggleNotifications();" hidden="true"/>
|
||||
<command id="Social:FocusChat" oncommand="SocialChatBar.focus();" hidden="true" disabled="true"/>
|
||||
<command id="Social:Toggle" oncommand="Social.toggle();" hidden="true"/>
|
||||
|
@ -45,9 +45,9 @@ SocialUI = {
|
||||
|
||||
if (!Social.initialized) {
|
||||
Social.init();
|
||||
} else if (Social.enabled) {
|
||||
// social was previously initialized, so it's not going to notify us of
|
||||
// anything, so handle that now.
|
||||
} else if (Social.providers.length > 0) {
|
||||
// Social was initialized during startup in a previous window. If we have
|
||||
// providers enabled initialize the UI for this window.
|
||||
this.observe(null, "social:providers-changed", null);
|
||||
this.observe(null, "social:provider-set", Social.provider ? Social.provider.origin : null);
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
// Test the top-level window UI for social.
|
||||
|
||||
let SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
|
||||
|
||||
// This function should "reset" Social such that the next time Social.init()
|
||||
// is called (eg, when a new window is opened), it re-performs all
|
||||
// initialization.
|
||||
@ -12,7 +14,6 @@ function resetSocial() {
|
||||
Social._provider = null;
|
||||
Social.providers = [];
|
||||
// *sob* - listeners keep getting added...
|
||||
let SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
|
||||
SocialService._providerListeners.clear();
|
||||
}
|
||||
|
||||
@ -52,9 +53,10 @@ function test() {
|
||||
}
|
||||
|
||||
let tests = {
|
||||
// check when social is totally disabled at startup (ie, no providers)
|
||||
// check when social is totally disabled at startup (ie, no providers enabled)
|
||||
testInactiveStartup: function(cbnext) {
|
||||
is(Social.providers.length, 0, "needs zero providers to start this test.");
|
||||
ok(!SocialService.hasEnabledProviders, "no providers are enabled");
|
||||
resetSocial();
|
||||
openWindowAndWaitForInit(function(w1) {
|
||||
checkSocialUI(w1);
|
||||
@ -67,12 +69,13 @@ let tests = {
|
||||
});
|
||||
},
|
||||
|
||||
// Check when providers exist and social is turned on at startup.
|
||||
// Check when providers are enabled and social is turned on at startup.
|
||||
testEnabledStartup: function(cbnext) {
|
||||
runSocialTestWithProvider(manifest, function (finishcb) {
|
||||
resetSocial();
|
||||
openWindowAndWaitForInit(function(w1) {
|
||||
ok(Social.enabled, "social is enabled");
|
||||
ok(SocialService.hasEnabledProviders, "providers are enabled");
|
||||
checkSocialUI(w1);
|
||||
// now init is complete, open a second window
|
||||
openWindowAndWaitForInit(function(w2) {
|
||||
@ -91,11 +94,13 @@ let tests = {
|
||||
}, cbnext);
|
||||
},
|
||||
|
||||
// Check when providers exist but social is turned off at startup.
|
||||
// Check when providers are enabled but social is turned off at startup.
|
||||
testDisabledStartup: function(cbnext) {
|
||||
runSocialTestWithProvider(manifest, function (finishcb) {
|
||||
setManifestPref("social.manifest.test", manifest);
|
||||
SocialService.addProvider(manifest, function (provider) {
|
||||
Services.prefs.setBoolPref("social.enabled", false);
|
||||
resetSocial();
|
||||
ok(SocialService.hasEnabledProviders, "providers are enabled");
|
||||
openWindowAndWaitForInit(function(w1) {
|
||||
ok(!Social.enabled, "social is disabled");
|
||||
checkSocialUI(w1);
|
||||
@ -109,36 +114,36 @@ let tests = {
|
||||
ok(Social.enabled, "social is enabled");
|
||||
checkSocialUI(w2);
|
||||
checkSocialUI(w1);
|
||||
finishcb();
|
||||
});
|
||||
});
|
||||
});
|
||||
}, cbnext);
|
||||
},
|
||||
|
||||
// Check when the last provider is removed.
|
||||
testRemoveProvider: function(cbnext) {
|
||||
runSocialTestWithProvider(manifest, function (finishcb) {
|
||||
openWindowAndWaitForInit(function(w1) {
|
||||
checkSocialUI(w1);
|
||||
// now init is complete, open a second window
|
||||
openWindowAndWaitForInit(function(w2) {
|
||||
checkSocialUI(w2);
|
||||
// remove the current provider.
|
||||
let SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
|
||||
SocialService.removeProvider(manifest.origin, function() {
|
||||
ok(!Social.enabled, "social is disabled");
|
||||
is(Social.providers.length, 0, "no providers");
|
||||
checkSocialUI(w2);
|
||||
checkSocialUI(w1);
|
||||
// *sob* - runSocialTestWithProvider's cleanup fails when it can't
|
||||
// remove the provider, so re-add it.
|
||||
SocialService.addProvider(manifest, function() {
|
||||
finishcb();
|
||||
SocialService.removeProvider(manifest.origin, function() {
|
||||
Services.prefs.clearUserPref("social.manifest.test");
|
||||
cbnext();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}, cbnext);
|
||||
},
|
||||
|
||||
// Check when the last provider is disabled.
|
||||
testRemoveProvider: function(cbnext) {
|
||||
setManifestPref("social.manifest.test", manifest);
|
||||
SocialService.addProvider(manifest, function (provider) {
|
||||
openWindowAndWaitForInit(function(w1) {
|
||||
checkSocialUI(w1);
|
||||
// now init is complete, open a second window
|
||||
openWindowAndWaitForInit(function(w2) {
|
||||
checkSocialUI(w2);
|
||||
// disable the current provider.
|
||||
SocialService.removeProvider(manifest.origin, function() {
|
||||
ok(!Social.enabled, "social is disabled");
|
||||
is(Social.providers.length, 0, "no providers");
|
||||
checkSocialUI(w2);
|
||||
checkSocialUI(w1);
|
||||
Services.prefs.clearUserPref("social.manifest.test");
|
||||
cbnext();
|
||||
});
|
||||
});
|
||||
});
|
||||
}, cbnext);
|
||||
},
|
||||
}
|
||||
|
@ -194,6 +194,7 @@ function runSocialTests(tests, cbPreTest, cbPostTest, cbFinish) {
|
||||
// A fairly large hammer which checks all aspects of the SocialUI for
|
||||
// internal consistency.
|
||||
function checkSocialUI(win) {
|
||||
let SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
|
||||
win = win || window;
|
||||
let doc = win.document;
|
||||
let provider = Social.provider;
|
||||
@ -201,6 +202,14 @@ function checkSocialUI(win) {
|
||||
let active = Social.providers.length > 0 && !win.SocialUI._chromeless &&
|
||||
!PrivateBrowsingUtils.isWindowPrivate(win);
|
||||
|
||||
// if we have enabled providers, we should also have instances of those
|
||||
// providers
|
||||
if (SocialService.hasEnabledProviders) {
|
||||
ok(Social.providers.length > 0, "providers are enabled");
|
||||
} else {
|
||||
is(Social.providers.length, 0, "providers are not enabled");
|
||||
}
|
||||
|
||||
// some local helpers to avoid log-spew for the many checks made here.
|
||||
let numGoodTests = 0, numTests = 0;
|
||||
function _ok(what, msg) {
|
||||
@ -246,6 +255,7 @@ function checkSocialUI(win) {
|
||||
|
||||
// and for good measure, check all the social commands.
|
||||
isbool(!doc.getElementById("Social:Toggle").hidden, active, "Social:Toggle visible?");
|
||||
isbool(!doc.getElementById("Social:ToggleSidebar").hidden, enabled, "Social:ToggleSidebar visible?");
|
||||
isbool(!doc.getElementById("Social:ToggleNotifications").hidden, enabled, "Social:ToggleNotifications visible?");
|
||||
isbool(!doc.getElementById("Social:FocusChat").hidden, enabled, "Social:FocusChat visible?");
|
||||
isbool(doc.getElementById("Social:FocusChat").getAttribute("disabled"), enabled ? "false" : "true", "Social:FocusChat disabled?");
|
||||
|
@ -158,8 +158,9 @@ this.Social = {
|
||||
return;
|
||||
}
|
||||
this.initialized = true;
|
||||
|
||||
if (SocialService.enabled) {
|
||||
// if SocialService.hasEnabledProviders, retreive the providers so the
|
||||
// front-end can generate UI
|
||||
if (SocialService.hasEnabledProviders) {
|
||||
// Retrieve the current set of providers, and set the current provider.
|
||||
SocialService.getOrderedProviderList(function (providers) {
|
||||
Social._updateProviderCache(providers);
|
||||
|
@ -350,6 +350,16 @@ function schedule(callback) {
|
||||
|
||||
// Public API
|
||||
this.SocialService = {
|
||||
get hasEnabledProviders() {
|
||||
// used as an optimization during startup, can be used to check if further
|
||||
// initialization should be done (e.g. creating the instances of
|
||||
// SocialProvider and turning on UI). ActiveProviders may have changed and
|
||||
// not yet flushed so we check the active providers array
|
||||
for (let p in ActiveProviders._providers) {
|
||||
return true;
|
||||
};
|
||||
return false;
|
||||
},
|
||||
get enabled() {
|
||||
return SocialServiceInternal.enabled;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user