Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | subscriptLoader.loadSubScript("resource://gre/modules/ril_consts.js", this); |
michael@0 | 5 | |
michael@0 | 6 | function run_test() { |
michael@0 | 7 | run_next_test(); |
michael@0 | 8 | } |
michael@0 | 9 | |
michael@0 | 10 | function _getWorker() { |
michael@0 | 11 | let _postedMessage; |
michael@0 | 12 | let _worker = newWorker({ |
michael@0 | 13 | postRILMessage: function(data) { |
michael@0 | 14 | }, |
michael@0 | 15 | postMessage: function(message) { |
michael@0 | 16 | _postedMessage = message; |
michael@0 | 17 | } |
michael@0 | 18 | }); |
michael@0 | 19 | return { |
michael@0 | 20 | get postedMessage() { |
michael@0 | 21 | return _postedMessage; |
michael@0 | 22 | }, |
michael@0 | 23 | get worker() { |
michael@0 | 24 | return _worker; |
michael@0 | 25 | } |
michael@0 | 26 | }; |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | add_test(function test_queryCLIP_provisioned() { |
michael@0 | 30 | let workerHelper = _getWorker(); |
michael@0 | 31 | let worker = workerHelper.worker; |
michael@0 | 32 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 33 | |
michael@0 | 34 | context.Buf.readInt32 = function fakeReadUint32() { |
michael@0 | 35 | return context.Buf.int32Array.pop(); |
michael@0 | 36 | }; |
michael@0 | 37 | |
michael@0 | 38 | context.RIL.queryCLIP = function fakeQueryCLIP(options) { |
michael@0 | 39 | context.Buf.int32Array = [ |
michael@0 | 40 | 1, // CLIP provisioned. |
michael@0 | 41 | 1 // Length. |
michael@0 | 42 | ]; |
michael@0 | 43 | context.RIL[REQUEST_QUERY_CLIP](1, { |
michael@0 | 44 | rilRequestError: ERROR_SUCCESS |
michael@0 | 45 | }); |
michael@0 | 46 | }; |
michael@0 | 47 | |
michael@0 | 48 | context.RIL.queryCLIP({}); |
michael@0 | 49 | |
michael@0 | 50 | let postedMessage = workerHelper.postedMessage; |
michael@0 | 51 | |
michael@0 | 52 | do_check_eq(postedMessage.errorMsg, undefined); |
michael@0 | 53 | do_check_true(postedMessage.success); |
michael@0 | 54 | do_check_eq(postedMessage.provisioned, 1); |
michael@0 | 55 | run_next_test(); |
michael@0 | 56 | }); |
michael@0 | 57 | |
michael@0 | 58 | add_test(function test_getCLIP_error_generic_failure_invalid_length() { |
michael@0 | 59 | let workerHelper = _getWorker(); |
michael@0 | 60 | let worker = workerHelper.worker; |
michael@0 | 61 | let context = worker.ContextPool._contexts[0]; |
michael@0 | 62 | |
michael@0 | 63 | context.Buf.readInt32 = function fakeReadUint32() { |
michael@0 | 64 | return context.Buf.int32Array.pop(); |
michael@0 | 65 | }; |
michael@0 | 66 | |
michael@0 | 67 | context.RIL.queryCLIP = function fakeQueryCLIP(options) { |
michael@0 | 68 | context.Buf.int32Array = [ |
michael@0 | 69 | 1, // CLIP provisioned. |
michael@0 | 70 | 0 // Length. |
michael@0 | 71 | ]; |
michael@0 | 72 | context.RIL[REQUEST_QUERY_CLIP](1, { |
michael@0 | 73 | rilRequestError: ERROR_SUCCESS |
michael@0 | 74 | }); |
michael@0 | 75 | }; |
michael@0 | 76 | |
michael@0 | 77 | context.RIL.queryCLIP({}); |
michael@0 | 78 | |
michael@0 | 79 | let postedMessage = workerHelper.postedMessage; |
michael@0 | 80 | |
michael@0 | 81 | do_check_eq(postedMessage.errorMsg, "GenericFailure"); |
michael@0 | 82 | do_check_false(postedMessage.success); |
michael@0 | 83 | run_next_test(); |
michael@0 | 84 | }); |