ac818f72e7d6fe5bb3cabceb63df198abe602272
[WebKit.git] / Websites / perf.webkit.org / public / v3 / components / test-group-form.js
1
2 class TestGroupForm extends ComponentBase {
3
4     constructor(name)
5     {
6         super(name || 'test-group-form');
7         this._repetitionCount = 4;
8     }
9
10     setRepetitionCount(count)
11     {
12         this.content('repetition-count').value = count;
13     }
14
15     didConstructShadowTree()
16     {
17         const repetitionCountSelect = this.content('repetition-count');
18         repetitionCountSelect.onchange = () => {
19             this._repetitionCount = repetitionCountSelect.value;
20         }
21         this.content('form').onsubmit = this.createEventHandler(() => this.startTesting());
22     }
23
24     startTesting()
25     {
26         this.dispatchAction('startTesting', this._repetitionCount);
27     }
28
29     static htmlTemplate()
30     {
31         return `<form id="form"><button id="start-button" type="submit"><slot>Start A/B testing</slot></button>${this.formContent()}</form>`;
32     }
33
34     static formContent()
35     {
36         return `
37             with
38             <select id="repetition-count">
39                 <option>1</option>
40                 <option>2</option>
41                 <option>3</option>
42                 <option>4</option>
43                 <option>5</option>
44                 <option>6</option>
45                 <option>7</option>
46                 <option>8</option>
47                 <option>9</option>
48                 <option>10</option>
49             </select>
50             iterations per set
51         `;
52     }
53
54 }
55
56 ComponentBase.defineElement('test-group-form', TestGroupForm);