Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / networking_private / chromeos / test.js
blob3c8e20a63ae1dadd4ed484905330527d7201c52b
1 // Copyright (c) 2013 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 // The expectations in this test for the Chrome OS implementation. See
6 // networking_private_chromeos_apitest.cc for more info.
8 var callbackPass = chrome.test.callbackPass;
9 var callbackFail = chrome.test.callbackFail;
10 var assertTrue = chrome.test.assertTrue;
11 var assertFalse = chrome.test.assertFalse;
12 var assertEq = chrome.test.assertEq;
14 var ActivationStateType = chrome.networkingPrivate.ActivationStateType;
15 var ConnectionStateType = chrome.networkingPrivate.ConnectionStateType;
16 var NetworkType = chrome.networkingPrivate.NetworkType;
18 // Test properties for the verification API.
19 var verificationProperties = {
20   certificate: 'certificate',
21   intermediateCertificates: ['ica1', 'ica2', 'ica3'],
22   publicKey: 'cHVibGljX2tleQ==',  // Base64('public_key')
23   nonce: 'nonce',
24   signedData: 'c2lnbmVkX2RhdGE=',  // Base64('signed_data')
25   deviceSerial: 'device_serial',
26   deviceSsid: 'Device 0123',
27   deviceBssid: '00:01:02:03:04:05'
30 var privateHelpers = {
31   // Watches for the states |expectedStates| in reverse order. If all states
32   // were observed in the right order, succeeds and calls |done|. If any
33   // unexpected state is observed, fails.
34   watchForStateChanges: function(network, expectedStates, done) {
35     var self = this;
36     var collectProperties = function(properties) {
37       var finishTest = function() {
38         chrome.networkingPrivate.onNetworksChanged.removeListener(
39             self.onNetworkChange);
40         done();
41       };
42       if (expectedStates.length > 0) {
43         var expectedState = expectedStates.pop();
44         assertEq(expectedState, properties.ConnectionState);
45         if (expectedStates.length == 0)
46           finishTest();
47       }
48     };
49     this.onNetworkChange = function(changes) {
50       assertEq([network], changes);
51       chrome.networkingPrivate.getProperties(
52           network,
53           callbackPass(collectProperties));
54     };
55     chrome.networkingPrivate.onNetworksChanged.addListener(
56         this.onNetworkChange);
57   },
58   listListener: function(expected, done) {
59     var self = this;
60     this.listenForChanges = function(list) {
61       assertEq(expected, list);
62       chrome.networkingPrivate.onNetworkListChanged.removeListener(
63           self.listenForChanges);
64       done();
65     };
66   },
67   watchForCaptivePortalState: function(expectedGuid,
68                                        expectedState,
69                                        done) {
70     var self = this;
71     this.onPortalDetectionCompleted = function(guid, state) {
72       assertEq(expectedGuid, guid);
73       assertEq(expectedState, state);
74       chrome.networkingPrivate.onPortalDetectionCompleted.removeListener(
75           self.onPortalDetectionCompleted);
76       done();
77     };
78     chrome.networkingPrivate.onPortalDetectionCompleted.addListener(
79         self.onPortalDetectionCompleted);
80   }
83 var availableTests = [
84   function startConnect() {
85     chrome.networkingPrivate.startConnect('stub_wifi2_guid', callbackPass());
86   },
87   function startDisconnect() {
88     // Must connect to a network before we can disconnect from it.
89     chrome.networkingPrivate.startConnect(
90         'stub_wifi2_guid', callbackPass(function() {
91           chrome.networkingPrivate.startDisconnect('stub_wifi2_guid',
92                                                    callbackPass());
93         }));
94   },
95   function startActivate() {
96     // Must connect to a network before we can activate it.
97     chrome.networkingPrivate.startConnect(
98         'stub_cellular1_guid', callbackPass(function() {
99           chrome.networkingPrivate.startActivate(
100               'stub_cellular1_guid', callbackPass(function() {
101                 chrome.networkingPrivate.getState(
102                     'stub_cellular1_guid', callbackPass(function(state) {
103                       assertEq(ActivationStateType.ACTIVATED,
104                                state.Cellular.ActivationState);
105                     }));
106               }));
107         }));
108   },
109   function startConnectNonexistent() {
110     chrome.networkingPrivate.startConnect(
111       'nonexistent_path',
112       callbackFail('Error.InvalidNetworkGuid'));
113   },
114   function startDisconnectNonexistent() {
115     chrome.networkingPrivate.startDisconnect(
116       'nonexistent_path',
117       callbackFail('Error.InvalidNetworkGuid'));
118   },
119   function startGetPropertiesNonexistent() {
120     chrome.networkingPrivate.getProperties(
121       'nonexistent_path',
122       callbackFail('Error.InvalidNetworkGuid'));
123   },
124   function createNetwork() {
125     chrome.networkingPrivate.createNetwork(
126       false,  // shared
127       { Type: NetworkType.WI_FI,
128         GUID: 'ignored_guid',
129         WiFi: {
130           SSID: 'wifi_created',
131           Security: 'WEP-PSK'
132         }
133       },
134       callbackPass(function(guid) {
135         assertFalse(guid == '');
136         assertFalse(guid == 'ignored_guid');
137         chrome.networkingPrivate.getProperties(
138             guid, callbackPass(function(properties) {
139               assertEq(NetworkType.WI_FI, properties.Type);
140               assertEq(guid, properties.GUID);
141               assertEq('wifi_created', properties.WiFi.SSID);
142               assertEq('WEP-PSK', properties.WiFi.Security);
143             }));
144       }));
145   },
146   function forgetNetwork() {
147     var kNumNetworks = 2;
148     var kTestNetworkGuid = 'stub_wifi1_guid';
149     function guidExists(networks, guid) {
150       for (var n of networks) {
151         if (n.GUID == kTestNetworkGuid)
152           return true;
153       }
154       return false;
155     }
156     var filter = {
157       networkType: NetworkType.WI_FI,
158       visible: true,
159       configured: true
160     };
161     chrome.networkingPrivate.getNetworks(
162         filter, callbackPass(function(networks) {
163           assertEq(kNumNetworks, networks.length);
164           assertTrue(guidExists(networks, kTestNetworkGuid));
165           chrome.networkingPrivate.forgetNetwork(
166               kTestNetworkGuid, callbackPass(function() {
167                 chrome.networkingPrivate.getNetworks(
168                     filter, callbackPass(function(networks) {
169                       assertEq(kNumNetworks - 1, networks.length);
170                       assertFalse(guidExists(networks, kTestNetworkGuid));
171                     }));
172               }));
173         }));
174   },
175   function getNetworks() {
176     // Test 'type' and 'configured'.
177     var filter = {
178       networkType: NetworkType.WI_FI,
179       configured: true
180     };
181     chrome.networkingPrivate.getNetworks(
182       filter,
183       callbackPass(function(result) {
184         assertEq([{
185           Connectable: true,
186           ConnectionState: ConnectionStateType.CONNECTED,
187           GUID: 'stub_wifi1_guid',
188           Name: 'wifi1',
189           Type: NetworkType.WI_FI,
190           Source: 'User',
191           WiFi: {
192             Security: 'WEP-PSK',
193             SignalStrength: 40
194           }
195         }, {
196           GUID: 'stub_wifi2_guid',
197           Name: 'wifi2_PSK',
198           Type: NetworkType.WI_FI,
199           Source: 'User',
200           WiFi: {
201             Security: 'WPA-PSK',
202           }
203         }], result);
205         // Test 'visible' (and 'configured').
206         filter.visible = true;
207         chrome.networkingPrivate.getNetworks(
208           filter,
209           callbackPass(function(result) {
210             assertEq([{
211               Connectable: true,
212               ConnectionState: ConnectionStateType.CONNECTED,
213               GUID: 'stub_wifi1_guid',
214               Name: 'wifi1',
215               Source: 'User',
216               Type: NetworkType.WI_FI,
217               WiFi: {
218                 Security: 'WEP-PSK',
219                 SignalStrength: 40
220               }
221             }], result);
223             // Test 'limit'.
224             filter = {
225               networkType: NetworkType.ALL,
226               limit: 1
227             };
228             chrome.networkingPrivate.getNetworks(
229               filter,
230               callbackPass(function(result) {
231                 assertEq([{
232                   ConnectionState: ConnectionStateType.CONNECTED,
233                   Ethernet: {
234                     Authentication: 'None'
235                   },
236                   GUID: 'stub_ethernet_guid',
237                   Name: 'eth0',
238                   Source: 'Device',
239                   Type: NetworkType.ETHERNET
240                 }], result);
241               }));
242           }));
243       }));
244   },
245   function getVisibleNetworks() {
246     chrome.networkingPrivate.getVisibleNetworks(
247       NetworkType.ALL,
248       callbackPass(function(result) {
249         assertEq([{
250           ConnectionState: ConnectionStateType.CONNECTED,
251           Ethernet: {
252             Authentication: 'None'
253           },
254           GUID: 'stub_ethernet_guid',
255           Name: 'eth0',
256           Source: 'Device',
257           Type: NetworkType.ETHERNET
258         }, {
259           Connectable: true,
260           ConnectionState: ConnectionStateType.CONNECTED,
261           GUID: 'stub_wifi1_guid',
262           Name: 'wifi1',
263           Source: 'User',
264           Type: NetworkType.WI_FI,
265           WiFi: {
266             Security: 'WEP-PSK',
267             SignalStrength: 40
268           }
269         }, {
270           Connectable: true,
271           ConnectionState: ConnectionStateType.CONNECTED,
272           GUID: 'stub_wimax_guid',
273           Name: 'wimax',
274           Source: 'User',
275           Type: NetworkType.WI_MAX,
276           WiMAX: {
277             SignalStrength: 40
278           }
279         }, {
280           ConnectionState: ConnectionStateType.CONNECTED,
281           GUID: 'stub_vpn1_guid',
282           Name: 'vpn1',
283           Source: 'User',
284           Type: NetworkType.VPN,
285           VPN: {
286             Type: 'OpenVPN'
287           }
288         }, {
289           ConnectionState: ConnectionStateType.NOT_CONNECTED,
290           GUID: 'stub_vpn2_guid',
291           Name: 'vpn2',
292           Source: 'User',
293           Type: NetworkType.VPN,
294           VPN: {
295             ThirdPartyVPN: {
296               ExtensionID: 'third_party_provider_extension_id'
297             },
298             Type: 'ThirdPartyVPN'
299           }
300         }, {
301           Connectable: true,
302           ConnectionState: ConnectionStateType.NOT_CONNECTED,
303           GUID: 'stub_wifi2_guid',
304           Name: 'wifi2_PSK',
305           Source: 'User',
306           Type: NetworkType.WI_FI,
307           WiFi: {
308             Security: 'WPA-PSK',
309             SignalStrength: 80
310           }
311         }], result);
312       }));
313   },
314   function getVisibleNetworksWifi() {
315     chrome.networkingPrivate.getVisibleNetworks(
316       NetworkType.WI_FI,
317       callbackPass(function(result) {
318         assertEq([{
319           Connectable: true,
320           ConnectionState: ConnectionStateType.CONNECTED,
321           GUID: 'stub_wifi1_guid',
322           Name: 'wifi1',
323           Source: 'User',
324           Type: NetworkType.WI_FI,
325           WiFi: {
326             Security: 'WEP-PSK',
327             SignalStrength: 40
328           }
329         }, {
330           Connectable: true,
331           ConnectionState: ConnectionStateType.NOT_CONNECTED,
332           GUID: 'stub_wifi2_guid',
333           Name: 'wifi2_PSK',
334           Source: 'User',
335           Type: NetworkType.WI_FI,
336           WiFi: {
337             Security: 'WPA-PSK',
338             SignalStrength: 80
339           }
340         }], result);
341       }));
342   },
343   function enabledNetworkTypes() {
344     // Note: We call getEnabledNetworkTypes twice after each enable/dsiable
345     // to ensure that Chrome has processed the command (since enable/disable
346     // are 'synchronous' even though the action of enabling/disabling is not).
347     chrome.networkingPrivate.getEnabledNetworkTypes(function(types) {
348       assertTrue(types.indexOf('WiFi') >= 0);
349       chrome.networkingPrivate.disableNetworkType('WiFi');
350       chrome.networkingPrivate.getEnabledNetworkTypes(function(types) {
351         chrome.networkingPrivate.getEnabledNetworkTypes(function(types) {
352           assertFalse(types.indexOf('WiFi') >= 0);
353           chrome.networkingPrivate.enableNetworkType('WiFi');
354           chrome.networkingPrivate.getEnabledNetworkTypes(function(types) {
355             chrome.networkingPrivate.getEnabledNetworkTypes(
356               callbackPass(function(types) {
357                 assertTrue(types.indexOf('WiFi') >= 0);
358               }));
359           });
360         });
361       });
362     });
363   },
364   function getDeviceStates() {
365     chrome.networkingPrivate.getDeviceStates(callbackPass(function(result) {
366       assertEq([
367         {Scanning: false, State: 'Enabled', Type: 'Ethernet'},
368         {Scanning: false, State: 'Enabled', Type: 'WiFi'},
369         {State: 'Uninitialized', Type: 'Cellular'},
370         {State: 'Disabled', Type: 'WiMAX'},
371       ],
372                result);
373     }));
374   },
375   function requestNetworkScan() {
376     // Connected or Connecting networks should be listed first, sorted by type.
377     var expected = ['stub_ethernet_guid',
378                     'stub_wifi1_guid',
379                     'stub_wimax_guid',
380                     'stub_vpn1_guid',
381                     'stub_vpn2_guid',
382                     'stub_wifi2_guid'];
383     var done = chrome.test.callbackAdded();
384     var listener = new privateHelpers.listListener(expected, done);
385     chrome.networkingPrivate.onNetworkListChanged.addListener(
386       listener.listenForChanges);
387     chrome.networkingPrivate.requestNetworkScan();
388   },
389   function getProperties() {
390     chrome.networkingPrivate.getProperties(
391       'stub_wifi1_guid',
392       callbackPass(function(result) {
393         assertEq({
394           Connectable: true,
395           ConnectionState: ConnectionStateType.CONNECTED,
396           GUID: 'stub_wifi1_guid',
397           IPAddressConfigType: chrome.networkingPrivate.IPConfigType.STATIC,
398           IPConfigs: [{
399             Gateway: '0.0.0.1',
400             IPAddress: '0.0.0.0',
401             RoutingPrefix: 0,
402             Type: 'IPv4'
403           }],
404           MacAddress: '00:11:22:AA:BB:CC',
405           Name: 'wifi1',
406           StaticIPConfig: {
407             IPAddress: '1.2.3.4',
408             Type: 'IPv4'
409           },
410           Type: NetworkType.WI_FI,
411           WiFi: {
412             HexSSID: '7769666931', // 'wifi1'
413             Frequency: 2400,
414             FrequencyList: [2400],
415             SSID: 'wifi1',
416             Security: 'WEP-PSK',
417             SignalStrength: 40
418           }
419         }, result);
420       }));
421   },
422   function getPropertiesCellular() {
423     chrome.networkingPrivate.getProperties(
424       'stub_cellular1_guid',
425       callbackPass(function(result) {
426         assertEq({
427           Cellular: {
428             ActivationState: ActivationStateType.NOT_ACTIVATED,
429             AllowRoaming: false,
430             AutoConnect: true,
431             Carrier: 'Cellular1_Carrier',
432             HomeProvider: {
433               Country: 'us',
434               Name: 'Cellular1_Provider'
435             },
436             NetworkTechnology: 'GSM',
437             RoamingState: 'Home'
438           },
439           ConnectionState: ConnectionStateType.NOT_CONNECTED,
440           GUID: 'stub_cellular1_guid',
441           Name: 'cellular1',
442           Type: NetworkType.CELLULAR,
443         }, result);
444       }));
445   },
446   function getManagedProperties() {
447     chrome.networkingPrivate.getManagedProperties(
448       'stub_wifi2',
449       callbackPass(function(result) {
450         assertEq({
451           Connectable: true,
452           ConnectionState: ConnectionStateType.NOT_CONNECTED,
453           GUID: 'stub_wifi2',
454           Name: {
455             Active: 'wifi2_PSK',
456             Effective: 'UserPolicy',
457             UserPolicy: 'My WiFi Network'
458           },
459           Source: 'UserPolicy',
460           Type: {
461             Active: NetworkType.WI_FI,
462             Effective: 'UserPolicy',
463             UserPolicy: NetworkType.WI_FI
464           },
465           WiFi: {
466             AutoConnect: {
467               Active: false,
468               UserEditable: true
469             },
470             HexSSID: {
471               Active: '77696669325F50534B', // 'wifi2_PSK'
472               Effective: 'UserPolicy',
473               UserPolicy: '77696669325F50534B'
474             },
475             Frequency: 5000,
476             FrequencyList: [2400, 5000],
477             Passphrase: {
478               Effective: 'UserSetting',
479               UserEditable: true,
480               UserSetting: 'FAKE_CREDENTIAL_VPaJDV9x'
481             },
482             SSID: {
483               Active: 'wifi2_PSK',
484               Effective: 'UserPolicy',
485             },
486             Security: {
487               Active: 'WPA-PSK',
488               Effective: 'UserPolicy',
489               UserPolicy: 'WPA-PSK'
490             },
491             SignalStrength: 80,
492           }
493         }, result);
494       }));
495   },
496   function setCellularProperties() {
497     var network_guid = 'stub_cellular1_guid';
498     // Make sure we test Cellular.Carrier since it requires a special call
499     // to Shill.Device.SetCarrier.
500     var newCarrier = 'new_carrier';
501     chrome.networkingPrivate.getProperties(
502         network_guid,
503         callbackPass(function(result) {
504           assertEq(network_guid, result.GUID);
505           assertTrue(!result.Cellular || result.Cellular.Carrier != newCarrier);
506           var new_properties = {
507             Priority: 1,
508             Cellular: {
509               Carrier: newCarrier,
510             },
511           };
512           chrome.networkingPrivate.setProperties(
513               network_guid,
514               new_properties,
515               callbackPass(function() {
516                 chrome.networkingPrivate.getProperties(
517                     network_guid,
518                     callbackPass(function(result) {
519                       // Ensure that the GUID doesn't change.
520                       assertEq(network_guid, result.GUID);
521                       // Ensure that the properties were set.
522                       assertEq(1, result['Priority']);
523                       assertTrue('Cellular' in result);
524                       assertEq(newCarrier, result.Cellular.Carrier);
525                     }));
526               }));
527         }));
528   },
529   function setWiFiProperties() {
530     var network_guid = 'stub_wifi1_guid';
531     chrome.networkingPrivate.getProperties(
532         network_guid,
533         callbackPass(function(result) {
534           assertEq(network_guid, result.GUID);
535           var new_properties = {
536             Priority: 1,
537             WiFi: {
538               AutoConnect: true
539             },
540             IPAddressConfigType: 'Static',
541             StaticIPConfig: {
542               IPAddress: '1.2.3.4'
543             }
544           };
545           chrome.networkingPrivate.setProperties(
546               network_guid,
547               new_properties,
548               callbackPass(function() {
549                 chrome.networkingPrivate.getProperties(
550                     network_guid,
551                     callbackPass(function(result) {
552                       // Ensure that the GUID doesn't change.
553                       assertEq(network_guid, result.GUID);
554                       // Ensure that the properties were set.
555                       assertEq(1, result['Priority']);
556                       assertTrue('WiFi' in result);
557                       assertTrue('AutoConnect' in result['WiFi']);
558                       assertEq(true, result['WiFi']['AutoConnect']);
559                       assertTrue('StaticIPConfig' in result);
560                       assertEq('1.2.3.4',
561                                result['StaticIPConfig']['IPAddress']);
562                     }));
563               }));
564         }));
565   },
566   function setVPNProperties() {
567     var network_guid = 'stub_vpn1_guid';
568     chrome.networkingPrivate.getProperties(
569         network_guid,
570         callbackPass(function(result) {
571           assertEq(network_guid, result.GUID);
572           var new_properties = {
573             Priority: 1,
574             VPN: {
575               Host: 'vpn.host1'
576             }
577           };
578           chrome.networkingPrivate.setProperties(
579               network_guid,
580               new_properties,
581               callbackPass(function() {
582                 chrome.networkingPrivate.getProperties(
583                     network_guid,
584                     callbackPass(function(result) {
585                       // Ensure that the properties were set.
586                       assertEq(1, result['Priority']);
587                       assertTrue('VPN' in result);
588                       assertTrue('Host' in result['VPN']);
589                       assertEq('vpn.host1', result['VPN']['Host']);
590                       // Ensure that the GUID doesn't change.
591                       assertEq(network_guid, result.GUID);
592                     }));
593               }));
594         }));
595   },
596   function getState() {
597     chrome.networkingPrivate.getState(
598       'stub_wifi2_guid',
599       callbackPass(function(result) {
600         assertEq({
601           Connectable: true,
602           ConnectionState: ConnectionStateType.NOT_CONNECTED,
603           GUID: 'stub_wifi2_guid',
604           Name: 'wifi2_PSK',
605           Source: 'User',
606           Type: NetworkType.WI_FI,
607           WiFi: {
608             Security: 'WPA-PSK',
609             SignalStrength: 80
610           }
611         }, result);
612       }));
613   },
614   function getStateNonExistent() {
615     chrome.networkingPrivate.getState(
616       'non_existent',
617       callbackFail('Error.InvalidNetworkGuid'));
618   },
619   function getErrorState() {
620     // Both getState and getProperties should have ErrorState set.
621     chrome.networkingPrivate.getState(
622       'stub_wifi1_guid',
623       function(result) {
624         assertEq('TestErrorState', result.ErrorState);
625         chrome.networkingPrivate.getProperties(
626           'stub_wifi1_guid',
627           callbackPass(function(result2) {
628             assertEq('TestErrorState', result2.ErrorState);
629           }));
630       });
631   },
632   function onNetworksChangedEventConnect() {
633     var network = 'stub_wifi2_guid';
634     var done = chrome.test.callbackAdded();
635     var expectedStates = [ConnectionStateType.CONNECTED];
636     var listener =
637         new privateHelpers.watchForStateChanges(network, expectedStates, done);
638     chrome.networkingPrivate.startConnect(network, callbackPass());
639   },
640   function onNetworksChangedEventDisconnect() {
641     var network = 'stub_wifi1_guid';
642     var done = chrome.test.callbackAdded();
643     var expectedStates = [ConnectionStateType.NOT_CONNECTED];
644     var listener =
645         new privateHelpers.watchForStateChanges(network, expectedStates, done);
646     chrome.networkingPrivate.startDisconnect(network, callbackPass());
647   },
648   function onNetworkListChangedEvent() {
649     // Connecting to wifi2 should set wifi1 to offline. Connected or Connecting
650     // networks should be listed first, sorted by type.
651     var expected = ['stub_ethernet_guid',
652                     'stub_wifi2_guid',
653                     'stub_wimax_guid',
654                     'stub_vpn1_guid',
655                     'stub_wifi1_guid',
656                     'stub_vpn2_guid'];
657     var done = chrome.test.callbackAdded();
658     var listener = new privateHelpers.listListener(expected, done);
659     chrome.networkingPrivate.onNetworkListChanged.addListener(
660       listener.listenForChanges);
661     var network = 'stub_wifi2_guid';
662     chrome.networkingPrivate.startConnect(network, callbackPass());
663   },
664   function onDeviceStateListChangedEvent() {
665     var listener = callbackPass(function() {
666       chrome.networkingPrivate.onDeviceStateListChanged.removeListener(
667           listener);
668     });
669     chrome.networkingPrivate.onDeviceStateListChanged.addListener(listener);
670     chrome.networkingPrivate.disableNetworkType('WiFi');
671   },
672   function verifyDestination() {
673     chrome.networkingPrivate.verifyDestination(
674       verificationProperties,
675       callbackPass(function(isValid) {
676         assertTrue(isValid);
677       }));
678   },
679   function verifyAndEncryptCredentials() {
680     var network_guid = 'stub_wifi2_guid';
681     chrome.networkingPrivate.verifyAndEncryptCredentials(
682       verificationProperties,
683       network_guid,
684       callbackPass(function(result) {
685         assertEq('encrypted_credentials', result);
686       }));
687   },
688   function verifyAndEncryptData() {
689     chrome.networkingPrivate.verifyAndEncryptData(
690       verificationProperties,
691       'data',
692       callbackPass(function(result) {
693         assertEq('encrypted_data', result);
694       }));
695   },
696   function setWifiTDLSEnabledState() {
697     chrome.networkingPrivate.setWifiTDLSEnabledState(
698         'aa:bb:cc:dd:ee:ff', true, callbackPass(function(result) {
699           assertEq(ConnectionStateType.CONNECTED, result);
700         }));
701   },
702   function getWifiTDLSStatus() {
703     chrome.networkingPrivate.getWifiTDLSStatus(
704         'aa:bb:cc:dd:ee:ff', callbackPass(function(result) {
705           assertEq(ConnectionStateType.CONNECTED, result);
706         }));
707   },
708   function getCaptivePortalStatus() {
709     var networks = [['stub_ethernet_guid', 'Online'],
710                     ['stub_wifi1_guid', 'Offline'],
711                     ['stub_wifi2_guid', 'Portal'],
712                     ['stub_cellular1_guid', 'ProxyAuthRequired'],
713                     ['stub_vpn1_guid', 'Unknown']];
714     networks.forEach(function(network) {
715       var guid = network[0];
716       var expectedStatus = network[1];
717       chrome.networkingPrivate.getCaptivePortalStatus(
718         guid,
719         callbackPass(function(status) {
720           assertEq(expectedStatus, status);
721         }));
722     });
723   },
724   function captivePortalNotification() {
725     var done = chrome.test.callbackAdded();
726     var listener =
727         new privateHelpers.watchForCaptivePortalState(
728             'wifi_guid', 'Online', done);
729     chrome.test.sendMessage('notifyPortalDetectorObservers');
730   },
733 var testToRun = window.location.search.substring(1);
734 chrome.test.runTests(availableTests.filter(function(op) {
735   return op.name == testToRun;
736 }));