DoYouEvenBench: Make it work on Internet Explorer 11 Release Preview
[WebKit-https.git] / PerformanceTests / DoYouEvenBench / benchmark.html
index e7447f1de9e3f5660434714acd3163a2f78cbbcd..bb5528988644b73b6028497c754fdad77d726b58 100644 (file)
@@ -113,7 +113,6 @@ BenchmarkRunner.suite({
     name: 'jQuery/TodoMVC',
     url: 'todomvc/architecture-examples/jquery/index.html',
     prepare: function (contentWindow, contentDocument) {
-    var storage = [];
         return BenchmarkRunner.waitForElement('#new-todo').then(function (element) {
             element.focus();
             return element;
@@ -126,19 +125,42 @@ BenchmarkRunner.suite({
             for (var i = 0; i < numberOfItemsToAdd; i++) {
                 newTodo.value = 'Something to do ' + i;
                 app.create.call(newTodo, fakeEvent);
-                }
+            }
         }],
         ['CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
             var app = contentWindow.app;
             var checkboxes = contentDocument.querySelectorAll('.toggle');
+            var $ = contentWindow.$;
+
+            itemIndexToId = new Array(checkboxes.length);
             for (var i = 0; i < checkboxes.length; i++)
-            app.toggle.call(checkboxes[i]);
+                itemIndexToId[i] = $(checkboxes[i]).closest('li').data('id');
+
+            app.getTodo = function (element, callback) {
+                var self = this;
+                var id = itemIndexToId[this.currentItemIndex];
+                $.each(this.todos, function (j, val) {
+                    if (val.id === id) {
+                        callback.apply(self, arguments);
+                        return false;
+                    }
+                });
+            }
+
+            for (var i = 0; i < checkboxes.length; i++) {
+                app.currentItemIndex = i;
+                app.toggle.call(checkboxes[i]);
+            }
         }],
         ['DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
+            contentDocument.querySelector('#clear-completed').click();
             var app = contentWindow.app;
             var deleteButtons = contentDocument.querySelectorAll('.destroy');
-            for (var i = 0; i < deleteButtons.length; i++)
-            app.destroy.call(deleteButtons[i]);
+
+            for (var i = 0; i < deleteButtons.length; i++) {
+                app.currentItemIndex = i;
+                app.destroy.call(deleteButtons[i]);
+            }
         }],
     ]
 });
@@ -147,7 +169,6 @@ BenchmarkRunner.suite({
     name: 'AngularJS/TodoMVC',
     url: 'todomvc/architecture-examples/angularjs/index.html',
     prepare: function (contentWindow, contentDocument) {
-    var storage = [];
         return BenchmarkRunner.waitForElement('#new-todo').then(function (element) {
             element.focus();
             return element;
@@ -179,9 +200,98 @@ BenchmarkRunner.suite({
     ]
 });
 
+BenchmarkRunner.suite({
+    name: 'React/TodoMVC',
+    url: 'todomvc/labs/architecture-examples/react/index.html',
+    prepare: function (contentWindow, contentDocument) {
+        contentWindow.Utils.store = function () {}
+        return BenchmarkRunner.waitForElement('#new-todo').then(function (element) {
+            element.focus();
+            return element;
+        });
+    },
+    tests: [
+        ['Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
+            var todomvc = contentWindow.todomvc;
+            for (var i = 0; i < numberOfItemsToAdd; i++) {
+                newTodo.value = 'Something to do ' + i;
+
+                var keydownEvent = document.createEvent('Event');
+                keydownEvent.initEvent('keydown', true, true);
+                keydownEvent.which = 13; // VK_ENTER
+                newTodo.dispatchEvent(keydownEvent);
+            }
+        }],
+        ['CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
+            var checkboxes = contentDocument.querySelectorAll('.toggle');
+            for (var i = 0; i < checkboxes.length; i++)
+                checkboxes[i].click();
+        }],
+        ['DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
+            var deleteButtons = contentDocument.querySelectorAll('.destroy');
+            for (var i = 0; i < deleteButtons.length; i++)
+                deleteButtons[i].click();
+        }],
+    ]
+});
+
+var actionCount = 50;
+BenchmarkRunner.suite({
+    name: 'FlightJS/MailClient',
+    url: 'flightjs-example-app/index.html',
+    prepare: function (contentWindow, contentDocument) {
+        return BenchmarkRunner.waitForElement('.span8').then(function (element) {
+            element.focus();
+            return element;
+        });
+    },
+    tests: [
+        ['OpeningTabs' + actionCount + 'Times', function (newTodo, contentWindow, contentDocument) {
+            contentDocument.getElementById('inbox').click();
+            for (var i = 0; i < actionCount; i++) {
+                contentDocument.getElementById('later').click();
+                contentDocument.getElementById('sent').click();
+                contentDocument.getElementById('trash').click();
+                contentDocument.getElementById('inbox').click();
+            }
+        }],
+        ['MovingEmails' + actionCount + 'Times', function (newTodo, contentWindow, contentDocument) {
+            contentDocument.getElementById('inbox').click();
+            for (var i = 0; i < actionCount; i++) {
+                contentDocument.getElementById('mail_2139').click();
+                contentDocument.getElementById('move_mail').click();
+                contentDocument.querySelector('#move_to_selector #later').click();
+                contentDocument.getElementById('later').click();
+                contentDocument.getElementById('mail_2139').click();
+                contentDocument.getElementById('move_mail').click();
+                contentDocument.querySelector('#move_to_selector #trash').click();
+                contentDocument.getElementById('trash').click();
+                contentDocument.getElementById('mail_2139').click();
+                contentDocument.getElementById('move_mail').click();
+                contentDocument.querySelector('#move_to_selector #inbox').click();
+                contentDocument.getElementById('inbox').click();
+            }
+        }],
+        ['Sending' + actionCount + 'NewEmails', function (newTodo, contentWindow, contentDocument) {
+            for (var i = 0; i < actionCount; i++) {
+                contentDocument.getElementById('new_mail').click();
+                contentDocument.getElementById('recipient_select').selectedIndex = 1;
+                var subject = contentDocument.getElementById('compose_subject');
+                var message = contentDocument.getElementById('compose_message');
+                subject.focus();
+                contentWindow.$(subject).trigger('keydown');
+                contentWindow.$(subject).text('Hello');
+                message.focus();
+                contentWindow.$(message).trigger('keydown');
+                contentWindow.$(message).text('Hello,\n\nThis is a test message.\n\n- WebKitten');
+                contentDocument.getElementById('send_composed').click();
+            }
+        }],
+    ]
+});
+
 </script>
 </head>
 <body>
-<p></p>
 </body>
 </html>