Bug 1374477 - Update consumers of Photon page action panel for changed identifiers. r?Gijs draft
authorDrew Willcoxon <adw@mozilla.com>
Tue, 25 Jul 2017 18:37:31 -0700
changeset 615467 fb35e577b538d8cf1de7060334dded0fc81883a6
parent 615466 e1610d1ccf294024c8330dd874e24ad3a00ab364
child 615468 aa9223679f69f8e84a8f3f1046a346d83fd04031
push id70372
push userdwillcoxon@mozilla.com
push dateWed, 26 Jul 2017 01:37:45 +0000
reviewersGijs
bugs1374477
milestone56.0a1
Bug 1374477 - Update consumers of Photon page action panel for changed identifiers. r?Gijs MozReview-Commit-ID: 1skE8YJaqA7
browser/base/content/browser-sync.js
browser/base/content/browser.css
browser/base/content/test/urlbar/browser_page_action_menu.js
browser/base/content/test/urlbar/browser_page_action_menu_clipboard.js
browser/base/content/test/urlbar/head.js
--- a/browser/base/content/browser-sync.js
+++ b/browser/base/content/browser-sync.js
@@ -346,17 +346,17 @@ var gSync = {
 
   _appendSendTabDeviceList(fragment, createDeviceNodeFn, url, title) {
     const onTargetDeviceCommand = (event) => {
       let clients = event.target.getAttribute("clientId") ?
         [event.target.getAttribute("clientId")] :
         this.remoteClients.map(client => client.id);
 
       clients.forEach(clientId => this.sendTabToDevice(url, clientId, title));
-      gPageActionButton.panel.hidePopup();
+      BrowserPageActions.panelNode.hidePopup();
     }
 
     function addTargetDevice(clientId, name, clientType) {
       const targetDevice = createDeviceNodeFn(clientId, name, clientType);
       targetDevice.addEventListener("command", onTargetDeviceCommand, true);
       targetDevice.classList.add("sync-menuitem", "sendtab-target");
       targetDevice.setAttribute("clientId", clientId);
       targetDevice.setAttribute("clientType", clientType);
@@ -379,35 +379,35 @@ var gSync = {
     }
   },
 
   _appendSendTabSingleDevice(fragment, createDeviceNodeFn) {
     const noDevices = this.fxaStrings.GetStringFromName("sendTabToDevice.singledevice.status");
     const learnMore = this.fxaStrings.GetStringFromName("sendTabToDevice.singledevice");
     this._appendSendTabInfoItems(fragment, createDeviceNodeFn, noDevices, learnMore, () => {
       this.openSendToDevicePromo();
-      gPageActionButton.panel.hidePopup();
+      BrowserPageActions.panelNode.hidePopup();
     });
   },
 
   _appendSendTabVerify(fragment, createDeviceNodeFn) {
     const notVerified = this.fxaStrings.GetStringFromName("sendTabToDevice.verify.status");
     const verifyAccount = this.fxaStrings.GetStringFromName("sendTabToDevice.verify");
     this._appendSendTabInfoItems(fragment, createDeviceNodeFn, notVerified, verifyAccount, () => {
       this.openPrefs("sendtab");
-      gPageActionButton.panel.hidePopup();
+      BrowserPageActions.panelNode.hidePopup();
     });
   },
 
   _appendSendTabUnconfigured(fragment, createDeviceNodeFn) {
     const notConnected = this.fxaStrings.GetStringFromName("sendTabToDevice.unconfigured.status");
     const learnMore = this.fxaStrings.GetStringFromName("sendTabToDevice.unconfigured");
     this._appendSendTabInfoItems(fragment, createDeviceNodeFn, notConnected, learnMore, () => {
       this.openSendToDevicePromo();
-      gPageActionButton.panel.hidePopup();
+      BrowserPageActions.panelNode.hidePopup();
     });
   },
 
   _appendSendTabInfoItems(fragment, createDeviceNodeFn, statusLabel, actionLabel, actionCommand) {
     const status = createDeviceNodeFn(null, statusLabel, null);
     status.setAttribute("label", statusLabel);
     status.setAttribute("disabled", true);
     status.classList.add("sync-menuitem");
--- a/browser/base/content/browser.css
+++ b/browser/base/content/browser.css
@@ -1486,14 +1486,17 @@ toolbarpaletteitem[place="palette"][hidd
 }
 
 .dragfeedback-tab {
   -moz-appearance: none;
   opacity: 0.65;
   -moz-window-shadow: none;
 }
 
-/* Page action menu */
-#page-action-sendToDeviceView-body:not([state="notready"]) > #page-action-sync-not-ready-button {
+%ifdef MOZ_PHOTON_THEME
+/* Page action panel */
+#pageAction-panel-sendToDevice-subview-body:not([state="notready"]) > #pageAction-panel-sendToDevice-notReady,
+#pageAction-urlbar-sendToDevice-subview-body:not([state="notready"]) > #pageAction-urlbar-sendToDevice-notReady {
   display: none;
 }
+%endif
 
 %include theme-vars.inc.css
--- a/browser/base/content/test/urlbar/browser_page_action_menu.js
+++ b/browser/base/content/test/urlbar/browser_page_action_menu.js
@@ -18,17 +18,17 @@ const mockRemoteClients = [
 add_task(async function bookmark() {
   // Open a unique page.
   let url = "http://example.com/browser_page_action_menu";
   await BrowserTestUtils.withNewTab(url, async () => {
     // Open the panel.
     await promisePageActionPanelOpen();
 
     // The bookmark button should read "Bookmark This Page" and not be starred.
-    let bookmarkButton = document.getElementById("page-action-bookmark-button");
+    let bookmarkButton = document.getElementById("pageAction-panel-bookmark");
     Assert.equal(bookmarkButton.label, "Bookmark This Page");
     Assert.ok(!bookmarkButton.hasAttribute("starred"));
 
     // Click the button.
     let hiddenPromise = promisePageActionPanelHidden();
     EventUtils.synthesizeMouseAtCenter(bookmarkButton, {});
     await hiddenPromise;
 
@@ -96,32 +96,32 @@ add_task(async function emailLink() {
   };
   registerCleanupFunction(() => {
     MailIntegration.sendLinkForBrowser = originalFn;
   });
 
   // Open the panel and click Email Link.
   await promisePageActionPanelOpen();
   let emailLinkButton =
-    document.getElementById("page-action-email-link-button");
+    document.getElementById("pageAction-panel-emailLink");
   let hiddenPromise = promisePageActionPanelHidden();
   EventUtils.synthesizeMouseAtCenter(emailLinkButton, {});
   await hiddenPromise;
 
   Assert.ok(fnCalled);
 });
 
 add_task(async function sendToDevice_nonSendable() {
   // Open a tab that's not sendable.
   await BrowserTestUtils.withNewTab("about:blank", async () => {
     await promiseSyncReady();
     // Open the panel.  Send to Device should be disabled.
     await promisePageActionPanelOpen();
     let sendToDeviceButton =
-      document.getElementById("page-action-send-to-device-button");
+      document.getElementById("pageAction-panel-sendToDevice");
     Assert.ok(sendToDeviceButton.disabled);
     let hiddenPromise = promisePageActionPanelHidden();
     gPageActionPanel.hidePopup();
     await hiddenPromise;
   });
 });
 
 add_task(async function sendToDevice_syncNotReady_other_states() {
@@ -137,28 +137,28 @@ add_task(async function sendToDevice_syn
     let cleanUp = () => {
       sandbox.restore();
     };
     registerCleanupFunction(cleanUp);
 
     // Open the panel.
     await promisePageActionPanelOpen();
     let sendToDeviceButton =
-      document.getElementById("page-action-send-to-device-button");
+      document.getElementById("pageAction-panel-sendToDevice");
     Assert.ok(!sendToDeviceButton.disabled);
 
     // Click Send to Device.
     let viewPromise = promisePageActionViewShown();
     EventUtils.synthesizeMouseAtCenter(sendToDeviceButton, {});
     let view = await viewPromise;
-    Assert.equal(view.id, "page-action-sendToDeviceView");
+    Assert.equal(view.id, "pageAction-panel-sendToDevice-subview");
 
     let expectedItems = [
       {
-        id: "page-action-sync-not-ready-button",
+        id: "pageAction-panel-sendToDevice-notReady",
         display: "none",
         disabled: true,
       },
       {
         attrs: {
           label: "Account Not Verified",
         },
         disabled: true
@@ -192,54 +192,54 @@ add_task(async function sendToDevice_syn
     sandbox.stub(gSync, "isSendableURI").returns(true);
 
     sandbox.stub(Weave.Service, "sync").callsFake(() => {
       syncReady.get(() => true);
       lastSync.get(() => Date.now());
       sandbox.stub(gSync, "remoteClients").get(() => mockRemoteClients);
     });
 
-    const setupSendToDeviceView = gPageActionButton.setupSendToDeviceView;
-    sandbox.stub(gPageActionButton, "setupSendToDeviceView").callsFake(() => {
+    let onShowingSubview = BrowserPageActions.sendToDevice.onShowingSubview;
+    sandbox.stub(BrowserPageActions.sendToDevice, "onShowingSubview").callsFake((...args) => {
       this.numCall++ || (this.numCall = 1);
-      setupSendToDeviceView.call(gPageActionButton);
+      onShowingSubview.call(BrowserPageActions.sendToDevice, ...args);
       testSendTabToDeviceMenu(this.numCall);
     });
 
     let cleanUp = () => {
       sandbox.restore();
     };
     registerCleanupFunction(cleanUp);
 
     // Open the panel.
     await promisePageActionPanelOpen();
     let sendToDeviceButton =
-      document.getElementById("page-action-send-to-device-button");
+      document.getElementById("pageAction-panel-sendToDevice");
     Assert.ok(!sendToDeviceButton.disabled);
 
     // Click Send to Device.
     let viewPromise = promisePageActionViewShown();
     EventUtils.synthesizeMouseAtCenter(sendToDeviceButton, {});
     let view = await viewPromise;
-    Assert.equal(view.id, "page-action-sendToDeviceView");
+    Assert.equal(view.id, "pageAction-panel-sendToDevice-subview");
 
     function testSendTabToDeviceMenu(numCall) {
       if (numCall == 1) {
         // "Syncing devices" should be shown.
         checkSendToDeviceItems([
           {
-            id: "page-action-sync-not-ready-button",
+            id: "pageAction-panel-sendToDevice-notReady",
             disabled: true,
           },
         ]);
       } else if (numCall == 2) {
         // The devices should be shown in the subview.
         let expectedItems = [
           {
-            id: "page-action-sync-not-ready-button",
+            id: "pageAction-panel-sendToDevice-notReady",
             display: "none",
             disabled: true,
           },
         ];
         for (let client of mockRemoteClients) {
           expectedItems.push({
             attrs: {
               clientId: client.id,
@@ -273,28 +273,28 @@ add_task(async function sendToDevice_syn
 add_task(async function sendToDevice_notSignedIn() {
   // Open a tab that's sendable.
   await BrowserTestUtils.withNewTab("http://example.com/", async () => {
     await promiseSyncReady();
 
     // Open the panel.
     await promisePageActionPanelOpen();
     let sendToDeviceButton =
-      document.getElementById("page-action-send-to-device-button");
+      document.getElementById("pageAction-panel-sendToDevice");
     Assert.ok(!sendToDeviceButton.disabled);
 
     // Click Send to Device.
     let viewPromise = promisePageActionViewShown();
     EventUtils.synthesizeMouseAtCenter(sendToDeviceButton, {});
     let view = await viewPromise;
-    Assert.equal(view.id, "page-action-sendToDeviceView");
+    Assert.equal(view.id, "pageAction-panel-sendToDevice-subview");
 
     let expectedItems = [
       {
-        id: "page-action-sync-not-ready-button",
+        id: "pageAction-panel-sendToDevice-notReady",
         display: "none",
         disabled: true,
       },
       {
         attrs: {
           label: "Not Connected to Sync",
         },
         disabled: true
@@ -329,28 +329,28 @@ add_task(async function sendToDevice_noD
     let cleanUp = () => {
       sandbox.restore();
     };
     registerCleanupFunction(cleanUp);
 
     // Open the panel.
     await promisePageActionPanelOpen();
     let sendToDeviceButton =
-      document.getElementById("page-action-send-to-device-button");
+      document.getElementById("pageAction-panel-sendToDevice");
     Assert.ok(!sendToDeviceButton.disabled);
 
     // Click Send to Device.
     let viewPromise = promisePageActionViewShown();
     EventUtils.synthesizeMouseAtCenter(sendToDeviceButton, {});
     let view = await viewPromise;
-    Assert.equal(view.id, "page-action-sendToDeviceView");
+    Assert.equal(view.id, "pageAction-panel-sendToDevice-subview");
 
     let expectedItems = [
       {
-        id: "page-action-sync-not-ready-button",
+        id: "pageAction-panel-sendToDevice-notReady",
         display: "none",
         disabled: true,
       },
       {
         attrs: {
           label: "No Devices Connected",
         },
         disabled: true
@@ -389,29 +389,29 @@ add_task(async function sendToDevice_dev
     let cleanUp = () => {
       sandbox.restore();
     };
     registerCleanupFunction(cleanUp);
 
     // Open the panel.
     await promisePageActionPanelOpen();
     let sendToDeviceButton =
-      document.getElementById("page-action-send-to-device-button");
+      document.getElementById("pageAction-panel-sendToDevice");
     Assert.ok(!sendToDeviceButton.disabled);
 
     // Click Send to Device.
     let viewPromise = promisePageActionViewShown();
     EventUtils.synthesizeMouseAtCenter(sendToDeviceButton, {});
     let view = await viewPromise;
-    Assert.equal(view.id, "page-action-sendToDeviceView");
+    Assert.equal(view.id, "pageAction-panel-sendToDevice-subview");
 
     // The devices should be shown in the subview.
     let expectedItems = [
       {
-        id: "page-action-sync-not-ready-button",
+        id: "pageAction-panel-sendToDevice-notReady",
         display: "none",
         disabled: true,
       },
     ];
     for (let client of mockRemoteClients) {
       expectedItems.push({
         attrs: {
           clientId: client.id,
@@ -445,17 +445,18 @@ function promiseSyncReady() {
                   .wrappedJSObject;
   return service.whenLoaded().then(() => {
     UIState.isReady();
     return UIState.refresh();
   });
 }
 
 function checkSendToDeviceItems(expectedItems) {
-  let body = document.getElementById("page-action-sendToDeviceView-body");
+  let body =
+    document.getElementById("pageAction-panel-sendToDevice-subview-body");
   Assert.equal(body.childNodes.length, expectedItems.length);
   for (let i = 0; i < expectedItems.length; i++) {
     let expected = expectedItems[i];
     let actual = body.childNodes[i];
     if (!expected) {
       Assert.equal(actual.localName, "toolbarseparator");
       continue;
     }
--- a/browser/base/content/test/urlbar/browser_page_action_menu_clipboard.js
+++ b/browser/base/content/test/urlbar/browser_page_action_menu_clipboard.js
@@ -6,17 +6,17 @@ const mockRemoteClients = [
   { id: "2", name: "baz", type: "mobile" },
 ];
 
 add_task(async function copyURL() {
   // Open the panel.
   await promisePageActionPanelOpen();
 
   // Click Copy URL.
-  let copyURLButton = document.getElementById("page-action-copy-url-button");
+  let copyURLButton = document.getElementById("pageAction-panel-copyURL");
   let hiddenPromise = promisePageActionPanelHidden();
   EventUtils.synthesizeMouseAtCenter(copyURLButton, {});
   await hiddenPromise;
 
   // Check the clipboard.
   let transferable = Cc["@mozilla.org/widget/transferable;1"]
                        .createInstance(Ci.nsITransferable);
   transferable.init(null);
--- a/browser/base/content/test/urlbar/head.js
+++ b/browser/base/content/test/urlbar/head.js
@@ -195,20 +195,20 @@ function promiseNewSearchEngine(basename
       onError(errCode) {
         Assert.ok(false, "addEngine failed with error code " + errCode);
         reject();
       },
     });
   });
 }
 
-let gPageActionPanel = document.getElementById("page-action-panel");
+let gPageActionPanel = document.getElementById("pageActionPanel");
 
 function promisePageActionPanelOpen() {
-  let button = document.getElementById("urlbar-page-action-button");
+  let button = document.getElementById("pageActionButton");
   let shownPromise = promisePageActionPanelShown();
   EventUtils.synthesizeMouseAtCenter(button, {});
   return shownPromise;
 }
 
 function promisePageActionPanelShown() {
   return promisePageActionPanelEvent("popupshown");
 }