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');
13 chrome
.printerProvider
.onGetCapabilityRequested
.addListener(
14 function(printerId
, callback
) {
15 chrome
.test
.assertFalse(!!chrome
.printerProviderInternal
);
16 chrome
.test
.assertEq('printer_id', printerId
);
17 chrome
.test
.assertTrue(!!callback
);
19 if (test
== 'ASYNC_RESPONSE') {
20 setTimeout(callback
.bind(null, {'capability': 'value'}), 0);
21 chrome
.test
.succeed();
25 if (test
== 'IGNORE_CALLBACK') {
26 chrome
.test
.succeed();
30 if (test
== 'INVALID_VALUE') {
31 chrome
.test
.assertThrows(
34 'Invalid value for argument 1. '+
35 'Expected \'object\' but got \'string\'.');
36 } else if (test
== 'EMPTY') {
39 chrome
.test
.assertEq('OK', test
);
40 callback({'capability': 'value'});
43 chrome
.test
.assertThrows(
46 'Event callback must not be called more than once.');
48 chrome
.test
.succeed();
51 chrome
.test
.sendMessage('ready');