This test is flaky in debug builds after http://trac.webkit.org/changeset/177682. It seems that the test needs to call internals.updateEditorUINowIfScheduled() after programmatic selection changes.
Committed r177684: <http://trac.webkit.org/changeset/177684>
It looks like it's flaky in Release builds as well https://build.webkit.org/builders/Apple%20Yosemite%20Release%20WK1%20%28Tests%29/builds/1527/steps/layout-test/logs/stdio
I was able to reproduce it with: ./Tools/Scripts/run-webkit-tests --debug LayoutTests/editing/spelling/grammar-paste.html --iterations=200 --time-out-ms=3000 Result: [1/1] editing/spelling/grammar-paste.html passed 196 tests ran as expected, 4 didn't: Might be similar to https://bugs.webkit.org/show_bug.cgi?id=139862. This is probably regression from http://trac.webkit.org/changeset/164401
Looks like this happens on all Mac WK1 bots, not just on debug. I'll update test expectations.