Skip to content

Commit

Permalink
Bug 1417272 - The "Send Tab to Device" page action can be disabled in…
Browse files Browse the repository at this point in the history
… the page action menu but enabled in the urlbar. r=Gijs

MozReview-Commit-ID: BZ4CAqG0kkH
  • Loading branch information
0c0w3 committed Nov 15, 2017
1 parent 67bec42 commit 43b88d9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 30 deletions.
9 changes: 3 additions & 6 deletions browser/base/content/browser-pageActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -958,14 +958,11 @@ BrowserPageActions.sendToDevice = {
}
},

onShowingInPanel(buttonNode) {
onLocationChange() {
let action = PageActions.actionForID("sendToDevice");
let browser = gBrowser.selectedBrowser;
let url = browser.currentURI.spec;
if (gSync.isSendableURI(url)) {
buttonNode.removeAttribute("disabled");
} else {
buttonNode.setAttribute("disabled", "true");
}
action.setDisabled(!gSync.isSendableURI(url), window);
},

onShowingSubview(panelViewNode) {
Expand Down
39 changes: 17 additions & 22 deletions browser/base/content/test/urlbar/browser_page_action_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,34 +174,27 @@ add_task(async function copyURLFromURLBar() {
});

add_task(async function sendToDevice_nonSendable() {
// Open a tab that's not sendable. An about: page like about:home is
// convenient.
await BrowserTestUtils.withNewTab("about:home", async () => {
// ... but the page actions should be hidden on about:home, including the
// main button. (It's not easy to load a page that's both actionable and
// not sendable.) So first check that that's the case, and then unhide the
// main button so that this test can continue.
Assert.equal(
window.getComputedStyle(BrowserPageActions.mainButtonNode).display,
"none",
"Main button should be hidden on about:home"
);
BrowserPageActions.mainButtonNode.style.display = "-moz-box";
// Open a tab that's not sendable but where the page action buttons still
// appear. about:about is convenient.
await BrowserTestUtils.withNewTab("about:about", async () => {
await promiseSyncReady();
// Open the panel. Send to Device should be disabled.
await promisePageActionPanelOpen();
Assert.equal(BrowserPageActions.mainButtonNode.getAttribute("open"),
"true", "Main button has 'open' attribute");
let sendToDeviceButton =
document.getElementById("pageAction-panel-sendToDevice");
Assert.ok(sendToDeviceButton.disabled);
Assert.equal(BrowserPageActions.mainButtonNode.getAttribute("open"), "true",
"Main button has 'open' attribute");
let panelButton =
BrowserPageActions.panelButtonNodeForActionID("sendToDevice");
Assert.equal(panelButton.disabled, true,
"The panel button should be disabled");
let hiddenPromise = promisePageActionPanelHidden();
BrowserPageActions.panelNode.hidePopup();
await hiddenPromise;
Assert.ok(!BrowserPageActions.mainButtonNode.hasAttribute("open"),
"Main button no longer has 'open' attribute");
// Remove the `display` style set above.
BrowserPageActions.mainButtonNode.style.removeProperty("display");
"Main button no longer has 'open' attribute");
// The urlbar button shouldn't exist.
let urlbarButton =
BrowserPageActions.urlbarButtonNodeForActionID("sendToDevice");
Assert.equal(urlbarButton, null, "The urlbar button shouldn't exist");
});
});

Expand Down Expand Up @@ -550,7 +543,9 @@ add_task(async function sendToDevice_inUrlbar() {
let urlbarButton = document.getElementById(
BrowserPageActions.urlbarButtonNodeIDForActionID(action.id)
);
Assert.ok(!urlbarButton.disabled);
Assert.notEqual(urlbarButton, null, "The urlbar button should exist");
Assert.ok(!urlbarButton.disabled,
"The urlbar button should not be disabled");
let panelPromise =
promisePanelShown(BrowserPageActions._activatedActionPanelID);
EventUtils.synthesizeMouseAtCenter(urlbarButton, {});
Expand Down
4 changes: 2 additions & 2 deletions browser/modules/PageActions.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -1229,8 +1229,8 @@ var gBuiltInActions = [
onPlacedInPanel(buttonNode) {
browserPageActions(buttonNode).sendToDevice.onPlacedInPanel(buttonNode);
},
onShowingInPanel(buttonNode) {
browserPageActions(buttonNode).sendToDevice.onShowingInPanel(buttonNode);
onLocationChange(browserWindow) {
browserPageActions(browserWindow).sendToDevice.onLocationChange();
},
subview: {
buttons: [
Expand Down

0 comments on commit 43b88d9

Please sign in to comment.