diff --git a/browser/modules/PageActions.jsm b/browser/modules/PageActions.jsm index ca54fe333237..99c92e0d0638 100644 --- a/browser/modules/PageActions.jsm +++ b/browser/modules/PageActions.jsm @@ -224,6 +224,7 @@ this.PageActions = { this._persistedActions.idsInUrlbar.includes(action.id); } else { // The action is new. Store it in the persisted actions. + this._persistedActions.ids.push(action.id); this._updateIDsInUrlbarForAction(action); } }, diff --git a/browser/modules/test/browser/browser_PageActions.js b/browser/modules/test/browser/browser_PageActions.js index c051113c5691..b805dd87a36e 100644 --- a/browser/modules/test/browser/browser_PageActions.js +++ b/browser/modules/test/browser/browser_PageActions.js @@ -109,6 +109,9 @@ add_task(async function simple() { Assert.deepEqual(PageActions.actionForID(action.id), action, "actionForID should be action"); + Assert.ok(PageActions._persistedActions.ids.includes(action.id), + "PageActions should record action in its list of seen actions"); + // The action's panel button should have been created. let panelButtonNode = document.getElementById(panelButtonID); Assert.notEqual(panelButtonNode, null, "panelButtonNode"); @@ -179,6 +182,29 @@ add_task(async function simple() { Assert.equal(action.title, newTitle, "New title"); Assert.equal(panelButtonNode.getAttribute("label"), action.title, "New label"); + // Now that shownInUrlbar has been toggled, make sure that it sticks across + // app restarts. Simulate that by "unregistering" the action (not by removing + // it, which is more permanent) and then registering it again. + + // unregister + PageActions._actionsByID.delete(action.id); + let index = PageActions._nonBuiltInActions.findIndex(a => a.id == action.id); + Assert.ok(index >= 0, "Action should be in _nonBuiltInActions to begin with"); + PageActions._nonBuiltInActions.splice(index, 1); + + // register again + PageActions._registerAction(action); + + // check relevant properties + Assert.ok(PageActions._persistedActions.ids.includes(action.id), + "PageActions should have 'seen' the action"); + Assert.ok(PageActions._persistedActions.idsInUrlbar.includes(action.id), + "idsInUrlbar should still include the action"); + Assert.ok(action.shownInUrlbar, + "shownInUrlbar should still be true"); + Assert.ok(action._shownInUrlbar, + "_shownInUrlbar should still be true, for good measure"); + // Remove the action. action.remove(); panelButtonNode = document.getElementById(panelButtonID); @@ -191,6 +217,9 @@ add_task(async function simple() { Assert.equal(PageActions.actionForID(action.id), null, "actionForID should be null"); + Assert.ok(!PageActions._persistedActions.ids.includes(action.id), + "PageActions should remove action from its list of seen actions"); + // The separator between the built-in actions and non-built-in actions should // be gone now, too. let separatorNode = document.getElementById(