mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 23:35:34 +00:00
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:
parent
6e54f839f6
commit
c0de9ab9f5
@ -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);
|
||||
}
|
||||
},
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user