-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbrowser.js
5788 lines (4768 loc) · 170 KB
/
browser.js
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
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.chrome=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
var Chrome = _dereq_('./lib/Chrome');
module.exports = new Chrome();
},{"./lib/Chrome":2}],2:[function(_dereq_,module,exports){
var ContextMenus = _dereq_('./chrome/ContextMenus');
var Runtime = _dereq_('./chrome/Runtime');
var Tabs = _dereq_('./chrome/Tabs');
var I18n = _dereq_('./chrome/I18n');
module.exports = Chrome;
/**
* @constructor
*/
function Chrome() {
this.resetMock();
}
/**
* Re-initialize all mocks
*/
Chrome.prototype.resetMock = function () {
this.contextMenus = new ContextMenus(this);
this.runtime = new Runtime(this);
this.tabs = new Tabs(this);
this.i18n = new I18n(this);
};
},{"./chrome/ContextMenus":4,"./chrome/I18n":5,"./chrome/Runtime":6,"./chrome/Tabs":7}],3:[function(_dereq_,module,exports){
var sinon = _dereq_('sinon');
module.exports = Event;
function Event() {
this.listeners = [];
this.addListener = sinon.spy(this.addListener.bind(this));
}
/**
* @property {array}
*/
Event.prototype.listeners = null;
/**
* Add an event handler function
* @param {function} fn
*/
Event.prototype.addListener = function (fn) {
this.listeners.push(fn);
};
/**
* Trigger event
* @param {...object} arg
*/
Event.prototype.trigger = function () {
var args = arguments;
this.listeners.forEach(function (fn) {
fn.apply(null, args);
});
};
},{"sinon":13}],4:[function(_dereq_,module,exports){
var Event = _dereq_('../Event');
var sinon = _dereq_('sinon');
module.exports = ContextMenus;
/**
* Use the <code>chrome.contextMenus</code> API to add items to Google Chrome's context
* menu. You can choose what types of objects your context menu additions apply to,
* such as images, hyperlinks, and pages.
* @constructor
* @param {object} chrome
*/
function ContextMenus(chrome) {
this.chrome = chrome;
/**
* The maximum number of top level extension items that can be added to an extension
* action context menu. Any items beyond this limit will be ignored.
* @property {undefined}
*/
this.ACTION_MENU_TOP_LEVEL_LIMIT = null;
/**
* Creates a new context menu item. Note that if an error occurs during creation, you
* may not find out until the creation callback fires (the details will be in chro
* me.runtime.lastError).
*
* @param {object} createProperties
* @param {function} callback Called when the item has been created in the browser. If there were any probl...
* @returns {undefined} The ID of the newly created item.
*/
this.create = sinon.spy(function (createProperties, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Updates a previously created context menu item.
*
* @param {undefined} id The ID of the item to update.
* @param {object} updateProperties The properties to update. Accepts the same values as the create function.
* @param {function} callback Called when the context menu has been updated.
*/
this.update = sinon.spy(function (id, updateProperties, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Removes a context menu item.
*
* @param {undefined} menuItemId The ID of the context menu item to remove.
* @param {function} callback Called when the context menu has been removed.
*/
this.remove = sinon.spy(function (menuItemId, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Removes all context menu items added by this extension.
*
* @param {function} callback Called when removal is complete.
*/
this.removeAll = sinon.spy(function (callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* onClicked Event
*/
this.onClicked = new Event();
}
},{"../Event":3,"sinon":13}],5:[function(_dereq_,module,exports){
(function (process){
var Event = _dereq_('../Event');
var sinon = _dereq_('sinon');
var path = _dereq_('path');
/* CONSTANTS */
// To use this library create a messages.json inside of your src folder
// by default you can see that I am using src/_locales/en/messages.json
// if you _locales directory is in a different root directory simply change below
var DEFAULT_FILENAME = path.join(process.cwd(), 'src', '_locales', 'en', 'messages.json');
//change this to your locale
var LOCALE = 'en_US';
module.exports = i18n;
/**
* Use the <code>chrome.i8n</code> to implement internationalization across your whole app or extension.
* @constructor
* @param {object} chrome
*/
function i18n (chrome) {
this.chrome = chrome;
//loads a file from your
this._locales = null;
// todo implement this method
// /**
// * Gets the accept-languages of the browser. This is different from the locale
// * used by the browser; to get the locale, use
// *
// * @param {function} callback - Array of the accept languages of the browser, such as en-US,en,zh-CN
// */
// this.getAcceptLanguages = sinon.spy(function (callback){
//
// if (typeof callback === 'function') {
// callback();
// }
//
// });
/**
* Load default locales
*/
this.loadDefaults = function () {
this._locales = _dereq_(DEFAULT_FILENAME);
};
/**
* Gets the localized string for the specified message. If the message is missing,
* this method returns an empty string (''). If the format of the getMessage() call
* is wrong — for example, messageName is not a string or the substitutions array
* has more than 9 elements — this method returns undefined.
*
* @param {integer} messageName - The name of the message, as specified in the messages.json file.
* @param {object} substitutions - Up to 9 substitution strings, if the message requires any.
* @returns {string}
*/
this.getMessage = sinon.spy(function (messageName) {
//todo implement real '@@ui_locale' method - for now hard code to onstant
if(messageName === '@@ui_locale'){
return LOCALE;
}
var message = this._locales[messageName].message;
return message;
});
// todo implement this method
// /**
// * Gets the browser UI language of the browser. This is different
// * from i18n.getAcceptLanguages which returns the preferred user languages.
// *
// * @param {integer} tabId
// * @param {object} connectInfo
// * @returns {undefined} A port that can be used to communicate with the content scripts running in th...
// */
// this.getUILanguage = sinon.spy(function (tabId, connectInfo){
//
// });
}
}).call(this,_dereq_("JkpR2F"))
},{"../Event":3,"JkpR2F":10,"path":9,"sinon":13}],6:[function(_dereq_,module,exports){
var Event = _dereq_('../Event');
var sinon = _dereq_('sinon');
module.exports = Runtime;
/**
* Use the <code>chrome.runtime</code> API to retrieve the background page, return details
* about the manifest, and listen for and respond to events in the app or extension
* lifecycle. You can also use this API to convert the relative path of URLs to fully-qualified
* URLs.
* @constructor
* @param {object} chrome
*/
function Runtime(chrome) {
this.chrome = chrome;
/**
* This will be defined during an API method callback if there was an error
* @property {object}
*/
this.lastError = null;
/**
* The ID of the extension/app.
* @property {string}
*/
this.id = 'xxxxxxx';
/**
* Retrieves the JavaScript 'window' object for the background page running inside the
* current extension/app. If the background page is an event page, the system will ensure
* it is loaded before calling the callback. If there is no background page, an error
* is set.
*
* @param {function} callback
*/
this.getBackgroundPage = sinon.spy(function (callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Returns details about the app or extension from the manifest. The object returned
* is a serialization of the full <a href="manifest.html">manifest file</a>.
*
* @returns {object} The manifest details.
*/
this.getManifest = sinon.spy(function () {
});
/**
* Converts a relative path within an app/extension install directory to a fully-qualified
* URL.
*
* @param {string} path A path to a resource within an app/extension expressed relative to its instal...
* @returns {string} The fully-qualified URL to the resource.
*/
this.getURL = sinon.spy(function () {
});
/**
* Sets the URL to be visited upon uninstallation. This may be used to clean up server-side
* data, do analytics, and implement surveys. Maximum 255 characters.
*
* @param {string} url
*/
this.setUninstallURL = sinon.spy(function () {
});
/**
* Reloads the app or extension.
*
*/
this.reload = sinon.spy(function () {
});
/**
* Requests an update check for this app/extension.
*
* @param {function} callback
*/
this.requestUpdateCheck = sinon.spy(function (callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Restart the ChromeOS device when the app runs in kiosk mode. Otherwise, it's no
* -op.
*
*/
this.restart = sinon.spy(function () {
});
/**
* Attempts to connect to connect listeners within an extension/app (such as the background
* page), or other extensions/apps. This is useful for content scripts connecting to
* their extension processes, inter-app/extension communication, and <a href="manifest/externally_connectable.html">web
* messaging</a>. Note that this does not connect to any listeners in a content script.
* Extensions may connect to content scripts embedded in tabs via <a href="extensi
* ons/tabs#method-connect">tabs.connect</a>.
*
* @param {string} extensionId The ID of the extension or app to connect to. If omitted, a connection will b...
* @param {object} connectInfo
* @returns {undefined} Port through which messages can be sent and received. The port's $(ref:runtim...
*/
this.connect = sinon.spy(function () {
});
/**
* Connects to a native application in the host machine.
*
* @param {string} application The name of the registered application to connect to.
* @returns {undefined} Port through which messages can be sent and received with the application
*/
this.connectNative = sinon.spy(function (application) {
});
/**
* Sends a single message to event listeners within your extension/app or a different
* extension/app. Similar to $(ref:runtime.connect) but only sends a single message,
* with an optional response. If sending to your extension, the $(ref:runtime.onMessage)
* event will be fired in each page, or $(ref:runtime.onMessageExternal), if a different
* extension. Note that extensions cannot send messages to content scripts using this
* method. To send messages to content scripts, use <a href="extensions/tabs#metho
* d-sendMessage">tabs.sendMessage</a>.
*
* @param {string} extensionId The ID of the extension/app to send the message to. If omitted, the message w...
* @param {any} message
* @param {object} options
* @param {function} responseCallback
*/
this.sendMessage = sinon.spy(function (extensionId, message, options, responseCallback) {
if (typeof responseCallback === 'function') {
responseCallback();
}
});
/**
* Send a single message to a native application.
*
* @param {string} application The name of the native messaging host.
* @param {object} message The message that will be passed to the native messaging host.
* @param {function} responseCallback
*/
this.sendNativeMessage = sinon.spy(function (application, message, responseCallback) {
if (typeof responseCallback === 'function') {
responseCallback();
}
});
/**
* Returns information about the current platform.
*
* @param {function} callback Called with results
*/
this.getPlatformInfo = sinon.spy(function (callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Returns a DirectoryEntry for the package directory.
*
* @param {function} callback
*/
this.getPackageDirectoryEntry = sinon.spy(function (callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Fired when a profile that has this extension installed first starts up. This event
* is not fired when an incognito profile is started, even if this extension is operating
* in 'split' incognito mode.
*/
this.onStartup = new Event();
/**
* Fired when the extension is first installed, when the extension is updated to a new
* version, and when Chrome is updated to a new version.
*/
this.onInstalled = new Event();
/**
* Sent to the event page just before it is unloaded. This gives the extension opportunity
* to do some clean up. Note that since the page is unloading, any asynchronous operations
* started while handling this event are not guaranteed to complete. If more activity
* for the event page occurs before it gets unloaded the onSuspendCanceled event will
* be sent and the page won't be unloaded.
*/
this.onSuspend = new Event();
/**
* Sent after onSuspend to indicate that the app won't be unloaded after all.
*/
this.onSuspendCanceled = new Event();
/**
* Fired when an update is available, but isn't installed immediately because the app
* is currently running. If you do nothing, the update will be installed the next time
* the background page gets unloaded, if you want it to be installed sooner you can
* explicitly call chrome.runtime.reload(). If your extension is using a persistent
* background page, the background page of course never gets unloaded, so unless you
* call chrome.runtime.reload() manually in response to this event the update will not
* get installed until the next time chrome itself restarts. If no handlers are listening
* for this event, and your extension has a persistent background page, it behaves as
* if chrome.runtime.reload() is called in response to this event.
*/
this.onUpdateAvailable = new Event();
/**
* Fired when a Chrome update is available, but isn't installed immediately because
* a browser restart is required.
*/
this.onBrowserUpdateAvailable = new Event();
/**
* Fired when a connection is made from either an extension process or a content s
* cript.
*/
this.onConnect = new Event();
/**
* Fired when a connection is made from another extension.
*/
this.onConnectExternal = new Event();
/**
* Fired when a message is sent from either an extension process or a content scri
* pt.
*/
this.onMessage = new Event();
/**
* Fired when a message is sent from another extension/app. Cannot be used in a content
* script.
*/
this.onMessageExternal = new Event();
/**
* Fired when an app or the device that it runs on needs to be restarted. The app should
* close all its windows at its earliest convenient time to let the restart to happen.
* If the app does nothing, a restart will be enforced after a 24-hour grace period
* has passed. Currently, this event is only fired for Chrome OS kiosk apps.
*/
this.onRestartRequired = new Event();
}
},{"../Event":3,"sinon":13}],7:[function(_dereq_,module,exports){
var Event = _dereq_('../Event');
var sinon = _dereq_('sinon');
module.exports = Tabs;
/**
* Use the <code>chrome.tabs</code> API to interact with the browser's tab system. You
* can use this API to create, modify, and rearrange tabs in the browser.
* @constructor
* @param {object} chrome
*/
function Tabs(chrome) {
this.chrome = chrome;
/**
* Retrieves details about the specified tab.
*
* @param {integer} tabId
* @param {function} callback
*/
this.get = sinon.spy(function (tabId, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Gets the tab that this script call is being made from. May be undefined if called
* from a non-tab context (for example: a background page or popup view).
*
* @param {function} callback
*/
this.getCurrent = sinon.spy(function (callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Connects to the content script(s) in the specified tab. The $(ref:runtime.onConnect)
* event is fired in each content script running in the specified tab for the current
* extension. For more details, see <a href='messaging'>Content Script Messaging</
* a>.
*
* @param {integer} tabId
* @param {object} connectInfo
* @returns {undefined} A port that can be used to communicate with the content scripts running in th...
*/
this.connect = sinon.spy(function (tabId) {
});
/**
* Sends a single request to the content script(s) in the specified tab, with an optional
* callback to run when a response is sent back. The $(ref:extension.onRequest) event
* is fired in each content script running in the specified tab for the current ex
* tension.
*
* @param {integer} tabId
* @param {any} request
* @param {function} responseCallback
*/
this.sendRequest = sinon.spy(function (tabId, request, responseCallback) {
if (typeof responseCallback === 'function') {
responseCallback();
}
});
/**
* Sends a single message to the content script(s) in the specified tab, with an optional
* callback to run when a response is sent back. The $(ref:runtime.onMessage) event
* is fired in each content script running in the specified tab for the current ex
* tension.
*
* @param {integer} tabId
* @param {any} message
* @param {function} responseCallback
*/
this.sendMessage = sinon.spy(function (tabId, message, responseCallback) {
if (typeof responseCallback === 'function') {
responseCallback();
}
});
/**
* Gets the tab that is selected in the specified window.
*
* @param {integer} windowId Defaults to the <a href='windows#current-window'>current window</a>.
* @param {function} callback
*/
this.getSelected = sinon.spy(function (windowId, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Gets details about all tabs in the specified window.
*
* @param {integer} windowId Defaults to the <a href='windows#current-window'>current window</a>.
* @param {function} callback
*/
this.getAllInWindow = sinon.spy(function (windowId, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Creates a new tab.
*
* @param {object} createProperties
* @param {function} callback
*/
this.create = sinon.spy(function (createProperties, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Duplicates a tab.
*
* @param {integer} tabId The ID of the tab which is to be duplicated.
* @param {function} callback
*/
this.duplicate = sinon.spy(function (tabId, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Gets all tabs that have the specified properties, or all tabs if no properties are
* specified.
*
* @param {object} queryInfo
* @param {function} callback
*/
this.query = sinon.spy(function (queryInfo, callback) {
if (typeof callback === 'function') {
callback([{id: 0}]);
}
});
/**
* Highlights the given tabs.
*
* @param {object} highlightInfo
* @param {function} callback
*/
this.highlight = sinon.spy(function (highlightInfo, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Modifies the properties of a tab. Properties that are not specified in <var>updateProperties</var>
* are not modified.
*
* @param {integer} tabId Defaults to the selected tab of the <a href='windows#current-window'>current ...
* @param {object} updateProperties
* @param {function} callback
*/
this.update = sinon.spy(function (tabId, updateProperties, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Moves one or more tabs to a new position within its window, or to a new window. Note
* that tabs can only be moved to and from normal (window.type === "normal") windo
* ws.
*
* @param {undefined} tabIds The tab or list of tabs to move.
* @param {object} moveProperties
* @param {function} callback
*/
this.move = sinon.spy(function (tabIds, moveProperties, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Reload a tab.
*
* @param {integer} tabId The ID of the tab to reload; defaults to the selected tab of the current window.
* @param {object} reloadProperties
* @param {function} callback
*/
this.reload = sinon.spy(function (tabId, reloadProperties, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Closes one or more tabs.
*
* @param {undefined} tabIds The tab or list of tabs to close.
* @param {function} callback
*/
this.remove = sinon.spy(function (tabIds, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Detects the primary language of the content in a tab.
*
* @param {integer} tabId Defaults to the active tab of the <a href='windows#current-window'>current wi...
* @param {function} callback
*/
this.detectLanguage = sinon.spy(function (tabId, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Captures the visible area of the currently active tab in the specified window. You
* must have <a href='declare_permissions'><all_urls></a> permission to use this
* method.
*
* @param {integer} windowId The target window. Defaults to the <a href='windows#current-window'>current w...
* @param {undefined} options
* @param {function} callback
*/
this.captureVisibleTab = sinon.spy(function (windowId, options, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Injects JavaScript code into a page. For details, see the <a href='content_scripts#pi'>programmatic
* injection</a> section of the content scripts doc.
*
* @param {integer} tabId The ID of the tab in which to run the script; defaults to the active tab of t...
* @param {undefined} details Details of the script to run.
* @param {function} callback Called after all the JavaScript has been executed.
*/
this.executeScript = sinon.spy(function (tabId, details, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Injects CSS into a page. For details, see the <a href='content_scripts#pi'>programmatic
* injection</a> section of the content scripts doc.
*
* @param {integer} tabId The ID of the tab in which to insert the CSS; defaults to the active tab of t...
* @param {undefined} details Details of the CSS text to insert.
* @param {function} callback Called when all the CSS has been inserted.
*/
this.insertCSS = sinon.spy(function (tabId, details, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Zooms a specified tab.
*
* @param {integer} tabId The ID of the tab to zoom; defaults to the active tab of the current window.
* @param {number} zoomFactor The new zoom factor.
* @param {function} callback Called after the zoom factor has been changed.
*/
this.setZoom = sinon.spy(function (tabId, zoomFactor, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Gets the current zoom factor of a specified tab.
*
* @param {integer} tabId The ID of the tab to get the current zoom factor from; defaults to the active...
* @param {function} callback Called with the tab's current zoom factor after it has been fetched.
*/
this.getZoom = sinon.spy(function (tabId, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Sets the zoom settings for a specified tab, which define how zoom changes are handled.
* These settings are reset to defaults upon navigating the tab.
*
* @param {integer} tabId The ID of the tab to change the zoom settings for; defaults to the active tab...
* @param {undefined} zoomSettings Defines how zoom changes are handled and at what scope.
* @param {function} callback Called after the zoom settings have been changed.
*/
this.setZoomSettings = sinon.spy(function (tabId, zoomSettings, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Gets the current zoom settings of a specified tab.
*
* @param {integer} tabId The ID of the tab to get the current zoom settings from; defaults to the acti...
* @param {function} callback Called with the tab's current zoom settings.
*/
this.getZoomSettings = sinon.spy(function (tabId, callback) {
if (typeof callback === 'function') {
callback();
}
});
/**
* Fired when a tab is created. Note that the tab's URL may not be set at the time this
* event fired, but you can listen to onUpdated events to be notified when a URL is
* set.
*/
this.onCreated = new Event();
/**
* Fired when a tab is updated.
*/
this.onUpdated = new Event();
/**
* Fired when a tab is moved within a window. Only one move event is fired, representing
* the tab the user directly moved. Move events are not fired for the other tabs that
* must move in response. This event is not fired when a tab is moved between windows.
* For that, see $(ref:tabs.onDetached).
*/
this.onMoved = new Event();
/**
* Fires when the selected tab in a window changes.
*/
this.onSelectionChanged = new Event();
/**
* Fires when the selected tab in a window changes. Note that the tab's URL may not
* be set at the time this event fired, but you can listen to $(ref:tabs.onUpdated)
* events to be notified when a URL is set.
*/
this.onActiveChanged = new Event();
/**
* Fires when the active tab in a window changes. Note that the tab's URL may not be
* set at the time this event fired, but you can listen to onUpdated events to be notified
* when a URL is set.
*/
this.onActivated = new Event();
/**
* Fired when the highlighted or selected tabs in a window changes.
*/
this.onHighlightChanged = new Event();
/**
* Fired when the highlighted or selected tabs in a window changes.
*/
this.onHighlighted = new Event();
/**
* Fired when a tab is detached from a window, for example because it is being moved
* between windows.
*/
this.onDetached = new Event();
/**
* Fired when a tab is attached to a window, for example because it was moved between
* windows.
*/
this.onAttached = new Event();
/**
* Fired when a tab is closed.
*/
this.onRemoved = new Event();
/**
* Fired when a tab is replaced with another tab due to prerendering or instant.
*/
this.onReplaced = new Event();
/**
* Fired when a tab is zoomed.
*/
this.onZoomChange = new Event();
}
},{"../Event":3,"sinon":13}],8:[function(_dereq_,module,exports){
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
};
} else {
// old school shim for old browsers
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
var TempCtor = function () {}
TempCtor.prototype = superCtor.prototype
ctor.prototype = new TempCtor()
ctor.prototype.constructor = ctor
}
}
},{}],9:[function(_dereq_,module,exports){
(function (process){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included