1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 * @suppress {checkTypes}
8 * Browser test for the scenario below:
10 * 2. Connect with the new PIN.
11 * 3. Verify the connection succeeded.
12 * 4. Disconnect and reconnect with the old PIN.
13 * 5. Verify the connection failed.
19 browserTest
.Update_PIN = function() {};
22 * @param {{new_pin:string, old_pin:string}} data
24 browserTest
.Update_PIN
.prototype.run = function(data
) {
25 var LOGIN_BACKOFF_WAIT
= 2000;
27 browserTest
.expect(typeof data
.new_pin
== 'string');
28 browserTest
.expect(typeof data
.old_pin
== 'string');
29 browserTest
.expect(data
.new_pin
!= data
.old_pin
,
30 'The new PIN and the old PIN cannot be the same');
32 this.changePIN_(data
.new_pin
).then(
33 browserTest
.connectMe2Me
35 return browserTest
.enterPIN(data
.old_pin
, true /* expectError*/);
37 // Sleep for two seconds to allow for the login backoff logic to reset.
38 base
.Promise
.sleep
.bind(null, LOGIN_BACKOFF_WAIT
)
40 browserTest
.connectMe2Me
42 return browserTest
.enterPIN(data
.new_pin
, false /* expectError*/)
44 // Clean up the test by disconnecting and changing the PIN back
45 browserTest
.disconnect
47 // The PIN must be restored regardless of success or failure.
48 this.changePIN_
.bind(this, data
.old_pin
),
49 this.changePIN_
.bind(this, data
.old_pin
)
59 * @param {string} newPin
62 browserTest
.Update_PIN
.prototype.changePIN_ = function(newPin
) {
63 var AppMode
= remoting
.AppMode
;
64 var HOST_RESTART_WAIT
= 10000;
65 browserTest
.clickOnControl('.change-daemon-pin');
66 return browserTest
.setupPIN(newPin
);