dom/icc/tests/marionette/test_icc_match_mvno.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 MARIONETTE_TIMEOUT = 30000;
michael@0 5 MARIONETTE_HEAD_JS = "icc_header.js";
michael@0 6
michael@0 7 // Emulator's hard coded IMSI: 310260000000000
michael@0 8 let testCases = [
michael@0 9 // mvno type, mvno data, request success, expected result
michael@0 10 ["imsi", "3102600", true, true ],
michael@0 11 // x and X means skip the comparison.
michael@0 12 ["imsi", "31026xx0", true, true ],
michael@0 13 ["imsi", "310260x0x", true, true ],
michael@0 14 ["imsi", "310260X00", true, true ],
michael@0 15 ["imsi", "310260XX1", true, false ],
michael@0 16 ["imsi", "31026012", true, false ],
michael@0 17 ["imsi", "310260000000000", true, true ],
michael@0 18 ["imsi", "310260000000000123", true, false ],
michael@0 19 ["imsi", "", false, "InvalidParameter"],
michael@0 20 // Currently we only support imsi match.
michael@0 21 ["spn", "Android", false, "ModeNotSupported"]
michael@0 22 ];
michael@0 23
michael@0 24 function matchMvno(mvnoType, mvnoData, success, expectedResult) {
michael@0 25 log("matchMvno: " + mvnoType + ", " + mvnoData);
michael@0 26 let request = icc.matchMvno(mvnoType, mvnoData);
michael@0 27 request.onsuccess = function onsuccess() {
michael@0 28 log("onsuccess: " + request.result);
michael@0 29 ok(success, "onsuccess while error expected");
michael@0 30 is(request.result, expectedResult);
michael@0 31 testMatchMvno();
michael@0 32 }
michael@0 33 request.onerror = function onerror() {
michael@0 34 log("onerror: " + request.error.name);
michael@0 35 ok(!success, "onerror while success expected");
michael@0 36 is(request.error.name, expectedResult);
michael@0 37 testMatchMvno();
michael@0 38 }
michael@0 39 }
michael@0 40
michael@0 41 function testMatchMvno() {
michael@0 42 let testCase = testCases.shift();
michael@0 43 if (!testCase) {
michael@0 44 taskHelper.runNext();
michael@0 45 return;
michael@0 46 }
michael@0 47 matchMvno(testCase[0], testCase[1], testCase[2], testCase[3]);
michael@0 48 }
michael@0 49
michael@0 50 taskHelper.push(
michael@0 51 testMatchMvno
michael@0 52 );
michael@0 53
michael@0 54 // Start test
michael@0 55 taskHelper.runNext();
michael@0 56

mercurial