mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 22:55:23 +00:00
eabb5f6400
part 1: reorganize file locations, r=Gijs part 2: remove built-in pocket code, r=Gijs part 3: l10n support, r=glandium part 4: move code/functionality from part 2 into the addon, r=Gijs part 5: remove dead code, r=Gijs part 6: create a simple api for addons to add to reader mode, r=Gijs part 7: various test fixes related to cui behaviour and pocket, r=me --HG-- rename : browser/components/pocket/Pocket.jsm => browser/extensions/pocket/content/Pocket.jsm rename : browser/components/pocket/main.js => browser/extensions/pocket/content/main.js rename : browser/components/pocket/panels/css/firasans.css => browser/extensions/pocket/content/panels/css/firasans.css rename : browser/components/pocket/panels/css/normalize.css => browser/extensions/pocket/content/panels/css/normalize.css rename : browser/components/pocket/panels/css/saved.css => browser/extensions/pocket/content/panels/css/saved.css rename : browser/components/pocket/panels/css/signup.css => browser/extensions/pocket/content/panels/css/signup.css rename : browser/components/pocket/panels/fonts/FiraSans-Regular.woff => browser/extensions/pocket/content/panels/fonts/FiraSans-Regular.woff rename : toolkit/themes/shared/reader/pocket.svg => browser/extensions/pocket/content/panels/img/pocket.svg rename : browser/components/pocket/panels/img/pocketerror@1x.png => browser/extensions/pocket/content/panels/img/pocketerror@1x.png rename : browser/components/pocket/panels/img/pocketerror@2x.png => browser/extensions/pocket/content/panels/img/pocketerror@2x.png rename : browser/components/pocket/panels/img/pocketlogo@1x.png => browser/extensions/pocket/content/panels/img/pocketlogo@1x.png rename : browser/components/pocket/panels/img/pocketlogo@2x.png => browser/extensions/pocket/content/panels/img/pocketlogo@2x.png rename : browser/components/pocket/panels/img/pocketlogosolo@1x.png => browser/extensions/pocket/content/panels/img/pocketlogosolo@1x.png rename : browser/components/pocket/panels/img/pocketlogosolo@2x.png => browser/extensions/pocket/content/panels/img/pocketlogosolo@2x.png rename : browser/components/pocket/panels/img/pocketmenuitem16.png => browser/extensions/pocket/content/panels/img/pocketmenuitem16.png rename : browser/components/pocket/panels/img/pocketmenuitem16@2x.png => browser/extensions/pocket/content/panels/img/pocketmenuitem16@2x.png rename : browser/components/pocket/panels/img/pocketsignup_button@1x.png => browser/extensions/pocket/content/panels/img/pocketsignup_button@1x.png rename : browser/components/pocket/panels/img/pocketsignup_button@2x.png => browser/extensions/pocket/content/panels/img/pocketsignup_button@2x.png rename : browser/components/pocket/panels/img/pocketsignup_devices@1x.png => browser/extensions/pocket/content/panels/img/pocketsignup_devices@1x.png rename : browser/components/pocket/panels/img/pocketsignup_devices@2x.png => browser/extensions/pocket/content/panels/img/pocketsignup_devices@2x.png rename : browser/components/pocket/panels/img/pocketsignup_hero@1x.png => browser/extensions/pocket/content/panels/img/pocketsignup_hero@1x.png rename : browser/components/pocket/panels/img/pocketsignup_hero@2x.png => browser/extensions/pocket/content/panels/img/pocketsignup_hero@2x.png rename : browser/components/pocket/panels/img/signup_firefoxlogo@1x.png => browser/extensions/pocket/content/panels/img/signup_firefoxlogo@1x.png rename : browser/components/pocket/panels/img/signup_firefoxlogo@2x.png => browser/extensions/pocket/content/panels/img/signup_firefoxlogo@2x.png rename : browser/components/pocket/panels/img/signup_help@1x.png => browser/extensions/pocket/content/panels/img/signup_help@1x.png rename : browser/components/pocket/panels/img/signup_help@2x.png => browser/extensions/pocket/content/panels/img/signup_help@2x.png rename : browser/components/pocket/panels/img/signup_or@1x.png => browser/extensions/pocket/content/panels/img/signup_or@1x.png rename : browser/components/pocket/panels/img/signup_or@2x.png => browser/extensions/pocket/content/panels/img/signup_or@2x.png rename : browser/components/pocket/panels/img/tag_close@1x.png => browser/extensions/pocket/content/panels/img/tag_close@1x.png rename : browser/components/pocket/panels/img/tag_close@2x.png => browser/extensions/pocket/content/panels/img/tag_close@2x.png rename : browser/components/pocket/panels/img/tag_closeactive@1x.png => browser/extensions/pocket/content/panels/img/tag_closeactive@1x.png rename : browser/components/pocket/panels/img/tag_closeactive@2x.png => browser/extensions/pocket/content/panels/img/tag_closeactive@2x.png rename : browser/components/pocket/panels/js/messages.js => browser/extensions/pocket/content/panels/js/messages.js rename : browser/components/pocket/panels/js/saved.js => browser/extensions/pocket/content/panels/js/saved.js rename : browser/components/pocket/panels/js/signup.js => browser/extensions/pocket/content/panels/js/signup.js rename : browser/components/pocket/panels/js/tmpl.js => browser/extensions/pocket/content/panels/js/tmpl.js rename : browser/components/pocket/panels/js/vendor/handlebars.runtime.js => browser/extensions/pocket/content/panels/js/vendor/handlebars.runtime.js rename : browser/components/pocket/panels/js/vendor/jquery-2.1.1.min.js => browser/extensions/pocket/content/panels/js/vendor/jquery-2.1.1.min.js rename : browser/components/pocket/panels/js/vendor/jquery.tokeninput.min.js => browser/extensions/pocket/content/panels/js/vendor/jquery.tokeninput.min.js rename : browser/components/pocket/panels/license.txt => browser/extensions/pocket/content/panels/license.txt rename : browser/components/pocket/panels/saved.html => browser/extensions/pocket/content/panels/saved.html rename : browser/components/pocket/panels/signup.html => browser/extensions/pocket/content/panels/signup.html rename : browser/components/pocket/panels/tmpl/saved_premiumextras.handlebars => browser/extensions/pocket/content/panels/tmpl/saved_premiumextras.handlebars rename : browser/components/pocket/panels/tmpl/saved_premiumshell.handlebars => browser/extensions/pocket/content/panels/tmpl/saved_premiumshell.handlebars rename : browser/components/pocket/panels/tmpl/saved_shell.handlebars => browser/extensions/pocket/content/panels/tmpl/saved_shell.handlebars rename : browser/components/pocket/panels/tmpl/signup_shell.handlebars => browser/extensions/pocket/content/panels/tmpl/signup_shell.handlebars rename : browser/components/pocket/panels/tmpl/signupstoryboard_shell.handlebars => browser/extensions/pocket/content/panels/tmpl/signupstoryboard_shell.handlebars rename : browser/components/pocket/pktApi.js => browser/extensions/pocket/content/pktApi.jsm rename : browser/locales/en-US/chrome/browser/browser-pocket.properties => browser/extensions/pocket/locales/en-US/pocket.properties
299 lines
13 KiB
JavaScript
299 lines
13 KiB
JavaScript
/* 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/. */
|
|
|
|
var SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService;
|
|
|
|
var manifest2 = { // used for testing install
|
|
name: "provider test1",
|
|
origin: "https://test1.example.com",
|
|
workerURL: "https://test1.example.com/browser/browser/base/content/test/social/social_worker.js",
|
|
markURL: "https://test1.example.com/browser/browser/base/content/test/social/social_mark.html?url=%{url}",
|
|
markedIcon: "https://test1.example.com/browser/browser/base/content/test/social/unchecked.jpg",
|
|
unmarkedIcon: "https://test1.example.com/browser/browser/base/content/test/social/checked.jpg",
|
|
|
|
iconURL: "https://test1.example.com/browser/browser/base/content/test/general/moz.png",
|
|
version: "1.0"
|
|
};
|
|
var manifest3 = { // used for testing install
|
|
name: "provider test2",
|
|
origin: "https://test2.example.com",
|
|
sidebarURL: "https://test2.example.com/browser/browser/base/content/test/social/social_sidebar.html",
|
|
iconURL: "https://test2.example.com/browser/browser/base/content/test/general/moz.png",
|
|
version: "1.0"
|
|
};
|
|
|
|
function test() {
|
|
waitForExplicitFinish();
|
|
|
|
runSocialTests(tests, undefined, undefined, finish);
|
|
}
|
|
|
|
var tests = {
|
|
testButtonDisabledOnActivate: function(next) {
|
|
// starting on about:blank page, share should be visible but disabled when
|
|
// adding provider
|
|
is(gBrowser.selectedBrowser.currentURI.spec, "about:blank");
|
|
SocialService.addProvider(manifest2, function(provider) {
|
|
is(provider.origin, manifest2.origin, "provider is installed");
|
|
let id = SocialMarks._toolbarHelper.idFromOrigin(manifest2.origin);
|
|
let widget = CustomizableUI.getWidget(id).forWindow(window)
|
|
ok(widget.node, "button added to widget set");
|
|
|
|
// bypass widget go directly to dom, check attribute states
|
|
let button = document.getElementById(id);
|
|
is(button.disabled, true, "mark button is disabled");
|
|
// verify the attribute for proper css
|
|
is(button.getAttribute("disabled"), "true", "mark button attribute is disabled");
|
|
// button should be visible
|
|
is(button.hidden, false, "mark button is visible");
|
|
|
|
checkSocialUI(window);
|
|
SocialService.disableProvider(manifest2.origin, next);
|
|
});
|
|
},
|
|
testNoButtonOnEnable: function(next) {
|
|
// we expect the addon install dialog to appear, we need to accept the
|
|
// install from the dialog.
|
|
let panel = document.getElementById("servicesInstall-notification");
|
|
ensureEventFired(PopupNotifications.panel, "popupshown").then(() => {
|
|
info("servicesInstall-notification panel opened");
|
|
panel.button.click();
|
|
});
|
|
|
|
let activationURL = manifest3.origin + "/browser/browser/base/content/test/social/social_activate.html"
|
|
addTab(activationURL, function(tab) {
|
|
let doc = tab.linkedBrowser.contentDocument;
|
|
let data = {
|
|
origin: doc.nodePrincipal.origin,
|
|
url: doc.location.href,
|
|
manifest: manifest3,
|
|
window: window
|
|
}
|
|
|
|
Social.installProvider(data, function(addonManifest) {
|
|
// enable the provider so we know the button would have appeared
|
|
SocialService.enableProvider(manifest3.origin, function(provider) {
|
|
is(provider.origin, manifest3.origin, "provider is installed");
|
|
let id = SocialMarks._toolbarHelper.idFromOrigin(provider.origin);
|
|
let widget = CustomizableUI.getWidget(id);
|
|
ok(!widget || !widget.forWindow(window).node, "no button added to widget set");
|
|
Social.uninstallProvider(manifest3.origin, function() {
|
|
ensureBrowserTabClosed(tab).then(next);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
},
|
|
|
|
testButtonOnEnable: function(next) {
|
|
let panel = document.getElementById("servicesInstall-notification");
|
|
ensureEventFired(PopupNotifications.panel, "popupshown").then(() => {
|
|
info("servicesInstall-notification panel opened");
|
|
panel.button.click();
|
|
});
|
|
|
|
// enable the provider now
|
|
let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
|
|
addTab(activationURL, function(tab) {
|
|
let doc = tab.linkedBrowser.contentDocument;
|
|
let data = {
|
|
origin: doc.nodePrincipal.origin,
|
|
url: doc.location.href,
|
|
manifest: manifest2,
|
|
window: window
|
|
}
|
|
|
|
Social.installProvider(data, function(addonManifest) {
|
|
SocialService.enableProvider(manifest2.origin, function(provider) {
|
|
is(provider.origin, manifest2.origin, "provider is installed");
|
|
let id = SocialMarks._toolbarHelper.idFromOrigin(manifest2.origin);
|
|
let widget = CustomizableUI.getWidget(id).forWindow(window)
|
|
ok(widget.node, "button added to widget set");
|
|
|
|
// bypass widget go directly to dom, check attribute states
|
|
let button = document.getElementById(id);
|
|
is(button.disabled, false, "mark button is disabled");
|
|
// verify the attribute for proper css
|
|
ok(!button.hasAttribute("disabled"), "mark button attribute is disabled");
|
|
// button should be visible
|
|
is(button.hidden, false, "mark button is visible");
|
|
|
|
checkSocialUI(window);
|
|
ensureBrowserTabClosed(tab).then(next);
|
|
});
|
|
});
|
|
});
|
|
},
|
|
|
|
testMarkPanel: function(next) {
|
|
// click on panel to open and wait for visibility
|
|
let provider = Social._getProviderFromOrigin(manifest2.origin);
|
|
ok(provider.enabled, "provider is enabled");
|
|
let id = SocialMarks._toolbarHelper.idFromOrigin(manifest2.origin);
|
|
let widget = CustomizableUI.getWidget(id);
|
|
let btn = widget.forWindow(window).node;
|
|
ok(btn, "got a mark button");
|
|
let port = provider.getWorkerPort();
|
|
ok(port, "got a port");
|
|
|
|
// verify markbutton is disabled when there is no browser url
|
|
ok(btn.disabled, "button is disabled");
|
|
let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
|
|
addTab(activationURL, function(tab) {
|
|
ok(!btn.disabled, "button is enabled");
|
|
port.onmessage = function (e) {
|
|
let topic = e.data.topic;
|
|
switch (topic) {
|
|
case "test-init-done":
|
|
ok(true, "test-init-done received");
|
|
ok(provider.profile.userName, "profile was set by test worker");
|
|
// first click marks the page, second click opens the page. We have to
|
|
// synthesize so the command event happens
|
|
EventUtils.synthesizeMouseAtCenter(btn, {});
|
|
// wait for the button to be marked, click to open panel
|
|
is(btn.panel.state, "closed", "panel should not be visible yet");
|
|
waitForCondition(() => btn.isMarked, function() {
|
|
EventUtils.synthesizeMouseAtCenter(btn, {});
|
|
}, "button is marked");
|
|
break;
|
|
case "got-social-panel-visibility":
|
|
ok(true, "got the panel message " + e.data.result);
|
|
if (e.data.result == "shown") {
|
|
// unmark the page via the button in the page
|
|
ensureFrameLoaded(btn.content).then(() => {
|
|
let doc = btn.contentDocument;
|
|
let unmarkBtn = doc.getElementById("unmark");
|
|
ok(unmarkBtn, "testMarkPanel - got the panel unmark button");
|
|
EventUtils.sendMouseEvent({type: "click"}, unmarkBtn, btn.contentWindow);
|
|
});
|
|
} else {
|
|
// page should no longer be marked
|
|
port.close();
|
|
waitForCondition(() => !btn.isMarked, function() {
|
|
// cleanup after the page has been unmarked
|
|
ensureBrowserTabClosed(tab).then(() => {
|
|
ok(btn.disabled, "button is disabled");
|
|
next();
|
|
});
|
|
}, "button unmarked");
|
|
}
|
|
break;
|
|
}
|
|
};
|
|
port.postMessage({topic: "test-init"});
|
|
});
|
|
},
|
|
|
|
testMarkPanelOffline: function(next) {
|
|
// click on panel to open and wait for visibility
|
|
let provider = Social._getProviderFromOrigin(manifest2.origin);
|
|
ok(provider.enabled, "provider is enabled");
|
|
let id = SocialMarks._toolbarHelper.idFromOrigin(manifest2.origin);
|
|
let widget = CustomizableUI.getWidget(id);
|
|
let btn = widget.forWindow(window).node;
|
|
ok(btn, "got a mark button");
|
|
|
|
// verify markbutton is disabled when there is no browser url
|
|
ok(btn.disabled, "button is disabled");
|
|
let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
|
|
addTab(activationURL, function(tab) {
|
|
ok(!btn.disabled, "button is enabled");
|
|
goOffline().then(function() {
|
|
info("testing offline error page");
|
|
// wait for popupshown
|
|
ensureEventFired(btn.panel, "popupshown").then(() => {
|
|
info("marks panel is open");
|
|
ensureFrameLoaded(btn.content).then(() => {
|
|
is(btn.contentDocument.documentURI.indexOf("about:socialerror?mode=tryAgainOnly"), 0, "social error page is showing "+btn.contentDocument.documentURI);
|
|
// cleanup after the page has been unmarked
|
|
ensureBrowserTabClosed(tab).then(() => {
|
|
ok(btn.disabled, "button is disabled");
|
|
goOnline().then(next);
|
|
});
|
|
});
|
|
});
|
|
btn.markCurrentPage();
|
|
});
|
|
});
|
|
},
|
|
|
|
testMarkPanelLoggedOut: function(next) {
|
|
// click on panel to open and wait for visibility
|
|
let provider = Social._getProviderFromOrigin(manifest2.origin);
|
|
ok(provider.enabled, "provider is enabled");
|
|
let id = SocialMarks._toolbarHelper.idFromOrigin(manifest2.origin);
|
|
let widget = CustomizableUI.getWidget(id);
|
|
let btn = widget.forWindow(window).node;
|
|
ok(btn, "got a mark button");
|
|
let port = provider.getWorkerPort();
|
|
ok(port, "got a port");
|
|
|
|
// verify markbutton is disabled when there is no browser url
|
|
ok(btn.disabled, "button is disabled");
|
|
let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
|
|
addTab(activationURL, function(tab) {
|
|
ok(!btn.disabled, "button is enabled");
|
|
port.onmessage = function (e) {
|
|
let topic = e.data.topic;
|
|
switch (topic) {
|
|
case "test-init-done":
|
|
ok(true, "test-init-done received");
|
|
ok(provider.profile.userName, "profile was set by test worker");
|
|
port.postMessage({topic: "test-logout"});
|
|
waitForCondition(() => !provider.profile.userName,
|
|
function() {
|
|
// when the provider has not indicated to us that a user is
|
|
// logged in, the first click opens the page.
|
|
EventUtils.synthesizeMouseAtCenter(btn, {});
|
|
},
|
|
"profile was unset by test worker");
|
|
break;
|
|
case "got-social-panel-visibility":
|
|
ok(true, "got the panel message " + e.data.result);
|
|
if (e.data.result == "shown") {
|
|
// our test marks the page during the load event (see
|
|
// social_mark.html) regardless of login state, unmark the page
|
|
// via the button in the page
|
|
ensureFrameLoaded(btn.content).then(() => {
|
|
let doc = btn.contentDocument;
|
|
let unmarkBtn = doc.getElementById("unmark");
|
|
ok(unmarkBtn, "testMarkPanelLoggedOut - got the panel unmark button");
|
|
EventUtils.sendMouseEvent({type: "click"}, unmarkBtn, btn.contentWindow);
|
|
});
|
|
} else {
|
|
// page should no longer be marked
|
|
port.close();
|
|
waitForCondition(() => !btn.isMarked, function() {
|
|
// cleanup after the page has been unmarked
|
|
ensureBrowserTabClosed(tab).then(() => {
|
|
ok(btn.disabled, "button is disabled");
|
|
next();
|
|
});
|
|
}, "button unmarked");
|
|
}
|
|
break;
|
|
}
|
|
};
|
|
port.postMessage({topic: "test-init"});
|
|
});
|
|
},
|
|
|
|
testButtonOnDisable: function(next) {
|
|
// enable the provider now
|
|
let provider = Social._getProviderFromOrigin(manifest2.origin);
|
|
ok(provider, "provider is installed");
|
|
SocialService.disableProvider(manifest2.origin, function() {
|
|
let id = SocialMarks._toolbarHelper.idFromOrigin(manifest2.origin);
|
|
waitForCondition(function() {
|
|
// getWidget now returns null since we've destroyed the widget
|
|
return !CustomizableUI.getWidget(id)
|
|
},
|
|
function() {
|
|
checkSocialUI(window);
|
|
Social.uninstallProvider(manifest2.origin, next);
|
|
}, "button does not exist after disabling the provider");
|
|
});
|
|
}
|
|
}
|