mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
8b59e0537f
--HG-- rename : dom/system/b2g/AudioManager.cpp => dom/system/gonk/AudioManager.cpp rename : dom/system/b2g/AudioManager.h => dom/system/gonk/AudioManager.h rename : dom/system/b2g/GonkGPSGeolocationProvider.cpp => dom/system/gonk/GonkGPSGeolocationProvider.cpp rename : dom/system/b2g/GonkGPSGeolocationProvider.h => dom/system/gonk/GonkGPSGeolocationProvider.h rename : dom/system/b2g/Makefile.in => dom/system/gonk/Makefile.in rename : dom/system/b2g/RadioInterfaceLayer.js => dom/system/gonk/RadioInterfaceLayer.js rename : dom/system/b2g/RadioInterfaceLayer.manifest => dom/system/gonk/RadioInterfaceLayer.manifest rename : dom/system/b2g/SystemWorkerManager.cpp => dom/system/gonk/SystemWorkerManager.cpp rename : dom/system/b2g/SystemWorkerManager.h => dom/system/gonk/SystemWorkerManager.h rename : dom/system/b2g/net_worker.js => dom/system/gonk/net_worker.js rename : dom/system/b2g/nsIAudioManager.idl => dom/system/gonk/nsIAudioManager.idl rename : dom/system/b2g/nsIRadioInterfaceLayer.idl => dom/system/gonk/nsIRadioInterfaceLayer.idl rename : dom/system/b2g/nsIWorkerHolder.idl => dom/system/gonk/nsIWorkerHolder.idl rename : dom/system/b2g/nsRadioInterfaceLayer.h => dom/system/gonk/nsRadioInterfaceLayer.h rename : dom/system/b2g/ril_consts.js => dom/system/gonk/ril_consts.js rename : dom/system/b2g/ril_worker.js => dom/system/gonk/ril_worker.js rename : dom/system/b2g/systemlibs.js => dom/system/gonk/systemlibs.js rename : dom/system/b2g/tests/header_helpers.js => dom/system/gonk/tests/header_helpers.js rename : dom/system/b2g/tests/test_ril_worker_buf.js => dom/system/gonk/tests/test_ril_worker_buf.js rename : dom/system/b2g/tests/test_ril_worker_sms.js => dom/system/gonk/tests/test_ril_worker_sms.js rename : dom/system/b2g/tests/xpcshell.ini => dom/system/gonk/tests/xpcshell.ini
85 lines
2.2 KiB
JavaScript
85 lines
2.2 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
function run_test() {
|
|
run_next_test();
|
|
}
|
|
|
|
/**
|
|
* Add test function with specified parcel and request handler.
|
|
*
|
|
* @param parcel
|
|
* Incoming parcel to be tested.
|
|
* @param handler
|
|
* Handler to be invoked as RIL request handler.
|
|
*/
|
|
function add_test_incoming_parcel(parcel, handler) {
|
|
add_test(function test_incoming_parcel() {
|
|
let worker = newWorker({
|
|
postRILMessage: function fakePostRILMessage(data) {
|
|
// do nothing
|
|
},
|
|
postMessage: function fakePostMessage(message) {
|
|
// do nothing
|
|
}
|
|
});
|
|
|
|
if (!parcel) {
|
|
parcel = newIncomingParcel(-1,
|
|
worker.RESPONSE_TYPE_UNSOLICITED,
|
|
worker.REQUEST_REGISTRATION_STATE,
|
|
[0, 0, 0, 0]);
|
|
}
|
|
|
|
// supports only requests less or equal than UINT8_MAX(255).
|
|
let request = parcel[worker.PARCEL_SIZE_SIZE + worker.UINT32_SIZE];
|
|
worker.RIL[request] = function ril_request_handler() {
|
|
handler(worker);
|
|
worker.postMessage();
|
|
};
|
|
|
|
worker.onRILMessage(parcel);
|
|
|
|
// end of incoming parcel's trip, let's do next test.
|
|
run_next_test();
|
|
});
|
|
}
|
|
|
|
// Test normal parcel handling.
|
|
add_test_incoming_parcel(null,
|
|
function test_normal_parcel_handling(worker) {
|
|
do_check_throws(function normal_handler(worker) {
|
|
// reads exactly the same size, should not throw anything.
|
|
worker.Buf.readUint32();
|
|
});
|
|
}
|
|
);
|
|
|
|
// Test parcel under read.
|
|
add_test_incoming_parcel(null,
|
|
function test_parcel_under_read(worker) {
|
|
do_check_throws(function under_read_handler() {
|
|
// reads less than parcel size, should not throw.
|
|
worker.Buf.readUint16();
|
|
}, false);
|
|
}
|
|
);
|
|
|
|
// Test parcel over read.
|
|
add_test_incoming_parcel(null,
|
|
function test_parcel_over_read(worker) {
|
|
let buf = worker.Buf;
|
|
|
|
// read all data available
|
|
while (buf.readAvailable > 0) {
|
|
buf.readUint8();
|
|
}
|
|
|
|
do_check_throws(function over_read_handler() {
|
|
// reads more than parcel size, should throw an error.
|
|
buf.readUint8();
|
|
}, new Error("Trying to read data beyond the parcel end!").result);
|
|
}
|
|
);
|
|
|