Fixes inverted keys regression and adds a unit test.

BUG=327551

Review URL: https://codereview.chromium.org/111643003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240634 0039d316-1c4b-4281-b951-d872f2087c98
SVN changes up to revision 240634