Speedometer 2.0: Flight.js test is sometime broken
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 10:05:13 +0000 (10:05 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 10:05:13 +0000 (10:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=172347

Reviewed by Antti Koivisto.

The bug was caused by the test runner only waiting for #new-todo, which happens before all other states are
updated in the Flight.js dependency example. As done in Speedometer v1, insert a dummy element with id set
to appIsReady and wait for this element to appear in the benchmark harness.

* Speedometer/resources/tests.js: Wait for #appIsReady.
* Speedometer/resources/todomvc/dependency-examples/flight/flight/app/js/main.js: Removed the superflous call
to console.log.
(checkReady): Added. Insert #appIsReady if checkLoaded is no longer running at 50ms interval. Because this
could happen asynchronously, we check the absense of checkLoadedTimeoutId Ωevery 10ms for 5 times for
the total duration of 50ms. If checkLoadedTimeoutId was never present, we call it ready. If we ever observed
the presence of checkLoadedTimeoutId, wait another 50ms and start over.
* Speedometer/resources/todomvc/dependency-examples/flight/flight/node_modules/requirejs/require.js:
(.newContext.checkLoaded): Expose checkLoadedTimeoutId which is a timer ID used to check the dependency.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217118 268f45cc-cd09-0410-ab3c-d52691b4dbfc

PerformanceTests/ChangeLog
PerformanceTests/Speedometer/resources/tests.js
PerformanceTests/Speedometer/resources/todomvc/dependency-examples/flight/flight/app/js/main.js
PerformanceTests/Speedometer/resources/todomvc/dependency-examples/flight/flight/node_modules/requirejs/require.js

index 98c0286..514c59d 100644 (file)
@@ -1,3 +1,24 @@
+2017-05-18  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Speedometer 2.0: Flight.js test is sometime broken
+        https://bugs.webkit.org/show_bug.cgi?id=172347
+
+        Reviewed by Antti Koivisto.
+
+        The bug was caused by the test runner only waiting for #new-todo, which happens before all other states are
+        updated in the Flight.js dependency example. As done in Speedometer v1, insert a dummy element with id set
+        to appIsReady and wait for this element to appear in the benchmark harness.
+
+        * Speedometer/resources/tests.js: Wait for #appIsReady.
+        * Speedometer/resources/todomvc/dependency-examples/flight/flight/app/js/main.js: Removed the superflous call
+        to console.log.
+        (checkReady): Added. Insert #appIsReady if checkLoaded is no longer running at 50ms interval. Because this
+        could happen asynchronously, we check the absense of checkLoadedTimeoutId Ωevery 10ms for 5 times for
+        the total duration of 50ms. If checkLoadedTimeoutId was never present, we call it ready. If we ever observed
+        the presence of checkLoadedTimeoutId, wait another 50ms and start over.
+        * Speedometer/resources/todomvc/dependency-examples/flight/flight/node_modules/requirejs/require.js:
+        (.newContext.checkLoaded): Expose checkLoadedTimeoutId which is a timer ID used to check the dependency.
+
 2017-05-19  Ryosuke Niwa  <rniwa@webkit.org>
 
         Speedometer 2.0: jQuery and Inferno tests don't delete all ToDo items
index 2c9d397..d451307 100644 (file)
@@ -450,9 +450,10 @@ Suites.push({
     name: 'Flight-TodoMVC',
     url: 'todomvc/dependency-examples/flight/flight/index.html',
     prepare: function (runner, contentWindow, contentDocument) {
-        return runner.waitForElement('#new-todo').then(function (element) {
-            element.focus();
-            return element;
+        return runner.waitForElement('#appIsReady').then(function (element) {
+            var newTodo = contentDocument.getElementById('new-todo');
+            newTodo.focus();
+            return newTodo;
         });
     },
     tests: [
index 464773f..79dd75c 100644 (file)
@@ -23,9 +23,20 @@ require.config({
     }
 });
 
+function checkReady(count) {
+    if (window.checkLoadedTimeoutId)
+        return setTimeout(checkReady.bind(this, 0), 50);
+    if (count < 5)
+        return setTimeout(checkReady.bind(this, count + 1), 10);
+
+    var dummyNodeToNotifyAppIsReady = document.createElement('div');
+    dummyNodeToNotifyAppIsReady.id = 'appIsReady';
+    document.body.appendChild(dummyNodeToNotifyAppIsReady);
+}
+
 require([], function () {
     require(['app/page/app'],function(App){
         App.initialize();
-        console.log(App);
+        checkReady(0);
     });
 });
index 0fc1082..e1b56d3 100644 (file)
@@ -718,6 +718,7 @@ var requirejs, require, define;
                         checkLoadedTimeoutId = 0;
                         checkLoaded();
                     }, 50);
+                    window.checkLoadedTimeoutId = checkLoadedTimeoutId;
                 }
             }