1 var numberOfItemsToAdd = 100;
5 name: 'VanillaJS-TodoMVC',
6 url: 'todomvc/vanilla-examples/vanillajs/index.html',
7 prepare: function (runner, contentWindow, contentDocument) {
8 return runner.waitForElement('#new-todo').then(function (element) {
14 new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
15 var todoController = contentWindow.todo.controller;
16 for (var i = 0; i < numberOfItemsToAdd; i++) {
17 newTodo.value = 'Something to do ' + i;
18 todoController.addItem({keyCode: todoController.ENTER_KEY, target: newTodo});
21 new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
22 var checkboxes = contentDocument.querySelectorAll('.toggle');
23 for (var i = 0; i < checkboxes.length; i++)
24 checkboxes[i].click();
26 new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
27 var deleteButtons = contentDocument.querySelectorAll('.destroy');
28 for (var i = 0; i < deleteButtons.length; i++)
29 deleteButtons[i].click();
35 name: 'EmberJS-TodoMVC',
36 url: 'todomvc/architecture-examples/emberjs/index.html',
37 prepare: function (runner, contentWindow, contentDocument) {
38 return runner.waitForElement('#new-todo').then(function (element) {
41 views: contentWindow.Ember.View.views,
42 emberRun: contentWindow.Ember.run,
47 new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (params) {
48 for (var i = 0; i < numberOfItemsToAdd; i++) {
49 params.emberRun(function () { params.views["new-todo"].set('value', 'Something to do' + i); });
50 params.emberRun(function () { params.views["new-todo"].insertNewline(document.createEvent('Event')); });
53 new BenchmarkTestStep('CompletingAllItems', function (params, contentWindow, contentDocument) {
54 var checkboxes = contentDocument.querySelectorAll('.ember-checkbox');
55 for (var i = 0; i < checkboxes.length; i++) {
56 var view = params.views[checkboxes[i].id];
57 params.emberRun(function () { view.set('checked', true); });
60 new BenchmarkTestStep('DeletingItems', function (params, contentWindow, contentDocument) {
61 var deleteButtons = contentDocument.querySelectorAll('.destroy');
62 for (var i = 0; i < deleteButtons.length; i++)
63 params.emberRun(function () { deleteButtons[i].click(); });
69 name: 'BackboneJS-TodoMVC',
70 url: 'todomvc/architecture-examples/backbone/index.html',
71 prepare: function (runner, contentWindow, contentDocument) {
72 contentWindow.Backbone.sync = function () {}
73 return runner.waitForElement('#new-todo').then(function (element) {
79 new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
80 var appView = contentWindow.appView;
81 var fakeEvent = {which: contentWindow.ENTER_KEY};
82 for (var i = 0; i < numberOfItemsToAdd; i++) {
83 newTodo.value = 'Something to do ' + i;
84 appView.createOnEnter(fakeEvent);
87 new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
88 var checkboxes = contentDocument.querySelectorAll('.toggle');
89 for (var i = 0; i < checkboxes.length; i++)
90 checkboxes[i].click();
92 new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
93 var deleteButtons = contentDocument.querySelectorAll('.destroy');
94 for (var i = 0; i < deleteButtons.length; i++)
95 deleteButtons[i].click();
101 name: 'jQuery-TodoMVC',
102 url: 'todomvc/architecture-examples/jquery/index.html',
103 prepare: function (runner, contentWindow, contentDocument) {
104 return runner.waitForElement('#new-todo').then(function (element) {
110 new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
111 var app = contentWindow.app;
112 var fakeEvent = {which: app.ENTER_KEY};
113 for (var i = 0; i < numberOfItemsToAdd; i++) {
114 newTodo.value = 'Something to do ' + i;
115 app.create.call(newTodo, fakeEvent);
118 new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
119 var app = contentWindow.app;
120 var checkboxes = contentDocument.querySelectorAll('.toggle');
121 var $ = contentWindow.$;
123 itemIndexToId = new Array(checkboxes.length);
124 for (var i = 0; i < checkboxes.length; i++)
125 itemIndexToId[i] = $(checkboxes[i]).closest('li').data('id');
127 app.getTodo = function (element, callback) {
129 var id = itemIndexToId[this.currentItemIndex];
130 $.each(this.todos, function (j, val) {
132 callback.apply(self, arguments);
138 for (var i = 0; i < checkboxes.length; i++) {
139 app.currentItemIndex = i;
140 app.toggle.call(checkboxes[i]);
143 new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
144 contentDocument.querySelector('#clear-completed').click();
145 var app = contentWindow.app;
146 var deleteButtons = contentDocument.querySelectorAll('.destroy');
148 for (var i = 0; i < deleteButtons.length; i++) {
149 app.currentItemIndex = i;
150 app.destroy.call(deleteButtons[i]);
157 name: 'AngularJS-TodoMVC',
158 url: 'todomvc/architecture-examples/angularjs/index.html',
159 prepare: function (runner, contentWindow, contentDocument) {
160 return runner.waitForElement('#new-todo').then(function (element) {
166 new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
167 var todomvc = contentWindow.todomvc;
168 var submitEvent = document.createEvent('Event');
169 submitEvent.initEvent('submit', true, true);
170 var inputEvent = document.createEvent('Event');
171 inputEvent.initEvent('input', true, true);
172 for (var i = 0; i < numberOfItemsToAdd; i++) {
173 newTodo.value = 'Something to do ' + i;
174 newTodo.dispatchEvent(inputEvent);
175 newTodo.form.dispatchEvent(submitEvent);
178 new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
179 var checkboxes = contentDocument.querySelectorAll('.toggle');
180 for (var i = 0; i < checkboxes.length; i++)
181 checkboxes[i].click();
183 new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
184 var deleteButtons = contentDocument.querySelectorAll('.destroy');
185 for (var i = 0; i < deleteButtons.length; i++)
186 deleteButtons[i].click();
192 name: 'React-TodoMVC',
193 url: 'todomvc/labs/architecture-examples/react/index.html',
194 prepare: function (runner, contentWindow, contentDocument) {
195 contentWindow.Utils.store = function () {}
196 return runner.waitForElement('#new-todo').then(function (element) {
202 new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
203 var todomvc = contentWindow.todomvc;
204 for (var i = 0; i < numberOfItemsToAdd; i++) {
205 newTodo.value = 'Something to do ' + i;
207 var keydownEvent = document.createEvent('Event');
208 keydownEvent.initEvent('keydown', true, true);
209 keydownEvent.which = 13; // VK_ENTER
210 newTodo.dispatchEvent(keydownEvent);
213 new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
214 var checkboxes = contentDocument.querySelectorAll('.toggle');
215 for (var i = 0; i < checkboxes.length; i++)
216 checkboxes[i].click();
218 new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
219 var deleteButtons = contentDocument.querySelectorAll('.destroy');
220 for (var i = 0; i < deleteButtons.length; i++)
221 deleteButtons[i].click();
227 name: 'FlightJS-TodoMVC',
228 url: 'todomvc/dependency-examples/flight/index.html',
229 prepare: function (runner, contentWindow, contentDocument) {
230 return runner.waitForElement('#appIsReady').then(function () {
231 var newTodo = contentDocument.querySelector('#new-todo');
237 new BenchmarkTestStep('Adding' + numberOfItemsToAdd + 'Items', function (newTodo, contentWindow, contentDocument) {
238 var todomvc = contentWindow.todomvc;
239 for (var i = 0; i < numberOfItemsToAdd; i++) {
240 newTodo.value = 'Something to do ' + i;
242 var keydownEvent = document.createEvent('Event');
243 keydownEvent.initEvent('keydown', true, true);
244 keydownEvent.which = 13; // VK_ENTER
245 newTodo.dispatchEvent(keydownEvent);
248 new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
249 var checkboxes = contentDocument.querySelectorAll('.toggle');
250 for (var i = 0; i < checkboxes.length; i++)
251 checkboxes[i].click();
253 new BenchmarkTestStep('DeletingAllItems', function (newTodo, contentWindow, contentDocument) {
254 var deleteButtons = contentDocument.querySelectorAll('.destroy');
255 for (var i = 0; i < deleteButtons.length; i++)
256 deleteButtons[i].click();
261 var actionCount = 50;
264 name: 'FlightJS-MailClient',
265 url: 'flightjs-example-app/index.html',
266 prepare: function (runner, contentWindow, contentDocument) {
267 return runner.waitForElement('.span8').then(function (element) {
273 new BenchmarkTestStep('OpeningTabs' + actionCount + 'Times', function (newTodo, contentWindow, contentDocument) {
274 contentDocument.getElementById('inbox').click();
275 for (var i = 0; i < actionCount; i++) {
276 contentDocument.getElementById('later').click();
277 contentDocument.getElementById('sent').click();
278 contentDocument.getElementById('trash').click();
279 contentDocument.getElementById('inbox').click();
282 new BenchmarkTestStep('MovingEmails' + actionCount + 'Times', function (newTodo, contentWindow, contentDocument) {
283 contentDocument.getElementById('inbox').click();
284 for (var i = 0; i < actionCount; i++) {
285 contentDocument.getElementById('mail_2139').click();
286 contentDocument.getElementById('move_mail').click();
287 contentDocument.querySelector('#move_to_selector #later').click();
288 contentDocument.getElementById('later').click();
289 contentDocument.getElementById('mail_2139').click();
290 contentDocument.getElementById('move_mail').click();
291 contentDocument.querySelector('#move_to_selector #trash').click();
292 contentDocument.getElementById('trash').click();
293 contentDocument.getElementById('mail_2139').click();
294 contentDocument.getElementById('move_mail').click();
295 contentDocument.querySelector('#move_to_selector #inbox').click();
296 contentDocument.getElementById('inbox').click();
299 new BenchmarkTestStep('Sending' + actionCount + 'NewEmails', function (newTodo, contentWindow, contentDocument) {
300 for (var i = 0; i < actionCount; i++) {
301 contentDocument.getElementById('new_mail').click();
302 contentDocument.getElementById('recipient_select').selectedIndex = 1;
303 var subject = contentDocument.getElementById('compose_subject');
304 var message = contentDocument.getElementById('compose_message');
306 contentWindow.$(subject).trigger('keydown');
307 contentWindow.$(subject).text('Hello');
309 contentWindow.$(message).trigger('keydown');
310 contentWindow.$(message).text('Hello,\n\nThis is a test message.\n\n- WebKitten');
311 contentDocument.getElementById('send_composed').click();