Bug 983481 open a post activation landing page, r=markh

This commit is contained in:
Shane Caraveo 2014-04-30 12:08:23 -07:00
Родитель 7d5d7cf33b
Коммит bfbf27d0ac
6 изменённых файлов: 36 добавлений и 6 удалений

Просмотреть файл

@ -233,6 +233,9 @@ SocialUI = {
if (provider.sidebarURL) {
SocialSidebar.show(provider.origin);
}
if (provider.postActivationURL) {
openUILinkIn(provider.postActivationURL, "tab");
}
});
});
},

Просмотреть файл

@ -17,6 +17,7 @@ support-files =
social_flyout.html
social_mark.html
social_panel.html
social_postActivation.html
social_sidebar.html
social_sidebar_empty.html
social_window.html

Просмотреть файл

@ -90,9 +90,12 @@ function waitForProviderLoad(cb) {
waitForCondition(function() {
let sbrowser = document.getElementById("social-sidebar-browser");
let provider = SocialSidebar.provider;
let postActivation = provider && gBrowser.contentDocument.location.href == provider.origin + "/browser/browser/base/content/test/social/social_postActivation.html";
return provider &&
provider.profile &&
provider.profile.displayName &&
postActivation &&
sbrowser.docShellIsActive;
}, function() {
// executeSoon to let the browser UI observers run first
@ -290,6 +293,9 @@ var tests = {
let prefname = addBuiltinManifest(gProviders[0]);
activateOneProvider(gProviders[0], true, function() {
info("first activation completed");
is(gBrowser.contentDocument.location.href, gProviders[0].origin + "/browser/browser/base/content/test/social/social_postActivation.html");
gBrowser.removeTab(gBrowser.selectedTab);
is(gBrowser.contentDocument.location.href, gProviders[0].origin + "/browser/browser/base/content/test/social/social_activate.html");
gBrowser.removeTab(gBrowser.selectedTab);
tabsToRemove.pop();
// uninstall the provider
@ -297,6 +303,8 @@ var tests = {
checkSocialUI();
activateOneProvider(gProviders[0], true, function() {
info("second activation completed");
is(gBrowser.contentDocument.location.href, gProviders[0].origin + "/browser/browser/base/content/test/social/social_postActivation.html");
gBrowser.removeTab(gBrowser.selectedTab);
// after closing the addons tab, verify provider is still installed
gBrowser.tabContainer.addEventListener("TabClose", function onTabClose() {

Просмотреть файл

@ -15,6 +15,7 @@ var data = {
"sidebarURL": "/browser/browser/base/content/test/social/social_sidebar.html",
"workerURL": "/browser/browser/base/content/test/social/social_worker.js",
"statusURL": "/browser/browser/base/content/test/social/social_panel.html",
"postActivationURL": "/browser/browser/base/content/test/social/social_postActivation.html",
// should be available for display purposes
"description": "A short paragraph about this provider",

Просмотреть файл

@ -0,0 +1,11 @@
<html>
<head>
<title>Post-Activation test</title>
</head>
<body>
Post Activation landing page
</body>
</html>

Просмотреть файл

@ -501,7 +501,8 @@ this.SocialService = {
},
_manifestFromData: function(type, data, principal) {
let sameOriginRequired = ['workerURL', 'sidebarURL', 'shareURL', 'statusURL', 'markURL'];
let featureURLs = ['workerURL', 'sidebarURL', 'shareURL', 'statusURL', 'markURL'];
let resolveURLs = featureURLs.concat(['postActivationURL']);
if (type == 'directory') {
// directory provided manifests must have origin in manifest, use that
@ -515,11 +516,10 @@ this.SocialService = {
// force/fixup origin
data.origin = principal.origin;
// workerURL, sidebarURL is required and must be same-origin
// iconURL and name are required
// iconURL may be a different origin (CDN or data url support) if this is
// a whitelisted or directory listed provider
let providerHasFeatures = [url for (url of sameOriginRequired) if (data[url])].length > 0;
let providerHasFeatures = [url for (url of featureURLs) if (data[url])].length > 0;
if (!providerHasFeatures) {
Cu.reportError("SocialService.manifestFromData manifest missing required urls.");
return null;
@ -528,12 +528,17 @@ this.SocialService = {
Cu.reportError("SocialService.manifestFromData manifest missing name or iconURL.");
return null;
}
for (let url of sameOriginRequired) {
for (let url of resolveURLs) {
if (data[url]) {
try {
data[url] = Services.io.newURI(principal.URI.resolve(data[url]), null, null).spec;
let resolved = Services.io.newURI(principal.URI.resolve(data[url]), null, null);
if (!(resolved.schemeIs("http") || resolved.schemeIs("https"))) {
Cu.reportError("SocialService.manifestFromData unsupported scheme '" + resolved.scheme + "' for " + principal.origin);
return null;
}
data[url] = resolved.spec;
} catch(e) {
Cu.reportError("SocialService.manifestFromData same-origin missmatch in manifest for " + principal.origin);
Cu.reportError("SocialService.manifestFromData unable to resolve '" + url + "' for " + principal.origin);
return null;
}
}
@ -737,6 +742,7 @@ function SocialProvider(input) {
this.markURL = input.markURL;
this.markedIcon = input.markedIcon;
this.unmarkedIcon = input.unmarkedIcon;
this.postActivationURL = input.postActivationURL;
this.origin = input.origin;
let originUri = Services.io.newURI(input.origin, null, null);
this.principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(originUri);