Add support for testing states changing asynchronously. Apply it to state-url-sets...
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 24 Feb 2013 07:24:12 +0000 (07:24 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 24 Feb 2013 07:24:12 +0000 (07:24 +0000)
commit682add30000add8e10f9e4773f53d9c1e94c0798
treed42d57d39bebc9328d8d4e630fab4ad57b6ade95
parent207dc7009e9f68c44d48c601ee4f53691e4dcc30
Add support for testing states changing asynchronously. Apply it to state-url-sets-links-visited.html.
https://bugs.webkit.org/show_bug.cgi?id=109883

Reviewed by Antti Koivisto.

Some tests depends on state change happening asynchronously. This is typically solved by using
timers with a long enough interval.

Timers have the general pitfalls of causing unreliable tests, and forcing unnecessary delays
in the tests.

This patch introduces new testing helpers, shouldBecomeEqual and shouldBecomeEqualToString, to
test a change of state repetively until it succeed (or timeout). Those test functions execute
the condition every 5ms until the test succeed.

The helper shouldBecomeEqualToString is applied on state-url-sets-links-visited.html to illustrate
the concept.

* fast/js/resources/js-test-pre.js:
(_waitForCondition): Generic helper function for the familly shouldBecomeXXX.
(.condition):
(.failureHandler):
(shouldBecomeEqual):
(shouldBecomeEqualToString):

* fast/loader/stateobjects/state-url-sets-links-visited.html:
* platform/wk2/TestExpectations:
state-url-sets-links-visited.html failed on WebKit2 because the visited links table is updated
asynchronously, and the style is only updated after 1 IPC message + 1 timer + 1 IPC message.

The test is changed to use shouldBecomeEqualToString in order to become reliable. If the UIProcess
does not update the style in a reasonable amount of time, the test fails.

* platform/chromium/TestExpectations: Make the test as failing on Chromium until proper test support is added
to DRT or Internals.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@143860 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/js/resources/js-test-pre.js
LayoutTests/fast/loader/stateobjects/state-url-sets-links-visited-expected.txt
LayoutTests/fast/loader/stateobjects/state-url-sets-links-visited.html
LayoutTests/platform/chromium-win/fast/loader/stateobjects/state-url-sets-links-visited-expected.txt [deleted file]
LayoutTests/platform/chromium/TestExpectations
LayoutTests/platform/win/fast/loader/stateobjects/state-url-sets-links-visited-expected.txt [deleted file]
LayoutTests/platform/wk2/TestExpectations