> Is there something wrong in the test function or is there a problem in
> select-frame-set-input-focus?
Even if you get a thing like this work on your system, there will be
always another platform where it fails.
Note the remark in xfns.c:
In an ideal world, XSetInputFocus should generally be avoided so
that applications don't interfere with the window manager's focus
policy. But I think it's okay to use when it's clearly done
following a user-command.