Update broken references to image assets
[chromium-blink-merge.git] / extensions / test / data / api_test / printer_provider / request_printers / test.js
blob51b8e25f25ddeb3c44e2903cc7e67a4bc4a28d3e
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
3 // found in the LICENSE file.
5 chrome.test.sendMessage('loaded', function(test) {
6 chrome.test.runTests([function printTest() {
7 if (test == 'NO_LISTENER') {
8 chrome.test.sendMessage('ready');
9 chrome.test.succeed();
10 return;
13 chrome.printerProvider.onGetPrintersRequested.addListener(
14 function(callback) {
15 chrome.test.assertFalse(!!chrome.printerProviderInternal);
16 chrome.test.assertTrue(!!callback);
18 if (test == 'ASYNC_RESPONSE') {
19 setTimeout(callback.bind(null, [{
20 id: 'printer1',
21 name: 'Printer 1',
22 description: 'Test printer',
23 }]), 0);
24 chrome.test.succeed();
25 return;
28 if (test == 'IGNORE_CALLBACK') {
29 chrome.test.succeed();
30 return;
33 if (test == 'NOT_ARRAY') {
34 chrome.test.assertThrows(
35 callback,
36 ['XXX'],
37 'Invalid value for argument 1. ' +
38 'Expected \'array\' but got \'string\'.');
39 } else if (test == 'INVALID_PRINTER_TYPE') {
40 chrome.test.assertThrows(
41 callback,
42 [[{
43 id: 'printer1',
44 name: 'Printer 1',
45 description: 'Test printer'
46 }, 'printer2']],
47 'Invalid value for argument 1. ' +
48 'Property \'.1\': Expected \'object\' but got \'string\'.');
49 } else if (test == 'INVALID_PRINTER') {
50 chrome.test.assertThrows(
51 callback,
52 [[{
53 id: 'printer1',
54 name: 'Printer 1',
55 description: 'Test printer',
56 unsupported: 'print'
57 }]],
58 'Invalid value for argument 1. ' +
59 'Property \'.0.unsupported\': Unexpected property.');
60 } else {
61 chrome.test.assertEq('OK', test);
62 callback([{
63 id: 'printer1',
64 name: 'Printer 1',
65 description: 'Test printer',
66 }, {
67 id: 'printerNoDesc',
68 name: 'Printer 2'
69 }]);
72 chrome.test.assertThrows(
73 callback,
74 [],
75 'Event callback must not be called more than once.');
77 chrome.test.succeed();
78 });
80 chrome.test.sendMessage('ready');
81 }]);
82 });