[CSS Shapes] Add performance test for raster shape
[WebKit-https.git] / PerformanceTests / DoYouEvenBench / resources / tests.js
1 var numberOfItemsToAdd = 100;
2 var Suites = [];
3
4 Suites.push({
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) {
9             element.focus();
10             return element;
11         });
12     },
13     tests: [
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});
19             }
20         }),
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();
25         }),
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();
30         }),
31     ]
32 });
33
34 Suites.push({
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) {
39             element.focus();
40             return {
41                 views: contentWindow.Ember.View.views,
42                 emberRun: contentWindow.Ember.run,
43             }
44         });
45     },
46     tests: [
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')); });
51             }
52         }),
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); });
58             }
59         }),
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(); });
64         }),
65     ]
66 });
67
68 Suites.push({
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) {
74             element.focus();
75             return element;
76         });
77     },
78     tests: [
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);
85             }
86         }),
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();
91         }),
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();
96         }),
97     ]
98 });
99
100 Suites.push({
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) {
105             element.focus();
106             return element;
107         });
108     },
109     tests: [
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);
116             }
117         }),
118         new BenchmarkTestStep('CompletingAllItems', function (newTodo, contentWindow, contentDocument) {
119             var app = contentWindow.app;
120             var checkboxes = contentDocument.querySelectorAll('.toggle');
121             var $ = contentWindow.$;
122
123             itemIndexToId = new Array(checkboxes.length);
124             for (var i = 0; i < checkboxes.length; i++)
125                 itemIndexToId[i] = $(checkboxes[i]).closest('li').data('id');
126
127             app.getTodo = function (element, callback) {
128                 var self = this;
129                 var id = itemIndexToId[this.currentItemIndex];
130                 $.each(this.todos, function (j, val) {
131                     if (val.id === id) {
132                         callback.apply(self, arguments);
133                         return false;
134                     }
135                 });
136             }
137
138             for (var i = 0; i < checkboxes.length; i++) {
139                 app.currentItemIndex = i;
140                 app.toggle.call(checkboxes[i]);
141             }
142         }),
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');
147
148             for (var i = 0; i < deleteButtons.length; i++) {
149                 app.currentItemIndex = i;
150                 app.destroy.call(deleteButtons[i]);
151             }
152         }),
153     ]
154 });
155
156 Suites.push({
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) {
161             element.focus();
162             return element;
163         });
164     },
165     tests: [
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);
176             }
177         }),
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();
182         }),
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();
187         }),
188     ]
189 });
190
191 Suites.push({
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) {
197             element.focus();
198             return element;
199         });
200     },
201     tests: [
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;
206
207                 var keydownEvent = document.createEvent('Event');
208                 keydownEvent.initEvent('keydown', true, true);
209                 keydownEvent.which = 13; // VK_ENTER
210                 newTodo.dispatchEvent(keydownEvent);
211             }
212         }),
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();
217         }),
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();
222         }),
223     ]
224 });
225
226 var actionCount = 50;
227 Suites.push({
228     name: 'FlightJS-MailClient',
229     url: 'flightjs-example-app/index.html',
230     prepare: function (runner, contentWindow, contentDocument) {
231         return runner.waitForElement('.span8').then(function (element) {
232             element.focus();
233             return element;
234         });
235     },
236     tests: [
237         new BenchmarkTestStep('OpeningTabs' + actionCount + 'Times', function (newTodo, contentWindow, contentDocument) {
238             contentDocument.getElementById('inbox').click();
239             for (var i = 0; i < actionCount; i++) {
240                 contentDocument.getElementById('later').click();
241                 contentDocument.getElementById('sent').click();
242                 contentDocument.getElementById('trash').click();
243                 contentDocument.getElementById('inbox').click();
244             }
245         }),
246         new BenchmarkTestStep('MovingEmails' + actionCount + 'Times', function (newTodo, contentWindow, contentDocument) {
247             contentDocument.getElementById('inbox').click();
248             for (var i = 0; i < actionCount; i++) {
249                 contentDocument.getElementById('mail_2139').click();
250                 contentDocument.getElementById('move_mail').click();
251                 contentDocument.querySelector('#move_to_selector #later').click();
252                 contentDocument.getElementById('later').click();
253                 contentDocument.getElementById('mail_2139').click();
254                 contentDocument.getElementById('move_mail').click();
255                 contentDocument.querySelector('#move_to_selector #trash').click();
256                 contentDocument.getElementById('trash').click();
257                 contentDocument.getElementById('mail_2139').click();
258                 contentDocument.getElementById('move_mail').click();
259                 contentDocument.querySelector('#move_to_selector #inbox').click();
260                 contentDocument.getElementById('inbox').click();
261             }
262         }),
263         new BenchmarkTestStep('Sending' + actionCount + 'NewEmails', function (newTodo, contentWindow, contentDocument) {
264             for (var i = 0; i < actionCount; i++) {
265                 contentDocument.getElementById('new_mail').click();
266                 contentDocument.getElementById('recipient_select').selectedIndex = 1;
267                 var subject = contentDocument.getElementById('compose_subject');
268                 var message = contentDocument.getElementById('compose_message');
269                 subject.focus();
270                 contentWindow.$(subject).trigger('keydown');
271                 contentWindow.$(subject).text('Hello');
272                 message.focus();
273                 contentWindow.$(message).trigger('keydown');
274                 contentWindow.$(message).text('Hello,\n\nThis is a test message.\n\n- WebKitten');
275                 contentDocument.getElementById('send_composed').click();
276             }
277         }),
278     ]
279 });