REGRESSION(r217118): Speedometer 2.0: Flight.js test is broken
[WebKit-https.git] / Websites / browserbench.org / Speedometer2.0 / resources / tests.js
index dc59f8fc55ea8872eed9861b9887b6444d0b15be..dd9a6fadfe0b3e33bc9483d1c429218fa2a6bf9f 100644 (file)
@@ -250,9 +250,8 @@ Suites.push({
                 checkboxes[i].click();
         }),
         new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
-            var deleteButtons = contentDocument.querySelectorAll('.destroy');
-            for (var i = 0; i < deleteButtons.length; i++)
-                deleteButtons[i].click();
+            for (var i = 0; i < numberOfItemsToAdd; i++)
+                contentDocument.querySelector('.destroy').click();
         }),
     ]
 });
@@ -340,14 +339,13 @@ Suites.push({
             }
         }),
         new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
-            var checkboxes = contentDocument.querySelectorAll('.toggle');
+            var checkboxes = contentDocument.getElementsByClassName('toggle');
             for (var i = 0; i < checkboxes.length; i++)
                 checkboxes[i].click();
         }),
         new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
-            var deleteButtons = contentDocument.querySelectorAll('.destroy');
-            for (var i = 0; i < deleteButtons.length; i++)
-                deleteButtons[i].click();
+            for (var i = 0; i < numberOfItemsToAdd; i++)
+                contentDocument.querySelector('.destroy').click();
         }),
     ]
 })
@@ -408,12 +406,24 @@ Suites.push({
         }),
         new BenchmarkTestStep('DeletingItems', function (params, contentWindow, contentDocument) {
             var deleteButtons = contentDocument.querySelectorAll('.destroy');
-            for (var i = 0; i < deleteButtons.length; i++)
-                deleteButtons[i].click();
+            for (var i = 0; i < numberOfItemsToAdd; i++)
+                contentDocument.querySelector('.destroy').click();
         }),
     ]
 });
 
+function processElmWorkQueue(contentWindow)
+{
+    contentWindow.elmWork();
+    var callbacks = contentWindow.rAFCallbackList;
+    var i = 0;
+    while (i < callbacks.length) {
+        callbacks[i]();
+        i++;
+    }
+    contentWindow.rAFCallbackList = [];
+}
+
 Suites.push({
     name: 'Elm-TodoMVC',
     url: 'todomvc/functional-prog-examples/elm/index.html',
@@ -431,18 +441,23 @@ Suites.push({
                   bubbles: true,
                   cancelable: true
                 }));
+                processElmWorkQueue(contentWindow);
                 triggerEnter(newTodo, 'keydown');
+                processElmWorkQueue(contentWindow);
             }
         }),
         new BenchmarkTestStep('CompletingAllItems', function (params, contentWindow, contentDocument) {
             var checkboxes = contentDocument.querySelectorAll('.toggle');
-            for (var i = 0; i < checkboxes.length; i++)
+            for (var i = 0; i < checkboxes.length; i++) {
                 checkboxes[i].click();
+                processElmWorkQueue(contentWindow);
+            }
         }),
         new BenchmarkTestStep('DeletingItems', function (params, contentWindow, contentDocument) {
-            var deleteButtons = contentDocument.querySelectorAll('.destroy');
-            for (var i = 0; i < deleteButtons.length; i++)
-                deleteButtons[i].click();
+            for (var i = 0; i < numberOfItemsToAdd; i++) {
+                contentDocument.querySelector('.destroy').click();
+                processElmWorkQueue(contentWindow);
+            }
         }),
     ]
 });
@@ -451,9 +466,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: [