merge b2g-inbound to mozilla-central

This commit is contained in:
Carsten "Tomcat" Book 2014-06-02 15:20:05 +02:00
Родитель 46de95bc78 c3a9ea7a1f
Коммит fe24d28125
26 изменённых файлов: 1011 добавлений и 46 удалений

Просмотреть файл

@ -1063,6 +1063,7 @@ var CaptivePortalLoginHelper = {
init: function init() {
Services.obs.addObserver(this, 'captive-portal-login', false);
Services.obs.addObserver(this, 'captive-portal-login-abort', false);
Services.obs.addObserver(this, 'captive-portal-login-success', false);
},
handleEvent: function handleEvent(detail) {
Services.captivePortalDetector.cancelLogin(detail.id);

Просмотреть файл

@ -19,13 +19,13 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e98fe1e94d3d80ad36903500d8ca3333904b162c"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="82679a5ce84d1b6bf388da6536d5682a3ad56de3"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="531cf670e485649c69746e46d567929fcd54cbc5"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="8e4420c0c5c8e8c8e58a000278a7129403769f96"/>
<project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="9100fa82fc355f5201e23e400fc6b40e875304ed"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="41e7db9834c5ed99ed448074dce2b7331cf19c9f"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="c629a8c1e0101d3937ceb4c52a60f7569b9d4243"/>
<!-- Stock Android things -->
<project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
<project name="platform/bionic" path="bionic" revision="c72b8f6359de7ed17c11ddc9dfdde3f615d188a9"/>

Просмотреть файл

@ -17,10 +17,10 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="e98fe1e94d3d80ad36903500d8ca3333904b162c"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="82679a5ce84d1b6bf388da6536d5682a3ad56de3"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="531cf670e485649c69746e46d567929fcd54cbc5"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="41e7db9834c5ed99ed448074dce2b7331cf19c9f"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="c629a8c1e0101d3937ceb4c52a60f7569b9d4243"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
<!-- Stock Android things -->

Просмотреть файл

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="276ce45e78b09c4a4ee643646f691d22804754c1">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="e98fe1e94d3d80ad36903500d8ca3333904b162c"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="82679a5ce84d1b6bf388da6536d5682a3ad56de3"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="531cf670e485649c69746e46d567929fcd54cbc5"/>
<project name="librecovery" patch="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
@ -23,7 +23,7 @@
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="41e7db9834c5ed99ed448074dce2b7331cf19c9f"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="c629a8c1e0101d3937ceb4c52a60f7569b9d4243"/>
<!-- Stock Android things -->
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="f92a936f2aa97526d4593386754bdbf02db07a12"/>
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="6e47ff2790f5656b5b074407829ceecf3e6188c4"/>

Просмотреть файл

@ -19,13 +19,13 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e98fe1e94d3d80ad36903500d8ca3333904b162c"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="82679a5ce84d1b6bf388da6536d5682a3ad56de3"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="531cf670e485649c69746e46d567929fcd54cbc5"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="8e4420c0c5c8e8c8e58a000278a7129403769f96"/>
<project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="9100fa82fc355f5201e23e400fc6b40e875304ed"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="41e7db9834c5ed99ed448074dce2b7331cf19c9f"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="c629a8c1e0101d3937ceb4c52a60f7569b9d4243"/>
<!-- Stock Android things -->
<project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
<project name="platform/bionic" path="bionic" revision="c72b8f6359de7ed17c11ddc9dfdde3f615d188a9"/>

Просмотреть файл

@ -17,10 +17,10 @@
</project>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="e98fe1e94d3d80ad36903500d8ca3333904b162c"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="82679a5ce84d1b6bf388da6536d5682a3ad56de3"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="531cf670e485649c69746e46d567929fcd54cbc5"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="41e7db9834c5ed99ed448074dce2b7331cf19c9f"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="c629a8c1e0101d3937ceb4c52a60f7569b9d4243"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
<!-- Stock Android things -->
@ -118,7 +118,7 @@
<!-- Flame specific things -->
<project name="device/generic/armv7-a-neon" path="device/generic/armv7-a-neon" revision="e8a318f7690092e639ba88891606f4183e846d3f"/>
<project name="device/qcom/common" path="device/qcom/common" revision="34ed8345250bb97262d70a052217a92e83444ede"/>
<project name="device-flame" path="device/t2m/flame" remote="b2g" revision="218bcff6200f9b9e054467da963b7209e43ad287"/>
<project name="device-flame" path="device/t2m/flame" remote="b2g" revision="76f960b9512ec5c4726b5f52dd94bdf3c07e5071"/>
<project name="kernel/msm" path="kernel" revision="228d59147ff524e90774c566eef03260cc6857b8"/>
<project name="platform/bootable/recovery" path="bootable/recovery" revision="f2914eacee9120680a41463708bb6ee8291749fc"/>
<project name="platform/external/bluetooth/bluedroid" path="external/bluetooth/bluedroid" revision="81c4a859d75d413ad688067829d21b7ba9205f81"/>

Просмотреть файл

@ -4,6 +4,6 @@
"remote": "",
"branch": ""
},
"revision": "46fb0be835267316bda52a12dedab53978456833",
"revision": "01ae06e7d0c3c72d51e6801986339d6c06229c9b",
"repo_path": "/integration/gaia-central"
}

Просмотреть файл

@ -17,12 +17,12 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e98fe1e94d3d80ad36903500d8ca3333904b162c"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="82679a5ce84d1b6bf388da6536d5682a3ad56de3"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="531cf670e485649c69746e46d567929fcd54cbc5"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="41e7db9834c5ed99ed448074dce2b7331cf19c9f"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="c629a8c1e0101d3937ceb4c52a60f7569b9d4243"/>
<!-- Stock Android things -->
<project name="platform/abi/cpp" path="abi/cpp" revision="6426040f1be4a844082c9769171ce7f5341a5528"/>
<project name="platform/bionic" path="bionic" revision="d2eb6c7b6e1bc7643c17df2d9d9bcb1704d0b9ab"/>

Просмотреть файл

@ -15,7 +15,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e98fe1e94d3d80ad36903500d8ca3333904b162c"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="82679a5ce84d1b6bf388da6536d5682a3ad56de3"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="531cf670e485649c69746e46d567929fcd54cbc5"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>

Просмотреть файл

@ -17,10 +17,10 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="e98fe1e94d3d80ad36903500d8ca3333904b162c"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="82679a5ce84d1b6bf388da6536d5682a3ad56de3"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="531cf670e485649c69746e46d567929fcd54cbc5"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="41e7db9834c5ed99ed448074dce2b7331cf19c9f"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="c629a8c1e0101d3937ceb4c52a60f7569b9d4243"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
<!-- Stock Android things -->

Просмотреть файл

@ -17,12 +17,12 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e98fe1e94d3d80ad36903500d8ca3333904b162c"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="82679a5ce84d1b6bf388da6536d5682a3ad56de3"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="531cf670e485649c69746e46d567929fcd54cbc5"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="ce95d372e6d285725b96490afdaaf489ad8f9ca9"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="41e7db9834c5ed99ed448074dce2b7331cf19c9f"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="c629a8c1e0101d3937ceb4c52a60f7569b9d4243"/>
<project name="gonk-patches" path="patches" remote="b2g" revision="223a2421006e8f5da33f516f6891c87cae86b0f6"/>
<!-- Stock Android things -->
<project name="platform/abi/cpp" path="abi/cpp" revision="6426040f1be4a844082c9769171ce7f5341a5528"/>

Просмотреть файл

@ -1176,10 +1176,23 @@ ContentParent::ShutDownProcess(bool aCloseWithError)
// shut down the cycle collector. But by then it's too late to release any
// CC'ed objects, so we need to null them out here, while we still can. See
// bug 899761.
if (mMessageManager) {
mMessageManager->Disconnect();
mMessageManager = nullptr;
}
ShutDownMessageManager();
}
void
ContentParent::ShutDownMessageManager()
{
if (!mMessageManager) {
return;
}
mMessageManager->ReceiveMessage(
static_cast<nsIContentFrameMessageManager*>(mMessageManager.get()),
CHILD_PROCESS_SHUTDOWN_MESSAGE, false,
nullptr, nullptr, nullptr, nullptr);
mMessageManager->Disconnect();
mMessageManager = nullptr;
}
void
@ -1305,12 +1318,8 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
mForceKillTask = nullptr;
}
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
if (ppm) {
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()),
CHILD_PROCESS_SHUTDOWN_MESSAGE, false,
nullptr, nullptr, nullptr, nullptr);
}
ShutDownMessageManager();
nsRefPtr<ContentParent> kungFuDeathGrip(this);
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
@ -1321,10 +1330,6 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
}
}
if (ppm) {
ppm->Disconnect();
}
// Tell the memory reporter manager that this ContentParent is going away.
nsRefPtr<nsMemoryReporterManager> mgr =
nsMemoryReporterManager::GetOrCreate();

Просмотреть файл

@ -334,6 +334,10 @@ private:
*/
void ShutDownProcess(bool aCloseWithError);
// Perform any steps necesssary to gracefully shtudown the message
// manager and null out mMessageManager.
void ShutDownMessageManager();
PCompositorParent*
AllocPCompositorParent(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherProcess) MOZ_OVERRIDE;

Просмотреть файл

@ -56,6 +56,9 @@ this.SystemMessagePermissionsTable = {
"bluetooth": []
},
"connection": { },
"captive-portal": {
"wifi-manage": []
},
"dummy-system-message": { }, // for system message testing framework
"headset-button": { },
"icc-stkcommand": {

Просмотреть файл

@ -45,7 +45,7 @@ function onFailure() {
let mozSettings = window.navigator.mozSettings;
let req;
let storedBlob = new Blob([""], {"type": "text/xml"});
let storedBlob = new Blob(['12345'], {"type": "text/plain"});
function checkBlob(blob) {
try {

Просмотреть файл

@ -0,0 +1,731 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
let Promise = SpecialPowers.Cu.import('resource://gre/modules/Promise.jsm').Promise;
const STOCK_HOSTAPD_NAME = 'goldfish-hostapd';
const HOSTAPD_CONFIG_PATH = '/data/misc/wifi/hostapd/';
const HOSTAPD_COMMON_CONFIG = {
driver: 'test',
ctrl_interface: '/data/misc/wifi/hostapd',
test_socket: 'DIR:/data/misc/wifi/sockets',
hw_mode: 'b',
channel: '2',
};
const HOSTAPD_CONFIG_LIST = [
{ ssid: 'ap0' },
{ ssid: 'ap1',
wpa: 1,
wpa_pairwise: 'TKIP CCMP',
wpa_passphrase: '12345678'
},
{ ssid: 'ap2',
wpa: 2,
rsn_pairwise: 'CCMP',
wpa_passphrase: '12345678',
},
];
let gTestSuite = (function() {
let suite = {};
// Private member variables of the returned object |suite|.
let wifiManager;
let wifiOrigEnabled;
let pendingEmulatorShellCount = 0;
/**
* Send emulator shell command with safe guard.
*
* We should only call |finish()| after all emulator command transactions
* end, so here comes with the pending counter. Resolve when the emulator
* gives positive response, and reject otherwise.
*
* Fulfill params:
* result -- an array of emulator response lines.
* Reject params:
* result -- an array of emulator response lines.
*
* @param aCommand
* A string command to be passed to emulator through its telnet console.
*
* @return A deferred promise.
*/
function runEmulatorShellSafe(aCommand) {
let deferred = Promise.defer();
++pendingEmulatorShellCount;
runEmulatorShell(aCommand, function(aResult) {
--pendingEmulatorShellCount;
ok(true, "Emulator shell response: " + JSON.stringify(aResult));
if (Array.isArray(aResult)) {
deferred.resolve(aResult);
} else {
deferred.reject(aResult);
}
});
return deferred.promise;
}
/**
* Wait for one named MozWifiManager event.
*
* Resolve if that named event occurs. Never reject.
*
* Fulfill params: the DOMEvent passed.
*
* @param aEventName
* A string event name.
*
* @return A deferred promise.
*/
function waitForWifiManagerEventOnce(aEventName) {
let deferred = Promise.defer();
wifiManager.addEventListener(aEventName, function onevent(aEvent) {
wifiManager.removeEventListener(aEventName, onevent);
ok(true, "WifiManager event '" + aEventName + "' got.");
deferred.resolve(aEvent);
});
return deferred.promise;
}
/**
* Get the detail of currently running processes containing the given name.
*
* Use shell command 'ps' to get the desired process's detail. Never reject.
*
* Fulfill params:
* result -- an array of { pname, pid }
*
* @param aProcessName
* The process to get the detail.
*
* @return A deferred promise.
*/
function getProcessDetail(aProcessName) {
return runEmulatorShellSafe(['ps'])
.then(processes => {
// Sample 'ps' output:
//
// USER PID PPID VSIZE RSS WCHAN PC NAME
// root 1 0 284 204 c009e6c4 0000deb4 S /init
// root 2 0 0 0 c0052c64 00000000 S kthreadd
// root 3 2 0 0 c0044978 00000000 S ksoftirqd/0
//
let detail = [];
processes.shift(); // Skip the first line.
for (let i = 0; i < processes.length; i++) {
let tokens = processes[i].split(/\s+/);
let pname = tokens[tokens.length - 1];
let pid = tokens[1];
if (-1 !== pname.indexOf(aProcessName)) {
detail.push({ pname: pname, pid: pid });
}
}
return detail;
});
}
/**
* Add required permissions for wifi testing. Never reject.
*
* The permissions required for wifi testing are 'wifi-manage' and 'settings-write'.
* Never reject.
*
* Fulfill params: (none)
*
* @return A deferred promise.
*/
function addRequiredPermissions() {
let deferred = Promise.defer();
let permissions = [{ 'type': 'wifi-manage', 'allow': 1, 'context': window.document },
{ 'type': 'settings-write', 'allow': 1, 'context': window.document }];
SpecialPowers.pushPermissions(permissions, function() {
deferred.resolve();
});
return deferred.promise;
}
/**
* Wrap DOMRequest onsuccess/onerror events to Promise resolve/reject.
*
* Fulfill params: A DOMEvent.
* Reject params: A DOMEvent.
*
* @param aRequest
* A DOMRequest instance.
*
* @return A deferred promise.
*/
function wrapDomRequestAsPromise(aRequest) {
let deferred = Promise.defer();
ok(aRequest instanceof DOMRequest,
"aRequest is instanceof " + aRequest.constructor);
aRequest.addEventListener("success", function(aEvent) {
deferred.resolve(aEvent);
});
aRequest.addEventListener("error", function(aEvent) {
deferred.reject(aEvent);
});
return deferred.promise;
}
/**
* Ensure wifi is enabled/disabled.
*
* Issue a wifi enable/disable request if wifi is not in the desired state;
* return a resolved promise otherwise. Note that you cannot rely on this
* function to test the correctness of enabling/disabling wifi.
* (use requestWifiEnabled instead)
*
* Fulfill params: (none)
* Reject params: (none)
*
* @return a resolved promise or deferred promise.
*/
function ensureWifiEnabled(aEnabled) {
if (wifiManager.enabled === aEnabled) {
log('Already ' + (aEnabled ? 'enabled' : 'disabled'));
return Promise.resolve();
}
return requestWifiEnabled(aEnabled);
}
/**
* Issue a request to enable/disable wifi.
*
* For current design, this function will attempt to enable/disable wifi by
* writing 'wifi.enabled' regardless of the wifi state.
*
* Fulfill params: (none)
* Reject params: (none)
*
* @return A deferred promise.
*/
function requestWifiEnabled(aEnabled) {
return Promise.all([
waitForWifiManagerEventOnce(aEnabled ? 'enabled' : 'disabled'),
setSettings({ 'wifi.enabled': aEnabled }),
]);
}
/**
* Issue a request to scan all wifi available networks.
*
* Resolve when we get the scan result; reject when any error
* occurs.
*
* Fulfill params: An array of MozWifiNetwork
* Reject params: (none)
*
* @return A deferred promise.
*/
function requestWifiScan() {
let request = wifiManager.getNetworks();
return wrapDomRequestAsPromise(request)
.then(event => event.target.result);
}
/**
* Request wifi scan and verify the scan result as well.
*
* Issue a wifi scan request and check if the result is expected.
* Since the old APs may be cached and the newly added APs may be
* still not scan-able, a couple of attempts are acceptable.
* Resolve if we eventually get the expected scan result; reject otherwise.
*
* Fulfill params: The scan result, which is an array of MozWifiNetwork
* Reject params: (none)
*
* @param aRetryCnt
* The maxmimum number of attempts until we get the expected scan result.
* @param aExpectedNetworks
* An array of object, each of which contains at least the |ssid| property.
*
* @return A deferred promise.
*/
function testWifiScanWithRetry(aRetryCnt, aExpectedNetworks) {
// Check if every single ssid of each |aScanResult| exists in |aExpectedNetworks|
// as well as the length of |aScanResult| equals to |aExpectedNetworks|.
function isScanResultExpected(aScanResult) {
if (aScanResult.length !== aExpectedNetworks.length) {
return false;
}
for (let i = 0; i < aScanResult.length; i++) {
if (-1 === getFirstIndexBySsid(aScanResult[i].ssid, aExpectedNetworks)) {
return false;
}
}
return true;
}
return requestWifiScan()
.then(function (networks) {
if (isScanResultExpected(networks, aExpectedNetworks)) {
return networks;
}
if (aRetryCnt > 0) {
return testWifiScanWithRetry(aRetryCnt - 1, aExpectedNetworks);
}
throw 'Unexpected scan result!';
});
}
/**
* Set mozSettings values.
*
* Resolve if that mozSettings value is set successfully, reject otherwise.
*
* Fulfill params: (none)
* Reject params: (none)
*
* @param aSettings
* An object of format |{key1: value1, key2: value2, ...}|.
* @param aAllowError [optional]
* A boolean value. If set to true, an error response won't be treated
* as test failure. Default: false.
*
* @return A deferred promise.
*/
function setSettings(aSettings, aAllowError) {
let request = window.navigator.mozSettings.createLock().set(aSettings);
return wrapDomRequestAsPromise(request)
.then(function resolve() {
ok(true, "setSettings(" + JSON.stringify(aSettings) + ")");
}, function reject() {
ok(aAllowError, "setSettings(" + JSON.stringify(aSettings) + ")");
});
}
/**
* Start hostapd processes with given configuration list.
*
* For starting one hostapd, we need to generate a specific config file
* then launch a hostapd process with the confg file path passed. The
* config file is generated by two sources: one is the common
* part (HOSTAPD_COMMON_CONFIG) and the other is from the given |aConfigList|.
* Resolve when all the hostpads are requested to start. It is not guaranteed
* that all the hostapds will be up and running successfully. Never reject.
*
* Fulfill params: (none)
*
* @param aConfigList
* An array of config objects, each property in which will be
* output to the confg file with the format: [key]=[value] in one line.
* See http://hostap.epitest.fi/cgit/hostap/plain/hostapd/hostapd.conf
* for more information.
*
* @return A deferred promise.
*/
function startHostapds(aConfigList) {
function createConfigFromCommon(aIndex) {
// Create an copy of HOSTAPD_COMMON_CONFIG.
let config = JSON.parse(JSON.stringify(HOSTAPD_COMMON_CONFIG));
// Add user config.
for (let key in aConfigList[aIndex]) {
config[key] = aConfigList[aIndex][key];
}
// 'interface' is a required field but no need of being configurable
// for a test case. So we initialize this field on our own.
config.interface = 'AP-' + aIndex;
return config;
}
function startOneHostapd(aIndex) {
let configFileName = HOSTAPD_CONFIG_PATH + 'ap' + aIndex + '.conf';
return writeHostapdConfFile(configFileName, createConfigFromCommon(aIndex))
.then(() => runEmulatorShellSafe(['hostapd', '-B', configFileName]))
.then(function (reply) {
// It may fail at the first time due to the previous ungracefully terminated one.
if (reply[0] === 'bind(PF_UNIX): Address already in use') {
return startOneHostapd(aIndex);
}
});
}
return Promise.all(aConfigList.map(function(aConfig, aIndex) {
return startOneHostapd(aIndex);
}));
}
/**
* Kill all the running hostapd processes.
*
* Use shell command 'kill -9' to kill all hostapds. Never reject.
*
* Fulfill params: (none)
*
* @return A deferred promise.
*/
function killAllHostapd() {
return getProcessDetail('hostapd')
.then(function (runningHostapds) {
let promises = runningHostapds.map(runningHostapd => {
return runEmulatorShellSafe(['kill', '-9', runningHostapd.pid]);
});
return Promise.all(promises);
});
}
/**
* Write out the config file to the given path.
*
* For each key/value pair in |aConfig|,
*
* [key]=[value]
*
* will be output to one new line. Never reject.
*
* Fulfill params: (none)
*
* @param aFilePath
* The file path that we desire the config file to be located.
*
* @param aConfig
* The config object.
*
* @return A deferred promise.
*/
function writeHostapdConfFile(aFilePath, aConfig) {
let content = '';
for (let key in aConfig) {
if (aConfig.hasOwnProperty(key)) {
content += (key + '=' + aConfig[key] + '\n');
}
}
return writeFile(aFilePath, content);
}
/**
* Write file to the given path filled with given content.
*
* For now it is implemented by shell command 'echo'. Also, if the
* content contains whitespace, we need to quote the content to
* avoid error. Never reject.
*
* Fulfill params: (none)
*
* @param aFilePath
* The file path that we desire the file to be located.
*
* @param aContent
* The content as string which should be written to the file.
*
* @return A deferred promise.
*/
function writeFile(aFilePath, aContent) {
if (-1 === aContent.indexOf(' ')) {
aContent = '"' + aContent + '"';
}
return runEmulatorShellSafe(['echo', aContent, '>', aFilePath]);
}
/**
* Check if a init service is running or not.
*
* Check the android property 'init.svc.[aServiceName]' to determine if
* a init service is running. Reject if the propery is neither 'running'
* nor 'stopped'.
*
* Fulfill params:
* result -- |true| if the init service is running; |false| otherwise.
* Reject params: (none)
*
* @param aServiceName
* The init service name.
*
* @return A deferred promise.
*/
function isInitServiceRunning(aServiceName) {
return runEmulatorShellSafe(['getprop', 'init.svc.' + aServiceName])
.then(function (result) {
if ('running' !== result[0] && 'stopped' !== result[0]) {
throw 'Init service running state should be "running" or "stopped".';
}
return 'running' === result[0];
});
}
/**
* Wait for timeout.
*
* Resolve when the given duration elapsed. Never reject.
*
* Fulfill params: (none)
*
* @param aTimeoutMs
* The duration after which the timeout event should occurs.
*
* @return A deferred promise.
*/
function waitForTimeout(aTimeoutMs) {
let deferred = Promise.defer();
setTimeout(function() {
deferred.resolve();
}, aTimeoutMs);
return deferred.promise;
}
/**
* Start or stop an init service.
*
* Use shell command 'start'/'stop' to start/stop an init service.
* The running state will also be checked after we start/stop the service.
* Resolve if the service is successfully started/stopped; Reject otherwise.
*
* Fulfill params: (none)
* Reject params: (none)
*
* @param aServiceName
* The name of the service we want to start/stop.
*
* @param aStart
* |true| for starting the init service. |false| for stopping.
*
* @return A deferred promise.
*/
function startStopInitService(aServiceName, aStart) {
let retryCnt = 5;
return runEmulatorShellSafe([aStart ? 'start' : 'stop', aServiceName])
.then(() => isInitServiceRunning(aServiceName))
.then(function onIsServiceRunningResolved(aIsRunning) {
if (aStart === aIsRunning) {
return;
}
if (retryCnt-- > 0) {
log('Failed to ' + (aStart ? 'start ' : 'stop ') + aServiceName +
'. Retry: ' + retryCnt);
return waitForTimeout(500)
.then(() => isInitServiceRunning(aServiceName))
.then(onIsServiceRunningResolved);
}
throw 'Failed to ' + (aStart ? 'start' : 'stop') + ' ' + aServiceName;
});
}
/**
* Start the stock hostapd.
*
* Since the stock hostapd is an init service, use |startStopInitService| to
* start it. Note that we might fail to start the stock hostapd at the first time
* for unknown reason so give it the second chance to start again.
* Resolve when we are eventually successful to start the stock hostapd; Reject
* otherwise.
*
* Fulfill params: (none)
* Reject params: (none)
*
* @return A deferred promise.
*/
function startStockHostapd() {
return startStopInitService(STOCK_HOSTAPD_NAME, true)
.then(null, function onreject() {
log('Failed to restart goldfish-hostapd at the first time. Try again!');
return startStopInitService((STOCK_HOSTAPD_NAME), true);
});
}
/**
* Stop the stock hostapd.
*
* Since the stock hostapd is an init service, use |startStopInitService| to
* stop it.
*
* Fulfill params: (none)
* Reject params: (none)
*
* @return A deferred promise.
*/
function stopStockHostapd() {
return startStopInitService(STOCK_HOSTAPD_NAME, false);
}
/**
* Get the index of the first matching entry by |ssid|.
*
* Find the index of the first entry of |aArray| which property |ssid|
* is same as |aSsid|.
*
* @param aSsid
* The ssid that we want to match.
* @param aArray
* An array of objects, each of which should have the property |ssid|.
*
* @return The 0-based index of first matching entry if found; -1 otherwise.
*/
function getFirstIndexBySsid(aSsid, aArray) {
for (let i = 0; i < aArray.length; i++) {
if (aArray[i].ssid === aSsid) {
return i;
}
}
return -1;
}
/**
* Count the number of running process and verify if the count is expected.
*
* Return a promise that resolves when the process has expected number
* of running instances and rejects otherwise.
*
* Fulfill params: (none)
* Reject params: (none)
*
* @param aOrigWifiEnabled
* Boolean which indicates wifi was originally enabled.
*
* @return A deferred promise.
*/
function verifyNumOfProcesses(aProcessName, aExpectedNum) {
return getProcessDetail(aProcessName)
.then(function (detail) {
if (detail.length === aExpectedNum) {
return;
}
throw 'Unexpected number of running processes:' + aProcessName +
', expected: ' + aExpectedNum + ', actual: ' + detail.length;
});
}
/**
* Clean up all the allocated resources and running services for the test.
*
* After the test no matter success or failure, we should
* 1) Restore to the wifi original state (enabled or disabled)
* 2) Wait until all pending emulator shell commands are done.
*
* |finsih| will be called in the end.
*
* Fulfill params: (none)
* Reject params: (none)
*
* @return A deferred promise.
*/
function cleanUp() {
waitFor(function() {
return ensureWifiEnabled(wifiOrigEnabled)
.then(finish);
}, function() {
return pendingEmulatorShellCount === 0;
});
}
/**
* Init the test environment.
*
* Mainly add the required permissions and initialize the wifiManager
* and the orignal state of wifi. Reject if failing to create
* window.navigator.mozWifiManager; resolve if all is well.
*
* |finsih| will be called in the end.
*
* Fulfill params: (none)
* Reject params: The reject reason.
*
* @return A deferred promise.
*/
function initTestEnvironment() {
return addRequiredPermissions()
.then(function() {
wifiManager = window.navigator.mozWifiManager;
if (!wifiManager) {
throw 'window.navigator.mozWifiManager is NULL';
}
wifiOrigEnabled = wifiManager.enabled;
});
}
//---------------------------------------------------
// Public test suite functions
//---------------------------------------------------
suite.getWifiManager = (() => wifiManager);
suite.ensureWifiEnabled = ensureWifiEnabled;
suite.requestWifiEnabled = requestWifiEnabled;
suite.startHostapds = startHostapds;
suite.getProcessDetail = getProcessDetail;
suite.killAllHostapd = killAllHostapd;
suite.wrapDomRequestAsPromise = wrapDomRequestAsPromise;
suite.waitForWifiManagerEventOnce = waitForWifiManagerEventOnce;
suite.verifyNumOfProcesses = verifyNumOfProcesses;
suite.testWifiScanWithRetry = testWifiScanWithRetry;
suite.getFirstIndexBySsid = getFirstIndexBySsid;
/**
* Common test routine.
*
* Start a test with the given test case chain. The test environment will be
* settled down before the test. After the test, all the affected things will
* be restored.
*
* Fulfill params: (none)
* Reject params: (none)
*
* @param aTestCaseChain
* The test case entry point, which can be a function or a promise.
*
* @return A deferred promise.
*/
suite.doTest = function(aTestCaseChain) {
return initTestEnvironment()
.then(aTestCaseChain)
.then(function onresolve() {
cleanUp();
}, function onreject(aReason) {
ok(false, 'Promise rejects during test' + (aReason ? '(' + aReason + ')' : ''));
cleanUp();
});
};
/**
* Common test routine without the presence of stock hostapd.
*
* Same as doTest except stopping the stock hostapd before test
* and restarting it after test.
*
* Fulfill params: (none)
* Reject params: (none)
*
* @param aTestCaseChain
* The test case entry point, which can be a function or a promise.
*
* @return A deferred promise.
*/
suite.doTestWithoutStockAp = function(aTestCaseChain) {
return suite.doTest(function() {
return stopStockHostapd()
.then(aTestCaseChain)
.then(startStockHostapd);
});
};
return suite;
})();

Просмотреть файл

@ -0,0 +1,8 @@
[DEFAULT]
b2g = true
browser = false
qemu = true
[test_wifi_enable.js]
[test_wifi_scan.js]
[test_wifi_associate.js]

Просмотреть файл

@ -0,0 +1,121 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
const SCAN_RETRY_CNT = 5;
/**
* Test wifi association.
*
* Associate with the given network object which is obtained by
* MozWifiManager.getNetworks() (i.e. MozWifiNetwork).
* Resolve when the 'connected' status change event is received.
* Note that we might see other events like 'connecting'
* before 'connected'. So we need to call |waitForWifiManagerEventOnce|
* again whenever non 'connected' event is seen. Never reject.
*
* Fulfill params: (none)
*
* @param aNetwork
* An object of MozWifiNetwork.
*
* @return A deferred promise.
*/
function testAssociate(aNetwork) {
if (!setPasswordIfNeeded(aNetwork)) {
throw 'Failed to set password';
}
function waitForConnected() {
return gTestSuite.waitForWifiManagerEventOnce('statuschange')
.then(function onstatuschange(event) {
log("event.status: " + event.status);
log("event.network.ssid: " + (event.network ? event.network.ssid : ''));
if ("connected" === event.status &&
event.network.ssid === aNetwork.ssid) {
return; // Got expected 'connected' event from aNetwork.ssid.
}
log('Not expected "connected" statuschange event. Wait again!');
return waitForConnected();
});
}
let promises = [];
// Register the event listerner to wait for 'connected' event first
// to avoid racing issue.
promises.push(waitForConnected());
// Then we do the association.
let request = gTestSuite.getWifiManager().associate(aNetwork);
promises.push(gTestSuite.wrapDomRequestAsPromise(request));
return Promise.all(promises);
}
/**
* Convert the given MozWifiNetwork object array to testAssociate chain.
*
* @param aNetworks
* An array of MozWifiNetwork which we want to convert.
*
* @return A promise chain which "then"s testAssociate accordingly.
*/
function convertToTestAssociateChain(aNetworks) {
let chain = Promise.resolve();
aNetworks.forEach(function (aNetwork) {
chain = chain.then(() => testAssociate(aNetwork));
});
return chain;
}
/**
* Set the password for associating the given network if needed.
*
* Set the password by looking up HOSTAPD_CONFIG_LIST. This function
* will also set |keyManagement| properly.
*
* @param aNetwork
* The MozWifiNetwork object.
*
* @return |true| if either insesure or successfully set the password/keyManagement.
* |false| if the given network is not found in HOSTAPD_CONFIG_LIST.
*/
function setPasswordIfNeeded(aNetwork) {
let i = gTestSuite.getFirstIndexBySsid(aNetwork.ssid, HOSTAPD_CONFIG_LIST);
if (-1 === i) {
log('unknown ssid: ' + aNetwork.ssid);
return false; // Error!
}
if (!aNetwork.security.length) {
return true; // No need to set password.
}
let security = aNetwork.security[0];
if (/PSK$/.test(security)) {
aNetwork.psk = HOSTAPD_CONFIG_LIST[i].wpa_passphrase;
aNetwork.keyManagement = 'WPA-PSK';
} else if (/WEP$/.test(security)) {
aNetwork.wep = HOSTAPD_CONFIG_LIST[i].wpa_passphrase;
aNetwork.keyManagement = 'WEP';
}
return true;
}
gTestSuite.doTestWithoutStockAp(function() {
return gTestSuite.ensureWifiEnabled(true)
.then(() => gTestSuite.startHostapds(HOSTAPD_CONFIG_LIST))
.then(() => gTestSuite.verifyNumOfProcesses('hostapd', HOSTAPD_CONFIG_LIST.length))
.then(() => gTestSuite.testWifiScanWithRetry(SCAN_RETRY_CNT, HOSTAPD_CONFIG_LIST))
.then(networks => convertToTestAssociateChain(networks))
.then(gTestSuite.killAllHostapd)
.then(() => gTestSuite.verifyNumOfProcesses('hostapd', 0));
});

Просмотреть файл

@ -0,0 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
gTestSuite.doTest(function() {
return Promise.resolve()
.then(() => gTestSuite.ensureWifiEnabled(false))
.then(() => gTestSuite.requestWifiEnabled(true));
});

Просмотреть файл

@ -0,0 +1,43 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
const SCAN_RETRY_CNT = 5;
/**
* Test scan with no AP present.
*
* The precondition is:
* 1) Wifi is enabled.
* 2) All the hostapds are turned off.
*
* @return deferred promise.
*/
function testScanNoAp() {
return gTestSuite.testWifiScanWithRetry(SCAN_RETRY_CNT, []);
}
/**
* Test scan with APs present.
*
* The precondition is:
* 1) Wifi is enabled.
* 2) All the hostapds are turned off.
*
* @return deferred promise.
*/
function testScanWithAps() {
return gTestSuite.startHostapds(HOSTAPD_CONFIG_LIST)
.then(() => gTestSuite.verifyNumOfProcesses('hostapd', HOSTAPD_CONFIG_LIST.length))
.then(() => gTestSuite.testWifiScanWithRetry(SCAN_RETRY_CNT, HOSTAPD_CONFIG_LIST))
.then(gTestSuite.killAllHostapd)
.then(() => gTestSuite.verifyNumOfProcesses('hostapd', 0));
}
gTestSuite.doTestWithoutStockAp(function() {
return gTestSuite.ensureWifiEnabled(true)
.then(testScanNoAp)
.then(testScanWithAps);
});

Просмотреть файл

@ -26,3 +26,4 @@ skip = false
[include:../../../../../dom/system/tests/marionette/manifest.ini]
[include:../../../../../dom/nfc/tests/marionette/manifest.ini]
[include:../../../../../dom/events/test/marionette/manifest.ini]
[include:../../../../../dom/wifi/test/marionette/manifest.ini]

Просмотреть файл

@ -8,6 +8,7 @@
[include:dom/system/gonk/tests/xpcshell.ini]
[include:dom/wappush/tests/xpcshell.ini]
[include:toolkit/components/osfile/tests/xpcshell/xpcshell.ini]
[include:toolkit/components/captivedetect/test/unit/xpcshell.ini]
[include:toolkit/devtools/apps/tests/unit/xpcshell.ini]
[include:toolkit/devtools/debugger/tests/unit/xpcshell.ini]
[include:toolkit/devtools/qrcode/tests/unit/xpcshell.ini]

Просмотреть файл

@ -10,6 +10,10 @@ const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import('resource://gre/modules/Services.jsm');
XPCOMUtils.defineLazyServiceGetter(this, "gSysMsgr",
"@mozilla.org/system-message-internal;1",
"nsISystemMessagesInternal");
const DEBUG = false; // set to true to show debug messages
const kCAPTIVEPORTALDETECTOR_CONTRACTID = '@mozilla.org/toolkit/captive-detector;1';
@ -17,6 +21,9 @@ const kCAPTIVEPORTALDETECTOR_CID = Components.ID('{d9cd00ba-aa4d-47b1-879
const kOpenCaptivePortalLoginEvent = 'captive-portal-login';
const kAbortCaptivePortalLoginEvent = 'captive-portal-login-abort';
const kCaptivePortalLoginSuccessEvent = 'captive-portal-login-success';
const kCaptivePortalSystemMessage = 'captive-portal';
function URLFetcher(url, timeout) {
let self = this;
@ -332,6 +339,7 @@ CaptivePortalDetector.prototype = {
this._loginObserver.attach();
this._runningRequest['eventId'] = id;
this._sendEvent(kOpenCaptivePortalLoginEvent, details);
gSysMsgr.broadcastMessage(kCaptivePortalSystemMessage, {});
},
_mayRetry: function _mayRetry() {
@ -350,6 +358,16 @@ CaptivePortalDetector.prototype = {
this._runningRequest.callback.complete(success);
}
// Only when the request has a event id and |success| is true
// do we need to notify the login-success event.
if (this._runningRequest.hasOwnProperty('eventId') && success) {
let details = {
type: kCaptivePortalLoginSuccessEvent,
id: this._runningRequest['eventId'],
};
this._sendEvent(kCaptivePortalLoginSuccessEvent, details);
}
// Continue the following request
this._runningRequest['complete'] = true;
this._removeRequest(this._runningRequest.interfaceName);

Просмотреть файл

@ -32,6 +32,13 @@ function fakeUIResponse() {
do_check_eq(++step, 2);
}
}, 'captive-portal-login', false);
Services.obs.addObserver(function observe(subject, topic, data) {
if (topic === 'captive-portal-login-success') {
do_check_eq(++step, 4);
gServer.stop(do_test_finished);
}
}, 'captive-portal-login-success', false);
}
function test_portal_found() {
@ -44,9 +51,11 @@ function test_portal_found() {
gCaptivePortalDetector.finishPreparation(kInterfaceName);
},
complete: function complete(success) {
// Since this is a synchronous callback, it must happen before
// 'captive-portal-login-success' is received.
// (Check captivedetect.js::executeCallback
do_check_eq(++step, 3);
do_check_true(success);
gServer.stop(do_test_finished);
},
};

Просмотреть файл

@ -34,6 +34,13 @@ function fakeUIResponse() {
do_check_eq(++step, 2);
}
}, 'captive-portal-login', false);
Services.obs.addObserver(function observe(subject, topic, data) {
if (topic === 'captive-portal-login-success') {
do_check_eq(++step, 4);
gServer.stop(do_test_finished);
}
}, 'captive-portal-login-success', false);
}
function test_portal_found() {
@ -48,7 +55,6 @@ function test_portal_found() {
complete: function complete(success) {
do_check_eq(++step, 3);
do_check_true(success);
gServer.stop(do_test_finished);
},
};
@ -57,12 +63,4 @@ function test_portal_found() {
function run_test() {
run_captivedetect_test(xhr_handler, fakeUIResponse, test_portal_found);
server = new HttpServer();
server.registerPathHandler(kCanonicalSitePath, xhr_handler);
server.start(4444);
fakeUIResponse();
test_portal_found();
}

Просмотреть файл

@ -10,6 +10,7 @@ const kOtherInterfaceName = 'ril';
var server;
var step = 0;
var loginFinished = false;
var loginSuccessCount = 0;
function xhr_handler(metadata, response) {
response.setStatusLine(metadata.httpVersion, 200, 'OK');
@ -33,6 +34,16 @@ function fakeUIResponse() {
do_check_eq(++step, 2);
}
}, 'captive-portal-login', false);
Services.obs.addObserver(function observe(subject, topic, data) {
if (topic === 'captive-portal-login-success') {
loginSuccessCount++;
if (loginSuccessCount > 1) {
throw "We should only receive 'captive-portal-login-success' once";
}
do_check_eq(++step, 4);
}
}, 'captive-portal-login-success', false);
}
function test_multiple_requests() {
@ -53,11 +64,11 @@ function test_multiple_requests() {
let otherCallback = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsICaptivePortalCallback]),
prepare: function prepare() {
do_check_eq(++step, 4);
do_check_eq(++step, 5);
gCaptivePortalDetector.finishPreparation(kOtherInterfaceName);
},
complete: function complete(success) {
do_check_eq(++step, 5);
do_check_eq(++step, 6);
do_check_true(success);
gServer.stop(do_test_finished);
}