OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // Called by the common.js module. | 4 // Called by the common.js module. |
5 | |
6 function moduleDidLoad() { | 5 function moduleDidLoad() { |
7 // The module is not hidden by default so we can easily see if the plugin | 6 // The module is not hidden by default so we can easily see if the plugin |
8 // failed to load. | 7 // failed to load. |
9 common.hideModule(); | 8 common.hideModule(); |
10 } | 9 } |
11 | 10 |
12 var currentTestEl = null; | 11 var currentTestEl = null; |
| 12 var failedTests = 0; |
| 13 var testsFinished = false; |
13 | 14 |
14 function startCommand(testName) { | 15 function startCommand(testName) { |
15 var testListEl = document.getElementById('tests'); | 16 var testListEl = document.getElementById('tests'); |
16 var testEl = document.createElement('li'); | 17 var testEl = document.createElement('li'); |
17 var testRowEl = document.createElement('div'); | 18 var testRowEl = document.createElement('div'); |
18 var testNameEl = document.createElement('span'); | 19 var testNameEl = document.createElement('span'); |
19 var testResultEl = document.createElement('span'); | 20 var testResultEl = document.createElement('span'); |
20 testRowEl.classList.add('row'); | 21 testRowEl.classList.add('row'); |
21 testNameEl.classList.add('name'); | 22 testNameEl.classList.add('name'); |
22 testNameEl.textContent = testName; | 23 testNameEl.textContent = testName; |
23 testResultEl.classList.add('result'); | 24 testResultEl.classList.add('result'); |
24 testRowEl.appendChild(testNameEl); | 25 testRowEl.appendChild(testNameEl); |
25 testRowEl.appendChild(testResultEl); | 26 testRowEl.appendChild(testResultEl); |
26 testEl.appendChild(testRowEl); | 27 testEl.appendChild(testRowEl); |
27 testListEl.appendChild(testEl); | 28 testListEl.appendChild(testEl); |
28 | 29 |
29 currentTestEl = testEl; | 30 currentTestEl = testEl; |
30 } | 31 } |
31 | 32 |
32 function failCommand(fileName, lineNumber, summary) { | 33 function failCommand(fileName, lineNumber, summary) { |
33 var testMessageEl = document.createElement('pre'); | 34 var testMessageEl = document.createElement('pre'); |
34 testMessageEl.textContent += fileName + ':' + lineNumber + ': ' + summary; | 35 testMessageEl.textContent += fileName + ':' + lineNumber + ': ' + summary; |
35 currentTestEl.appendChild(testMessageEl); | 36 currentTestEl.appendChild(testMessageEl); |
| 37 failedTests++; |
36 } | 38 } |
37 | 39 |
38 function endCommand(testName, testResult) { | 40 function endCommand(testName, testResult) { |
39 var testRowEl = currentTestEl.querySelector('.row'); | 41 var testRowEl = currentTestEl.querySelector('.row'); |
40 var testResultEl = currentTestEl.querySelector('.result'); | 42 var testResultEl = currentTestEl.querySelector('.result'); |
41 testRowEl.classList.add(testResult); | 43 testRowEl.classList.add(testResult); |
42 testResultEl.textContent = testResult; | 44 testResultEl.textContent = testResult; |
43 } | 45 } |
44 | 46 |
| 47 function testendCommand() { |
| 48 testsFinished = true; |
| 49 |
| 50 if (failedTests) { |
| 51 common.updateStatus('FAILED'); |
| 52 document.getElementById('statusField').classList.add('failed'); |
| 53 } else { |
| 54 common.updateStatus('OK'); |
| 55 document.getElementById('statusField').classList.add('ok'); |
| 56 } |
| 57 } |
| 58 |
45 function handleMessage(event) { | 59 function handleMessage(event) { |
46 var msg = event.data; | 60 var msg = event.data; |
47 var firstColon = msg.indexOf(':'); | 61 var firstColon = msg.indexOf(':'); |
48 var cmd = msg.substr(0, firstColon); | 62 var cmd = firstColon !== -1 ? msg.substr(0, firstColon) : msg; |
49 var cmdFunctionName = cmd + 'Command'; | 63 var cmdFunctionName = cmd + 'Command'; |
50 var cmdFunction = window[cmdFunctionName]; | 64 var cmdFunction = window[cmdFunctionName]; |
51 | 65 |
52 if (typeof(cmdFunction) !== 'function') { | 66 if (typeof(cmdFunction) !== 'function') { |
53 console.log('Unknown command: ' + cmd); | 67 console.log('Unknown command: ' + cmd); |
54 console.log(' message: ' + msg); | 68 console.log(' message: ' + msg); |
55 return; | 69 return; |
56 } | 70 } |
57 | 71 |
58 var argCount = cmdFunction.length; | 72 var argCount = cmdFunction.length; |
(...skipping 18 matching lines...) Expand all Loading... |
77 argList = argList.substr(comma + 1); | 91 argList = argList.substr(comma + 1); |
78 } | 92 } |
79 args.push(arg); | 93 args.push(arg); |
80 } | 94 } |
81 | 95 |
82 // Last argument is the rest of the message. | 96 // Last argument is the rest of the message. |
83 args.push(argList); | 97 args.push(argList); |
84 | 98 |
85 cmdFunction.apply(null, args); | 99 cmdFunction.apply(null, args); |
86 } | 100 } |
OLD | NEW |