Bug 134550

Summary: Layout Test http/tests/cache/iframe-304-crash.html is flaky on GTK and Mac WebKit2 platforms
Product: WebKit Reporter: Carlos Alberto Lopez Perez <clopez>
Component: Tools / TestsAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: ap
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
URL: http://build.webkit.org/results/Apple%20Mavericks%20Debug%20WK2%20%28Tests%29/r170423%20%285407%29/http/tests/cache/iframe-304-crash-pretty-diff.html
See Also: https://bugs.webkit.org/show_bug.cgi?id=140703

Description Carlos Alberto Lopez Perez 2014-07-02 11:08:37 PDT
The layout test http/tests/cache/iframe-304-crash.html is flaky on WebKit2 platforms (checked on the flakiness dashboard, both Apple Mavericks and GTK have random recent failures):

The diff is the following: http://build.webkit.org/results/Apple%20Mavericks%20Debug%20WK2%20%28Tests%29/r170423%20%285407%29/http/tests/cache/iframe-304-crash-pretty-diff.html

Probable cause:

Sometimes the event didFinishLoading for the newIframe inserted with document.body.appendChild don't happens (or happens after testRunner.notifyDone).

The following _bash_ command should be able to reproduce the failure in less than 100 iterations:

WebKit $ rm -fr layout-test-results; n=0; while ! test -f layout-test-results/http/tests/cache/iframe-304-crash-diff.txt; do Tools/Scripts/run-webkit-tests --no-show-results --no-new-test-results --no-sample-on-timeout --results-directory layout-test-results --debug-rwt-logging --release --webkit-test-runner --gtk --no-retry-failures http/tests/cache/cached-main-resource.html http/tests/cache/iframe-304-crash.html; n=$(( ${n} + 1 )); done
# In the above command replace "--gtk" with your port name (if you are not running the GTK port)
WebKit $ echo "Test failed after ${n} iters"
WebKit $ cat layout-test-results/http/tests/cache/iframe-304-crash-diff.txt


I tested the following patch:

--- a/LayoutTests/http/tests/cache/iframe-304-crash.html
+++ b/LayoutTests/http/tests/cache/iframe-304-crash.html
@@ -11,7 +11,7 @@ function removeAndReplaceIframe() {
     document.body.removeChild(document.getElementById("iframe"));
     var newIframe = document.createElement("iframe");
     newIframe.src = "resources/iframe304.php";
-    newIframe.onload = function() { setTimeout(finish, 0); }
+    newIframe.onload = function() { setTimeout(finish, 100); }
     document.body.appendChild(newIframe);
 }
 

And with it I'm not longer able to reproduce the failure. However I'm afraid that this would only workaround the issue (just wait 100ms more) but won't fix the underlying problem.