OLD | NEW |
1 // Copyright 2013 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 function moduleDidLoad() { | 5 function moduleDidLoad() { |
6 // 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 |
7 // failed to load. | 7 // failed to load. |
8 common.hideModule(); | 8 common.hideModule(); |
9 } | 9 } |
10 | 10 |
11 var currentTestEl = null; | 11 var currentTestEl = null; |
| 12 var failedTests = 0; |
| 13 var testsFinished = false; |
12 | 14 |
13 function startCommand(testName) { | 15 function startCommand(testName) { |
14 var testListEl = document.getElementById('tests'); | 16 var testListEl = document.getElementById('tests'); |
15 var testEl = document.createElement('li'); | 17 var testEl = document.createElement('li'); |
16 var testRowEl = document.createElement('div'); | 18 var testRowEl = document.createElement('div'); |
17 var testNameEl = document.createElement('span'); | 19 var testNameEl = document.createElement('span'); |
18 var testResultEl = document.createElement('span'); | 20 var testResultEl = document.createElement('span'); |
19 testRowEl.classList.add('row'); | 21 testRowEl.classList.add('row'); |
20 testNameEl.classList.add('name'); | 22 testNameEl.classList.add('name'); |
21 testNameEl.textContent = testName; | 23 testNameEl.textContent = testName; |
22 testResultEl.classList.add('result'); | 24 testResultEl.classList.add('result'); |
23 testRowEl.appendChild(testNameEl); | 25 testRowEl.appendChild(testNameEl); |
24 testRowEl.appendChild(testResultEl); | 26 testRowEl.appendChild(testResultEl); |
25 testEl.appendChild(testRowEl); | 27 testEl.appendChild(testRowEl); |
26 testListEl.appendChild(testEl); | 28 testListEl.appendChild(testEl); |
27 | 29 |
28 currentTestEl = testEl; | 30 currentTestEl = testEl; |
29 } | 31 } |
30 | 32 |
31 function failCommand(fileName, lineNumber, summary) { | 33 function failCommand(fileName, lineNumber, summary) { |
32 var testMessageEl = document.createElement('pre'); | 34 var testMessageEl = document.createElement('pre'); |
33 testMessageEl.textContent += fileName + ':' + lineNumber + ': ' + summary; | 35 testMessageEl.textContent += fileName + ':' + lineNumber + ': ' + summary; |
34 currentTestEl.appendChild(testMessageEl); | 36 currentTestEl.appendChild(testMessageEl); |
| 37 failedTests++; |
35 } | 38 } |
36 | 39 |
37 function endCommand(testName, testResult) { | 40 function endCommand(testName, testResult) { |
38 var testRowEl = currentTestEl.querySelector('.row'); | 41 var testRowEl = currentTestEl.querySelector('.row'); |
39 var testResultEl = currentTestEl.querySelector('.result'); | 42 var testResultEl = currentTestEl.querySelector('.result'); |
40 testRowEl.classList.add(testResult); | 43 testRowEl.classList.add(testResult); |
41 testResultEl.textContent = testResult; | 44 testResultEl.textContent = testResult; |
42 } | 45 } |
43 | 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 |
44 function handleMessage(event) { | 59 function handleMessage(event) { |
45 var msg = event.data; | 60 var msg = event.data; |
46 var firstColon = msg.indexOf(':'); | 61 var firstColon = msg.indexOf(':'); |
47 var cmd = msg.substr(0, firstColon); | 62 var cmd = firstColon !== -1 ? msg.substr(0, firstColon) : msg; |
48 var cmdFunctionName = cmd + 'Command'; | 63 var cmdFunctionName = cmd + 'Command'; |
49 var cmdFunction = window[cmdFunctionName]; | 64 var cmdFunction = window[cmdFunctionName]; |
50 | 65 |
51 if (typeof(cmdFunction) !== 'function') { | 66 if (typeof(cmdFunction) !== 'function') { |
52 console.log('Unknown command: ' + cmd); | 67 console.log('Unknown command: ' + cmd); |
53 console.log(' message: ' + msg); | 68 console.log(' message: ' + msg); |
54 return; | 69 return; |
55 } | 70 } |
56 | 71 |
57 var argCount = cmdFunction.length; | 72 var argCount = cmdFunction.length; |
(...skipping 18 matching lines...) Expand all Loading... |
76 argList = argList.substr(comma + 1); | 91 argList = argList.substr(comma + 1); |
77 } | 92 } |
78 args.push(arg); | 93 args.push(arg); |
79 } | 94 } |
80 | 95 |
81 // Last argument is the rest of the message. | 96 // Last argument is the rest of the message. |
82 args.push(argList); | 97 args.push(argList); |
83 | 98 |
84 cmdFunction.apply(null, args); | 99 cmdFunction.apply(null, args); |
85 } | 100 } |
OLD | NEW |