Bug 1185485: disable the Loop/ Hello button in private browsing mode. r=Standard8

This commit is contained in:
Mike de Boer 2015-07-27 12:07:20 +02:00
Родитель d57ce95961
Коммит f9023c1ba9
4 изменённых файлов: 30 добавлений и 3 удалений

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

@ -957,9 +957,8 @@ const CustomizableWidgets = [
type: "custom",
label: "loop-call-button3.label",
tooltiptext: "loop-call-button3.tooltiptext",
privateBrowsingTooltiptext: "loop-call-button3-pb.tooltiptext",
defaultArea: CustomizableUI.AREA_NAVBAR,
// Not in private browsing, see bug 1108187.
showInPrivateBrowsing: false,
introducedInVersion: 4,
onBuild: function(aDocument) {
// If we're not supposed to see the button, return zip.
@ -967,13 +966,21 @@ const CustomizableWidgets = [
return null;
}
let isWindowPrivate = PrivateBrowsingUtils.isWindowPrivate(aDocument.defaultView);
let node = aDocument.createElementNS(kNSXUL, "toolbarbutton");
node.setAttribute("id", this.id);
node.classList.add("toolbarbutton-1");
node.classList.add("chromeclass-toolbar-additional");
node.classList.add("badged-button");
node.setAttribute("label", CustomizableUI.getLocalizedProperty(this, "label"));
node.setAttribute("tooltiptext", CustomizableUI.getLocalizedProperty(this, "tooltiptext"));
if (isWindowPrivate)
node.setAttribute("disabled", "true");
let tooltiptext = isWindowPrivate ?
CustomizableUI.getLocalizedProperty(this, "privateBrowsingTooltiptext",
[CustomizableUI.getLocalizedProperty(this, "label")]) :
CustomizableUI.getLocalizedProperty(this, "tooltiptext");
node.setAttribute("tooltiptext", tooltiptext);
node.setAttribute("removable", "true");
node.addEventListener("command", function(event) {
aDocument.defaultView.LoopUI.togglePanel(event);

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

@ -21,6 +21,7 @@
"gMozLoopAPI": true,
"mockDb": true,
"mockPushHandler": true,
"OpenBrowserWindow": true,
"promiseDeletedOAuthParams": false,
"promiseOAuthGetRegistration": false,
"promiseOAuthParamsSetup": false,

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

@ -167,3 +167,19 @@ add_task(function* test_screen_share() {
MozLoopService.setScreenShareState("1", false);
Assert.strictEqual(LoopUI.toolbarButton.node.getAttribute("state"), "", "Check button is in default state");
});
add_task(function* test_private_browsing_window() {
let win = OpenBrowserWindow({ private: true });
yield new Promise(resolve => {
win.addEventListener("load", function listener() {
win.removeEventListener("load", listener);
resolve();
});
});
let button = win.LoopUI.toolbarButton.node;
Assert.ok(button, "Loop button should be present");
Assert.ok(button.getAttribute("disabled"), "Disabled attribute should be set");
win.close();
});

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

@ -97,6 +97,9 @@ quit-button.tooltiptext.mac = Quit %1$S (%2$S)
# approval before you change it.
loop-call-button3.label = Hello
loop-call-button3.tooltiptext = Start a conversation
# LOCALIZATION NOTE(loop-call-button3-pb.tooltiptext): Shown when the button is
# placed inside a Private Browsing window. %S is the value of loop-call-button3.label.
loop-call-button3-pb.tooltiptext = %S is not available in Private Browsing
social-share-button.label = Share This Page
social-share-button.tooltiptext = Share this page