| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 | 4 |
| 5 // Reads a blob content. | 5 // Reads a blob content. |
| 6 // @param {!Blob} blob The blob to read. | 6 // @param {!Blob} blob The blob to read. |
| 7 // @param {function(?string)} callback Called with the read blob content. | 7 // @param {function(?string)} callback Called with the read blob content. |
| 8 // the content will be null on error. | 8 // the content will be null on error. |
| 9 function readBlob(blob, callback) { | 9 function readBlob(blob, callback) { |
| 10 var reader = new FileReader(); | 10 var reader = new FileReader(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 case 'INVALID_DATA': | 57 case 'INVALID_DATA': |
| 58 wrapPrintCallback(callback, test); | 58 wrapPrintCallback(callback, test); |
| 59 break; | 59 break; |
| 60 case 'OK': | 60 case 'OK': |
| 61 readBlob(job.document, function(content) { | 61 readBlob(job.document, function(content) { |
| 62 wrapPrintCallback(callback, !!content ? 'OK' : 'INVALID_DATA'); | 62 wrapPrintCallback(callback, !!content ? 'OK' : 'INVALID_DATA'); |
| 63 | 63 |
| 64 if (content) | 64 if (content) |
| 65 chrome.test.assertEq('bytes', content); | 65 chrome.test.assertEq('bytes', content); |
| 66 | 66 |
| 67 chrome.test.assertEq('Print job', job.title); |
| 68 |
| 67 chrome.test.succeed(); | 69 chrome.test.succeed(); |
| 68 }); | 70 }); |
| 69 | 71 |
| 70 // Test will end asynchronously. | 72 // Test will end asynchronously. |
| 71 return; | 73 return; |
| 72 default: | 74 default: |
| 73 callback('FAILED'); | 75 callback('FAILED'); |
| 74 chrome.test.fail('Invalid input'); | 76 chrome.test.fail('Invalid input'); |
| 75 return; | 77 return; |
| 76 } | 78 } |
| 77 | 79 |
| 78 chrome.test.succeed(); | 80 chrome.test.succeed(); |
| 79 }); | 81 }); |
| 80 | 82 |
| 81 chrome.test.sendMessage('ready'); | 83 chrome.test.sendMessage('ready'); |
| 82 }]); | 84 }]); |
| 83 }); | 85 }); |
| OLD | NEW |