michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: MARIONETTE_TIMEOUT = 30000; michael@0: MARIONETTE_HEAD_JS = "icc_header.js"; michael@0: michael@0: /* Test PIN code changes fail */ michael@0: taskHelper.push(function testPinChangeFailed() { michael@0: // The default pin is '0000' in emulator michael@0: let request = icc.setCardLock( michael@0: {lockType: "pin", michael@0: pin: "1111", michael@0: newPin: "0000"}); michael@0: michael@0: ok(request instanceof DOMRequest, michael@0: "request instanceof " + request.constructor); michael@0: michael@0: request.onerror = function onerror() { michael@0: is(request.error.name, "IncorrectPassword"); michael@0: is(request.error.lockType, "pin"); michael@0: // The default pin retries is 3, failed once becomes to 2 michael@0: is(request.error.retryCount, 2); michael@0: michael@0: // Reset pin retries by passing correct pin code. michael@0: let resetRequest = icc.setCardLock( michael@0: {lockType: "pin", michael@0: pin: "0000", michael@0: newPin: "0000"}); michael@0: michael@0: resetRequest.onsuccess = function onsuccess() { michael@0: taskHelper.runNext(); michael@0: }; michael@0: michael@0: resetRequest.onerror = function onerror() { michael@0: ok(false, "Reset pin retries got error: " + request.error.name); michael@0: taskHelper.runNext(); michael@0: }; michael@0: }; michael@0: }); michael@0: michael@0: /* Test PIN code changes success */ michael@0: taskHelper.push(function testPinChangeSuccess() { michael@0: // The default pin is '0000' in emulator michael@0: let request = icc.setCardLock( michael@0: {lockType: "pin", michael@0: pin: "0000", michael@0: newPin: "0000"}); michael@0: michael@0: ok(request instanceof DOMRequest, michael@0: "request instanceof " + request.constructor); michael@0: michael@0: request.onerror = function onerror() { michael@0: ok(false, "Should not fail, got error: " + request.error.name); michael@0: michael@0: taskHelper.runNext(); michael@0: }; michael@0: michael@0: request.onsuccess = function onsuccess() { michael@0: is(request.result.lockType, "pin"); michael@0: is(request.result.success, true); michael@0: michael@0: taskHelper.runNext(); michael@0: }; michael@0: }); michael@0: michael@0: /* Read PIN-lock retry count */ michael@0: taskHelper.push(function testPinCardLockRetryCount() { michael@0: let request = icc.getCardLockRetryCount('pin'); michael@0: michael@0: ok(request instanceof DOMRequest, michael@0: 'request instanceof ' + request.constructor); michael@0: michael@0: request.onsuccess = function onsuccess() { michael@0: is(request.result.lockType, 'pin', michael@0: 'lockType is ' + request.result.lockType); michael@0: ok(request.result.retryCount >= 0, michael@0: 'retryCount is ' + request.result.retryCount); michael@0: taskHelper.runNext(); michael@0: }; michael@0: request.onerror = function onerror() { michael@0: // The operation is optional any might not be supported for all michael@0: // all locks. In this case, we generate 'NotSupportedError' for michael@0: // the valid lock types. michael@0: is(request.error.name, 'RequestNotSupported', michael@0: 'error name is ' + request.error.name); michael@0: taskHelper.runNext(); michael@0: }; michael@0: }); michael@0: michael@0: /* Read PUK-lock retry count */ michael@0: taskHelper.push(function testPukCardLockRetryCount() { michael@0: let request = icc.getCardLockRetryCount('puk'); michael@0: michael@0: ok(request instanceof DOMRequest, michael@0: 'request instanceof ' + request.constructor); michael@0: michael@0: request.onsuccess = function onsuccess() { michael@0: is(request.result.lockType, 'puk', michael@0: 'lockType is ' + request.result.lockType); michael@0: ok(request.result.retryCount >= 0, michael@0: 'retryCount is ' + request.result.retryCount); michael@0: taskHelper.runNext(); michael@0: }; michael@0: request.onerror = function onerror() { michael@0: // The operation is optional any might not be supported for all michael@0: // all locks. In this case, we generate 'NotSupportedError' for michael@0: // the valid lock types. michael@0: is(request.error.name, 'RequestNotSupported', michael@0: 'error name is ' + request.error.name); michael@0: taskHelper.runNext(); michael@0: }; michael@0: }); michael@0: michael@0: /* Read lock retry count for an invalid entries */ michael@0: taskHelper.push(function testInvalidCardLockRetryCount() { michael@0: let request = icc.getCardLockRetryCount('invalid-lock-type'); michael@0: michael@0: ok(request instanceof DOMRequest, michael@0: 'request instanceof ' + request.constructor); michael@0: michael@0: request.onsuccess = function onsuccess() { michael@0: ok(false, michael@0: 'request should never return success for an invalid lock type'); michael@0: taskHelper.runNext(); michael@0: }; michael@0: request.onerror = function onerror() { michael@0: is(request.error.name, 'GenericFailure', michael@0: 'error name is ' + request.error.name); michael@0: taskHelper.runNext(); michael@0: }; michael@0: }); michael@0: michael@0: // Start test michael@0: taskHelper.runNext();