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.

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

mercurial