Bug 1398375 - PageActions forgets about actions added after bug 1397501 landed. r=Gijs

MozReview-Commit-ID: IIAPvUSUMot

--HG--
extra : rebase_source : 724e067bb1d642dbb57d7120ed2b64a35d3b5bf7
This commit is contained in:
Drew Willcoxon 2017-09-09 14:14:12 -07:00
parent 6e54f839f6
commit c0de9ab9f5
2 changed files with 30 additions and 0 deletions

View File

@ -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);
}
},

View File

@ -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(