Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / extensions / test / data / api_test / printer_provider / request_capability / test.js
blob2ad5b85677bd75f292d6ff64acce2d056c054c8a
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.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();
22 return;
25 if (test == 'IGNORE_CALLBACK') {
26 chrome.test.succeed();
27 return;
30 if (test == 'INVALID_VALUE') {
31 chrome.test.assertThrows(
32 callback,
33 ['XXX'],
34 'Invalid value for argument 1. '+
35 'Expected \'object\' but got \'string\'.');
36 } else if (test == 'EMPTY') {
37 callback({});
38 } else {
39 chrome.test.assertEq('OK', test);
40 callback({'capability': 'value'});
43 chrome.test.assertThrows(
44 callback,
45 [{'cap': 'value'}],
46 'Event callback must not be called more than once.');
48 chrome.test.succeed();
49 });
51 chrome.test.sendMessage('ready');
52 }]);
53 });