forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sinon-chrome.d.ts
549 lines (474 loc) · 19.5 KB
/
sinon-chrome.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
// Type definitions for Sinon-Chrome v0.2.1
// Project: https://github.com/vitalets/sinon-chrome
// Definitions by: Tim Perry <https://github.com/pimterry>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../chrome/chrome.d.ts"/>
/// <reference path="../sinon/sinon.d.ts"/>
/**
* To use sinon-chrome:
* Use chrome.* as normal in your production code
* In tests, forcibly cast window.chrome to typeof SinonChrome to access stub API.
* @example
* var chrome = <typeof SinonChrome> <any> window.chrome;
* chrome.storage.onChanged.trigger(...);
*/
declare module SinonChrome {
/**
* Flush cache
*/
export function flush(): void;
/**
* Reset all stubs and remove event listeners
* See https://github.com/cjohansen/Sinon.JS/issues/572
*/
export function reset(): void;
export var csi: Sinon.SinonSpy;
export var loadTimes: Sinon.SinonSpy;
}
declare module SinonChrome.events {
interface Event extends chrome.events.Event {
trigger(...args: any[]): void;
triggerAsync(...args: any[]): void;
applyTrigger(args: any[]): void;
applyTriggerAsync(args: any[]): void;
addListener: Sinon.SinonSpy;
removeListener: Sinon.SinonSpy;
removeListeners: Sinon.SinonSpy;
hasListener: Sinon.SinonSpy;
}
}
declare module SinonChrome.alarms {
export var clear: Sinon.SinonSpy;
export var clearAll: Sinon.SinonSpy;
export var create: Sinon.SinonSpy;
export var get: Sinon.SinonSpy;
export var getAll: Sinon.SinonSpy;
export var onAlarm: SinonChrome.events.Event;
}
declare module SinonChrome.app {
export var getDetails: Sinon.SinonStub;
export var getDetailsForFrame: Sinon.SinonStub;
export var getDetails: Sinon.SinonStub;
export var getDetailsForFrame: Sinon.SinonStub;
export var getIsInstalled: Sinon.SinonStub;
export var installState: Sinon.SinonStub;
export var runningState: Sinon.SinonStub;
}
declare module SinonChrome.bookmarks {
export var create: Sinon.SinonStub;
export var get: Sinon.SinonStub;
export var getChildren: Sinon.SinonStub;
export var getRecent: Sinon.SinonStub;
export var getSubTree: Sinon.SinonStub;
export var getTree: Sinon.SinonStub;
export var move: Sinon.SinonStub;
export var remove: Sinon.SinonStub;
export var removeTree: Sinon.SinonStub;
export var search: Sinon.SinonStub;
export var update: Sinon.SinonStub;
export var onChanged: SinonChrome.events.Event;
export var onChildrenReordered: SinonChrome.events.Event;
export var onCreated: SinonChrome.events.Event;
export var onImportBegan: SinonChrome.events.Event;
export var onImportEnded: SinonChrome.events.Event;
export var onMoved: SinonChrome.events.Event;
export var onRemoved: SinonChrome.events.Event;
}
declare module SinonChrome.browserAction {
export var disable: Sinon.SinonStub;
export var enable: Sinon.SinonStub;
export var getBadgeBackgroundColor: Sinon.SinonStub;
export var getBadgeText: Sinon.SinonStub;
export var getPopup: Sinon.SinonStub;
export var getTitle: Sinon.SinonStub;
export var setBadgeBackgroundColor: Sinon.SinonStub;
export var setBadgeText: Sinon.SinonStub;
export var setIcon: Sinon.SinonStub;
export var setPopup: Sinon.SinonStub;
export var setTitle: Sinon.SinonStub;
export var onClicked: SinonChrome.events.Event;
}
declare module SinonChrome.browsingData {
export var remove: Sinon.SinonStub;
export var removeAppcache: Sinon.SinonStub;
export var removeCache: Sinon.SinonStub;
export var removeCookies: Sinon.SinonStub;
export var removeDownloads: Sinon.SinonStub;
export var removeFileSystems: Sinon.SinonStub;
export var removeFormData: Sinon.SinonStub;
export var removeHistory: Sinon.SinonStub;
export var removeIndexedDB: Sinon.SinonStub;
export var removeLocalStorage: Sinon.SinonStub;
export var removePasswords: Sinon.SinonStub;
export var removePluginData: Sinon.SinonStub;
export var removeWebSQL: Sinon.SinonStub;
export var settings: Sinon.SinonStub;
}
declare module SinonChrome.contentSettings {
interface StubbedContentSetting {
clear: Sinon.SinonStub;
get: Sinon.SinonStub;
getResourceIdentifiers: Sinon.SinonStub;
set: Sinon.SinonStub;
}
export var cookies: StubbedContentSetting;
export var images: StubbedContentSetting;
export var javascript: StubbedContentSetting;
export var notifications: StubbedContentSetting;
export var plugins: StubbedContentSetting;
export var popups: StubbedContentSetting;
}
declare module SinonChrome.contextMenus {
export var create: Sinon.SinonStub;
export var remove: Sinon.SinonStub;
export var removeAll: Sinon.SinonStub;
export var update: Sinon.SinonStub;
export var onClicked: SinonChrome.events.Event;
}
declare module SinonChrome.omnibox {
export var setDefaultSuggestion: Sinon.SinonStub;
export var onInputStarted: SinonChrome.events.Event;
export var onInputChanged: SinonChrome.events.Event;
export var onInputEntered: SinonChrome.events.Event;
export var onInputCancelled: SinonChrome.events.Event;
}
declare module SinonChrome.cookies {
export var get: Sinon.SinonStub;
export var getAll: Sinon.SinonStub;
export var getAllCookieStores: Sinon.SinonStub;
export var onChanged: SinonChrome.events.Event;
export var remove: Sinon.SinonStub;
export var set: Sinon.SinonStub;
}
declare module "SinonChrome.debugger" {
export var attach: Sinon.SinonStub;
export var detach: Sinon.SinonStub;
export var getTargets: Sinon.SinonStub;
export var sendCommand: Sinon.SinonStub;
export var onDetach: SinonChrome.events.Event;
export var onEvent: SinonChrome.events.Event;
}
declare module SinonChrome.declarativeContent {
export var PageStateMatcher: Sinon.SinonStub;
export var RequestContentScript: Sinon.SinonStub;
export var ShowPageAction: Sinon.SinonStub;
export var onPageChanged: SinonChrome.events.Event;
}
declare module SinonChrome. desktopCapture {
export var cancelChooseDesktopMedia: Sinon.SinonStub;
export var chooseDesktopMedia: Sinon.SinonStub;
}
declare module SinonChrome.downloads {
export var acceptDanger: Sinon.SinonStub;
export var cancel: Sinon.SinonStub;
export var download: Sinon.SinonStub;
export var drag: Sinon.SinonStub;
export var erase: Sinon.SinonStub;
export var getFileIcon: Sinon.SinonStub;
export var open: Sinon.SinonStub;
export var pause: Sinon.SinonStub;
export var removeFile: Sinon.SinonStub;
export var resume: Sinon.SinonStub;
export var search: Sinon.SinonStub;
export var setShelfEnabled: Sinon.SinonStub;
export var show: Sinon.SinonStub;
export var showDefaultFolder: Sinon.SinonStub;
export var onChanged: SinonChrome.events.Event;
export var onCreated: SinonChrome.events.Event;
export var onDeterminingFilename: SinonChrome.events.Event;
export var onErased: SinonChrome.events.Event;
}
declare module SinonChrome.extension {
export var connect: Sinon.SinonStub;
export var connectNative: Sinon.SinonStub;
export var getBackgroundPage: Sinon.SinonStub;
export var getURL: Sinon.SinonStub;
export var getViews: Sinon.SinonStub;
export var isAllowedFileSchemeAccess: Sinon.SinonStub;
export var isAllowedIncognitoAccess: Sinon.SinonStub;
export var sendMessage: Sinon.SinonStub;
export var sendNativeMessage: Sinon.SinonStub;
export var sendRequest: Sinon.SinonStub;
export var setUpdateUrlData: Sinon.SinonStub;
export var onConnect: SinonChrome.events.Event;
export var onConnectExternal: SinonChrome.events.Event;
export var onMessage: SinonChrome.events.Event;
export var onMessageExternal: SinonChrome.events.Event;
export var onRequest: SinonChrome.events.Event;
export var onRequestExternal: SinonChrome.events.Event;
}
declare module SinonChrome.fontSettings {
export var clearDefaultFixedFontSize: Sinon.SinonStub;
export var clearDefaultFontSize: Sinon.SinonStub;
export var clearFont: Sinon.SinonStub;
export var clearMinimumFontSize: Sinon.SinonStub;
export var getDefaultFixedFontSize: Sinon.SinonStub;
export var getDefaultFontSize: Sinon.SinonStub;
export var getFont: Sinon.SinonStub;
export var getFontList: Sinon.SinonStub;
export var getMinimumFontSize: Sinon.SinonStub;
export var setDefaultFixedFontSize: Sinon.SinonStub;
export var setDefaultFontSize: Sinon.SinonStub;
export var setFont: Sinon.SinonStub;
export var setMinimumFontSize: Sinon.SinonStub;
export var onDefaultFixedFontSizeChanged: SinonChrome.events.Event;
export var onDefaultFontSizeChanged: SinonChrome.events.Event;
export var onFontChanged: SinonChrome.events.Event;
export var onMinimumFontSizeChanged: SinonChrome.events.Event;
}
declare module SinonChrome.gcm {
export var onMessage: SinonChrome.events.Event;
export var onMessagesDeleted: SinonChrome.events.Event;
export var onSendError: SinonChrome.events.Event;
export var register: Sinon.SinonStub;
export var send: Sinon.SinonStub;
export var unregister: Sinon.SinonStub;
}
declare module SinonChrome.history {
export var addUrl: Sinon.SinonStub;
export var deleteAll: Sinon.SinonStub;
export var deleteRange: Sinon.SinonStub;
export var deleteUrl: Sinon.SinonStub;
export var getVisits: Sinon.SinonStub;
export var search: Sinon.SinonStub;
export var onVisitRemoved: SinonChrome.events.Event;
export var onVisited: SinonChrome.events.Event;
}
declare module SinonChrome.i18n {
export var getAcceptLanguages: Sinon.SinonStub;
export var getMessage: Sinon.SinonStub;
export var getUILanguage: Sinon.SinonStub;
}
declare module SinonChrome.identity {
export var getAuthToken: Sinon.SinonStub;
export var getProfileUserInfo: Sinon.SinonStub;
export var getRedirectURL: Sinon.SinonStub;
export var launchWebAuthFlow: Sinon.SinonStub;
export var removeCachedAuthToken: Sinon.SinonStub;
export var onSignInChanged: SinonChrome.events.Event;
}
declare module SinonChrome.idle {
export var onStateChanged: SinonChrome.events.Event;
export var queryState: Sinon.SinonStub;
export var setDetectionInterval: Sinon.SinonStub;
}
declare module SinonChrome.management {
export var createAppShortcut: Sinon.SinonStub;
export var generateAppForLink: Sinon.SinonStub;
export var get: Sinon.SinonStub;
export var getAll: Sinon.SinonStub;
export var getPermissionWarningsById: Sinon.SinonStub;
export var getPermissionWarningsByManifest: Sinon.SinonStub;
export var launchApp: Sinon.SinonStub;
export var setEnabled: Sinon.SinonStub;
export var setLaunchType: Sinon.SinonStub;
export var uninstall: Sinon.SinonStub;
export var uninstallSelf: Sinon.SinonStub;
export var onDisabled: SinonChrome.events.Event;
export var onEnabled: SinonChrome.events.Event;
export var onInstalled: SinonChrome.events.Event;
export var onUninstalled: SinonChrome.events.Event;
}
declare module SinonChrome.notifications {
export var clear: Sinon.SinonStub;
export var create: Sinon.SinonStub;
export var getAll: Sinon.SinonStub;
export var getPermissionLevel: Sinon.SinonStub;
export var update: Sinon.SinonStub;
export var onButtonClicked: SinonChrome.events.Event;
export var onClicked: SinonChrome.events.Event;
export var onClosed: SinonChrome.events.Event;
export var onPermissionLevelChanged: SinonChrome.events.Event;
export var onShowSettings: SinonChrome.events.Event;
}
declare module SinonChrome.pageCapture {
export var saveAsMHTML: Sinon.SinonStub;
}
declare module SinonChrome.permissions {
export var contains: Sinon.SinonStub;
export var getAll: Sinon.SinonStub;
export var onAdded: SinonChrome.events.Event;
export var onRemoved: SinonChrome.events.Event;
export var remove: Sinon.SinonStub;
export var request: Sinon.SinonStub;
}
declare module SinonChrome.power {
export var releaseKeepAwake: Sinon.SinonStub;
export var requestKeepAwake: Sinon.SinonStub;
}
declare module SinonChrome.types {
interface StubbedChromeSetting {
clear: Sinon.SinonStub;
get: Sinon.SinonStub;
set: Sinon.SinonStub;
onChange: SinonChrome.events.Event;
}
}
declare module SinonChrome.privacy {
export var network: {
networkPredictionEnabled: SinonChrome.types.StubbedChromeSetting;
};
export var services: {
alternateErrorPagesEnabled: SinonChrome.types.StubbedChromeSetting;
autofillEnabled: SinonChrome.types.StubbedChromeSetting;
passwordSavingEnabled: SinonChrome.types.StubbedChromeSetting;
safeBrowsingEnabled: SinonChrome.types.StubbedChromeSetting;
searchSuggestEnabled: SinonChrome.types.StubbedChromeSetting;
spellingServiceEnabled: SinonChrome.types.StubbedChromeSetting;
translationServiceEnabled: SinonChrome.types.StubbedChromeSetting;
};
export var website: {
hyperlinkAuditingEnabled: SinonChrome.types.StubbedChromeSetting;
referrersEnabled: SinonChrome.types.StubbedChromeSetting;
thirdPartyCookiesAllowed: SinonChrome.types.StubbedChromeSetting;
};
}
declare module SinonChrome.proxy {
export var onProxyError: SinonChrome.events.Event;
export var settings: SinonChrome.types.StubbedChromeSetting;
}
declare module SinonChrome.pushMessaging {
export var getChannelId: Sinon.SinonStub;
export var onMessage: SinonChrome.events.Event;
}
declare module SinonChrome.runtime {
export var connect: Sinon.SinonStub;
export var connectNative: Sinon.SinonStub;
export var getBackgroundPage: Sinon.SinonStub;
export var getManifest: Sinon.SinonStub;
export var getPackageDirectoryEntry: Sinon.SinonStub;
export var getPlatformInfo: Sinon.SinonStub;
export var reload: Sinon.SinonStub;
export var requestUpdateCheck: Sinon.SinonStub;
export var restart: Sinon.SinonStub;
export var sendMessage: Sinon.SinonStub;
export var sendNativeMessage: Sinon.SinonStub;
export var onBrowserUpdateAvailable: SinonChrome.events.Event;
export var onConnect: SinonChrome.events.Event;
export var onConnectExternal: SinonChrome.events.Event;
export var onInstalled: SinonChrome.events.Event;
export var onMessage: SinonChrome.events.Event;
export var onMessageExternal: SinonChrome.events.Event;
export var onRestartRequired: SinonChrome.events.Event;
export var onStartup: SinonChrome.events.Event;
export var onSuspend: SinonChrome.events.Event;
export var onSuspendCanceled: SinonChrome.events.Event;
export var onUpdateAvailable: SinonChrome.events.Event;
export var id: string;
export var getURL: Sinon.SinonSpy;
export var lastError: { message?: string };
}
declare module SinonChrome.sessions {
export var getDevices: Sinon.SinonStub;
export var getRecentlyClosed: Sinon.SinonStub;
export var restore: Sinon.SinonStub;
export var onChanged: SinonChrome.events.Event;
}
declare module SinonChrome.storage {
interface StubbedStorageArea {
clear: Sinon.SinonStub;
get: Sinon.SinonStub;
getBytesInUse: Sinon.SinonStub;
remove: Sinon.SinonStub;
set: Sinon.SinonStub;
}
export var local: StubbedStorageArea;
export var managed: StubbedStorageArea;
export var sync: StubbedStorageArea;
export var onChanged: SinonChrome.events.Event;
}
declare module SinonChrome.tabCapture {
export var capture: Sinon.SinonStub;
export var getCapturedTabs: Sinon.SinonStub;
export var onStatusChanged: SinonChrome.events.Event;
}
declare module SinonChrome.tabs {
export var captureVisibleTab: Sinon.SinonStub;
export var connect: Sinon.SinonStub;
export var create: Sinon.SinonStub;
export var detectLanguage: Sinon.SinonStub;
export var duplicate: Sinon.SinonStub;
export var executeScript: Sinon.SinonStub;
export var get: Sinon.SinonStub;
export var getAllInWindow: Sinon.SinonStub;
export var getCurrent: Sinon.SinonStub;
export var getSelected: Sinon.SinonStub;
export var highlight: Sinon.SinonStub;
export var insertCSS: Sinon.SinonStub;
export var move: Sinon.SinonStub;
export var query: Sinon.SinonStub;
export var reload: Sinon.SinonStub;
export var remove: Sinon.SinonStub;
export var sendMessage: Sinon.SinonStub;
export var sendRequest: Sinon.SinonStub;
export var update: Sinon.SinonStub;
export var onActivated: SinonChrome.events.Event;
export var onActiveChanged: SinonChrome.events.Event;
export var onAttached: SinonChrome.events.Event;
export var onCreated: SinonChrome.events.Event;
export var onDetached: SinonChrome.events.Event;
export var onHighlightChanged: SinonChrome.events.Event;
export var onHighlighted: SinonChrome.events.Event;
export var onMoved: SinonChrome.events.Event;
export var onRemoved: SinonChrome.events.Event;
export var onReplaced: SinonChrome.events.Event;
export var onSelectionChanged: SinonChrome.events.Event;
export var onUpdated: SinonChrome.events.Event;
export var onZoomChange: SinonChrome.events.Event;
}
declare module SinonChrome.topSites {
export var get: Sinon.SinonStub;
}
declare module SinonChrome.tts {
export var getVoices: Sinon.SinonStub;
export var isSpeaking: Sinon.SinonStub;
export var pause: Sinon.SinonStub;
export var resume: Sinon.SinonStub;
export var speak: Sinon.SinonStub;
export var stop: Sinon.SinonStub;
export var onEvent: SinonChrome.events.Event;
}
declare module SinonChrome.ttsEngine {
export var onPause: SinonChrome.events.Event;
export var onResume: SinonChrome.events.Event;
export var onSpeak: SinonChrome.events.Event;
export var onStop: SinonChrome.events.Event;
export var sendTtsEvent: Sinon.SinonStub;
}
declare module SinonChrome.webNavigation {
export var getAllFrames: Sinon.SinonStub;
export var getFrame: Sinon.SinonStub;
export var onBeforeNavigate: SinonChrome.events.Event;
export var onCommitted: SinonChrome.events.Event;
export var onCompleted: SinonChrome.events.Event;
export var onCreatedNavigationTarget: SinonChrome.events.Event;
export var onDOMContentLoaded: SinonChrome.events.Event;
export var onErrorOccurred: SinonChrome.events.Event;
export var onHistoryStateUpdated: SinonChrome.events.Event;
export var onReferenceFragmentUpdated: SinonChrome.events.Event;
export var onTabReplaced: SinonChrome.events.Event;
}
declare module SinonChrome.webRequest {
export var handlerBehaviorChanged: Sinon.SinonStub;
export var onAuthRequired: SinonChrome.events.Event;
export var onBeforeRedirect: SinonChrome.events.Event;
export var onBeforeRequest: SinonChrome.events.Event;
export var onBeforeSendHeaders: SinonChrome.events.Event;
export var onCompleted: SinonChrome.events.Event;
export var onErrorOccurred: SinonChrome.events.Event;
export var onHeadersReceived: SinonChrome.events.Event;
export var onResponseStarted: SinonChrome.events.Event;
export var onSendHeaders: SinonChrome.events.Event;
}
declare module SinonChrome.windows {
export var create: Sinon.SinonStub;
export var get: Sinon.SinonStub;
export var getAll: Sinon.SinonStub;
export var getCurrent: Sinon.SinonStub;
export var getLastFocused: Sinon.SinonStub;
export var remove: Sinon.SinonStub;
export var update: Sinon.SinonStub;
export var onCreated: SinonChrome.events.Event;
export var onFocusChanged: SinonChrome.events.Event;
export var onRemoved: SinonChrome.events.Event;
}