Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1145031 - fix duplicated option in select option of server certif…
Browse files Browse the repository at this point in the history
…icate, r=ej
  • Loading branch information
ian-liu authored and rvandermeulen committed May 7, 2015
1 parent 7a3ac0c commit 6168009
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion apps/settings/js/modules/wifi_utils.js
Expand Up @@ -222,7 +222,8 @@ define(function(require) {
var certificateList = certList.ServerCert;

// reset the option to be <option value="none">--</option> only
for (i = 0; i < select.options.length - 1; i++) {
var originLengthOfOptions = select.options.length;
for (i = 0; i < originLengthOfOptions - 1; i++) {
select.remove(1);
}

Expand Down
11 changes: 9 additions & 2 deletions apps/settings/test/unit/modules/wifi_utils_test.js
Expand Up @@ -231,20 +231,27 @@ suite('WifiUtils', function() {
var selectDOM = document.createElement('select');
selectDOM.appendChild(createOption('--'));
selectDOM.appendChild(createOption('1'));
selectDOM.appendChild(createOption('2'));

MockNavigatorMozWifiManager._certificateList = [
'cert1', 'cert2', 'cert3'
];

// the total options would be one default item and certificates
var expectedLengthOfOptions =
1 + MockNavigatorMozWifiManager._certificateList.length;

this.sinon.spy(selectDOM, 'remove');
this.sinon.spy(selectDOM, 'add');
wifiUtils.loadImportedCertificateOptions(selectDOM);

// we have two options, but we would keep the first one
assert.isTrue(selectDOM.remove.calledOnce);
// we have three options, but we would keep the first one
assert.isTrue(selectDOM.remove.calledTwice);
// and we would add three options back based on the number of our fake
// certificates
assert.isTrue(selectDOM.add.calledThrice);
// and the total options should be one default item and certificates
assert.equal(selectDOM.options.length, expectedLengthOfOptions);
});

suite('newListItem', function() {
Expand Down

0 comments on commit 6168009

Please sign in to comment.