Rework menu test file to avoid spurious error on IE.

Closing the programmatic context menu tries to refocus the element that previously had focus,
which is likely the "create programmatic menu" button.  However, since that button disables itself
on click, it cannot be refocused.

Fixes #18167.