Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: extensions/test/data/api_test/printer_provider/request_print/test.js

Issue 973993003: Instead of ArrayBuffer, pass blob with printerProvider.onPrintRequested (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 function readBlob(blob, callback) {
6 var reader = new FileReader();
7 reader.onerror = function() { callback(null); };
8 reader.onloadend = function() {
9 callback(reader.result);
10 }
11 reader.readAsText(blob)
12 }
13
5 chrome.test.sendMessage('loaded', function(test) { 14 chrome.test.sendMessage('loaded', function(test) {
6 chrome.test.runTests([function printTest() { 15 chrome.test.runTests([function printTest() {
7 if (test == 'NO_LISTENER') { 16 if (test == 'NO_LISTENER') {
8 chrome.test.sendMessage('ready'); 17 chrome.test.sendMessage('ready');
9 chrome.test.succeed(); 18 chrome.test.succeed();
10 return; 19 return;
11 } 20 }
12 21
13 chrome.printerProvider.onPrintRequested.addListener(function(job, 22 chrome.printerProvider.onPrintRequested.addListener(function(job,
14 callback) { 23 callback) {
(...skipping 11 matching lines...) Expand all
26 return; 35 return;
27 } 36 }
28 37
29 if (test == 'INVALID_VALUE') { 38 if (test == 'INVALID_VALUE') {
30 chrome.test.assertThrows( 39 chrome.test.assertThrows(
31 callback, 40 callback,
32 ['XXX'], 41 ['XXX'],
33 'Invalid value for argument 1. ' + 42 'Invalid value for argument 1. ' +
34 'Value must be one of: ' + 43 'Value must be one of: ' +
35 '[OK, FAILED, INVALID_TICKET, INVALID_DATA].'); 44 '[OK, FAILED, INVALID_TICKET, INVALID_DATA].');
45 chrome.test.succeed();
46 } else if (test == 'OK') {
not at google - send to devlin 2015/03/04 21:54:50 Looks odd that the rest of the test uses the patte
tbarzic 2015/03/04 23:24:34 Done.
47 readBlob(job.document, function(content) {
48 callback(!!content ? 'OK' : 'INVALID_DATA');
49
50 if (content)
51 chrome.test.assertEq('bytes', content);
52
53 chrome.test.assertThrows(
54 callback,
55 [test],
56 'Event callback must not be called more than once.');
57 chrome.test.succeed();
58 });
36 } else { 59 } else {
37 chrome.test.assertTrue(test == 'OK' || test == 'FAILED' || 60 chrome.test.assertTrue(test == 'FAILED' || test == 'INVALID_TICKET' ||
38 test == 'INVALID_TICKET' || test == 'INVALID_DATA'); 61 test == 'INVALID_DATA');
not at google - send to devlin 2015/03/04 21:54:50 If you used a switch you could make this look a bi
tbarzic 2015/03/04 23:24:34 Done.
39 callback(test); 62 callback(test);
63 chrome.test.assertThrows(
64 callback,
65 [test],
66 'Event callback must not be called more than once.');
67 chrome.test.succeed();
40 } 68 }
41 69
42 chrome.test.assertThrows(
43 callback,
44 [test],
45 'Event callback must not be called more than once.');
46
47 chrome.test.succeed();
48 }); 70 });
49 71
50 chrome.test.sendMessage('ready'); 72 chrome.test.sendMessage('ready');
51 }]); 73 }]);
52 }); 74 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698