From bfbf27d0ac8410bfa8e4cd8d1a2dd7508081e378 Mon Sep 17 00:00:00 2001 From: Shane Caraveo Date: Wed, 30 Apr 2014 12:08:23 -0700 Subject: [PATCH] Bug 983481 open a post activation landing page, r=markh --- browser/base/content/browser-social.js | 3 +++ browser/base/content/test/social/browser.ini | 1 + .../test/social/browser_social_activation.js | 8 ++++++++ .../content/test/social/social_activate.html | 1 + .../test/social/social_postActivation.html | 11 +++++++++++ toolkit/components/social/SocialService.jsm | 18 ++++++++++++------ 6 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 browser/base/content/test/social/social_postActivation.html diff --git a/browser/base/content/browser-social.js b/browser/base/content/browser-social.js index 37680d877ab0..bdfcec2cf4b5 100644 --- a/browser/base/content/browser-social.js +++ b/browser/base/content/browser-social.js @@ -233,6 +233,9 @@ SocialUI = { if (provider.sidebarURL) { SocialSidebar.show(provider.origin); } + if (provider.postActivationURL) { + openUILinkIn(provider.postActivationURL, "tab"); + } }); }); }, diff --git a/browser/base/content/test/social/browser.ini b/browser/base/content/test/social/browser.ini index 3d860ee49a23..84996f7fbb53 100644 --- a/browser/base/content/test/social/browser.ini +++ b/browser/base/content/test/social/browser.ini @@ -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 diff --git a/browser/base/content/test/social/browser_social_activation.js b/browser/base/content/test/social/browser_social_activation.js index ebaa8527e811..ecdcef505c68 100644 --- a/browser/base/content/test/social/browser_social_activation.js +++ b/browser/base/content/test/social/browser_social_activation.js @@ -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() { diff --git a/browser/base/content/test/social/social_activate.html b/browser/base/content/test/social/social_activate.html index c6c0c183ace4..59cd8aa09484 100644 --- a/browser/base/content/test/social/social_activate.html +++ b/browser/base/content/test/social/social_activate.html @@ -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", diff --git a/browser/base/content/test/social/social_postActivation.html b/browser/base/content/test/social/social_postActivation.html new file mode 100644 index 000000000000..05937d4da6ab --- /dev/null +++ b/browser/base/content/test/social/social_postActivation.html @@ -0,0 +1,11 @@ + + + Post-Activation test + + + + +Post Activation landing page + + + diff --git a/toolkit/components/social/SocialService.jsm b/toolkit/components/social/SocialService.jsm index b8285153dafd..996f7cac961c 100644 --- a/toolkit/components/social/SocialService.jsm +++ b/toolkit/components/social/SocialService.jsm @@ -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);