Bug 1492735 - Port Bug 1486147: Replace use of nsIUTF8StringEnumerator in msgIStructuredHeaders. r=mkmelin

--HG--
extra : rebase_source : 43f99a3d2838e4ed1d550481afaf7c47e2828833
This commit is contained in:
Jorg K 2018-09-26 10:49:19 +02:00
Родитель cf4762ba06
Коммит ac863f050c
4 изменённых файлов: 8 добавлений и 45 удалений

Просмотреть файл

@ -10,8 +10,7 @@ var nsMsgCompFields = Components.Constructor(
function check_headers(enumerator, container) {
let checkValues = new Set(container.map(header => header.toLowerCase()));
while (enumerator.hasMore()) {
let value = enumerator.getNext().toLowerCase();
for (let value of enumerator) {
Assert.ok(checkValues.has(value));
checkValues.delete(value);
}

Просмотреть файл

@ -12,7 +12,7 @@
%}
interface msgIAddressObject;
interface nsIUTF8StringEnumerator;
interface nsIJSEnumerator;
/**
* A collection of MIME headers that are stored in a rich, structured format.
@ -95,7 +95,7 @@ interface msgIStructuredHeaders : nsISupports {
* precise implementation of this interface, so implementations should not
* rely on an exact kind of case being returned.
*/
readonly attribute nsIUTF8StringEnumerator headerNames;
readonly attribute nsIJSEnumerator headerNames;
/**
* Retrieve the MIME representation of all of the headers.

Просмотреть файл

@ -12,34 +12,6 @@ function HeaderHandler() {
this.deliverEOF = function () {};
}
function StringEnumerator(iterator) {
this._iterator = iterator;
this._next = undefined;
}
StringEnumerator.prototype = {
QueryInterface: ChromeUtils.generateQI([Ci.nsIUTF8StringEnumerator]),
[Symbol.iterator]: function () {
return this;
},
_setNext: function () {
if (this._next !== undefined)
return;
this._next = this._iterator.next();
},
hasMore: function () {
this._setNext();
return !this._next.done;
},
getNext: function () {
this._setNext();
let result = this._next;
this._next = undefined;
if (result.done)
throw Cr.NS_ERROR_UNEXPECTED;
return result.value;
}
};
/**
* If we get XPConnect-wrapped objects for msgIAddressObjects, we will have
* properties defined for 'group' that throws off jsmime. This function converts
@ -107,7 +79,7 @@ MimeStructuredHeaders.prototype = {
},
get headerNames() {
return new StringEnumerator(this._headers.keys());
return this._headers.keys();
},
buildMimeText: function () {
@ -179,9 +151,7 @@ MimeWritableStructuredHeaders.prototype = {
},
addAllHeaders: function (aHeaders) {
let headerList = aHeaders.headerNames;
while (headerList.hasMore()) {
let header = headerList.getNext();
for (let header of aHeaders.headerNames) {
this.setHeader(header, aHeaders.getHeader(header));
}
},

Просмотреть файл

@ -121,18 +121,14 @@ add_task(async function check_raw() {
headers.setHeader("unabashed-random-header", false);
let headerList = ["Date", "Content-Description", "Subject",
"Unabashed-Random-Header"];
let enumerator = headers.headerNames;
while (enumerator.hasMore()) {
let value = enumerator.getNext();
for (let value of headers.headerNames) {
Assert.equal(value.toLowerCase(), headerList.shift().toLowerCase());
}
// Check that copying works
let moreHeaders = new StructuredHeaders();
moreHeaders.addAllHeaders(headers);
enumerator = headers.headerNames;
while (enumerator.hasMore()) {
let value = enumerator.getNext();
for (let value of headers.headerNames) {
Assert.equal(moreHeaders.getHeader(value), headers.getHeader(value));
}
headers.deleteHeader("Date");
@ -155,9 +151,7 @@ add_task(async function check_nsIMimeHeaders() {
"FCC", "BCC", "X-Identity-Key", "Message-ID", "Date", "From",
"X-Mozilla-Draft-Info", "User-Agent", "MIME-Version", "To", "Subject",
"Content-Type", "Content-Transfer-Encoding"];
let enumerator = headers.headerNames;
while (enumerator.hasMore()) {
let value = enumerator.getNext();
for (let value of headers.headerNames) {
Assert.equal(value.toLowerCase(), headerList.shift().toLowerCase());
}
});