зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1774462) for xpcshell failure on test_keys.js . CLOSED TREE
Backed out changeset adfa13e465e6 (bug 1774462) Backed out changeset ee137407c8b4 (bug 1774462)
This commit is contained in:
Родитель
d586be7f75
Коммит
1b59ca4f2a
|
@ -47,7 +47,7 @@ DOM4_MSG_DEF(ConstraintError, "A mutation operation in the transaction failed be
|
|||
DOM4_MSG_DEF(ConstraintError, "Object store renamed to an already existing object store.", NS_ERROR_DOM_INDEXEDDB_RENAME_OBJECT_STORE_ERR)
|
||||
DOM4_MSG_DEF(ConstraintError, "Index already exists and a new one was being attempted to be created.", NS_ERROR_DOM_INDEXEDDB_RENAME_INDEX_ERR)
|
||||
DOM4_MSG_DEF(DataError, "Data provided to an operation does not meet requirements.", NS_ERROR_DOM_INDEXEDDB_DATA_ERR)
|
||||
DOM4_MSG_DEF(DataError, "No valid key or key range specified.", NS_ERROR_DOM_INDEXEDDB_KEY_ERR)
|
||||
DOM4_MSG_DEF(DataError, "No key or key range specified.", NS_ERROR_DOM_INDEXEDDB_KEY_ERR)
|
||||
DOM4_MSG_DEF(TransactionInactiveError, "A request was placed against a transaction which is currently not active, or which is finished.", NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR)
|
||||
DOM4_MSG_DEF(ReadOnlyError, "A mutation operation was attempted in a READ_ONLY transaction.", NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR)
|
||||
DOM4_MSG_DEF(VersionError, "The operation failed because the stored database is a higher version than the version requested.", NS_ERROR_DOM_INDEXEDDB_VERSION_ERR)
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "Key.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <stdint.h> // for UINT32_MAX, uintptr_t
|
||||
#include "js/Array.h" // JS::NewArrayObject
|
||||
#include "js/ArrayBuffer.h" // JS::{IsArrayBufferObject,NewArrayBuffer{,WithContents},GetArrayBufferLengthAndData}
|
||||
|
@ -32,7 +31,6 @@
|
|||
#include "mozIStorageStatement.h"
|
||||
#include "mozIStorageValueArray.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsTStringRepr.h"
|
||||
#include "ReportInternalError.h"
|
||||
#include "xpcpublic.h"
|
||||
|
||||
|
@ -557,22 +555,20 @@ Result<Ok, nsresult> Key::EncodeString(const Span<const T> aInput,
|
|||
return EncodeAsString(aInput, eString + aTypeOffset);
|
||||
}
|
||||
|
||||
// nsCString maximum length is limited by INT32_MAX.
|
||||
// XXX: We probably want to enforce even shorter keys, though.
|
||||
#define KEY_MAXIMUM_BUFFER_LENGTH \
|
||||
::mozilla::detail::nsTStringLengthStorage<char>::kMax
|
||||
|
||||
template <typename T>
|
||||
Result<Ok, nsresult> Key::EncodeAsString(const Span<const T> aInput,
|
||||
uint8_t aType) {
|
||||
// Please note that the input buffer can either be based on two-byte UTF-16
|
||||
// values or on arbitrary single byte binary values. Only the first case
|
||||
// needs to account for the TWO_BYTE_LIMIT of UTF-8.
|
||||
// First we measure how long the encoded string will be.
|
||||
// First measure how long the encoded string will be.
|
||||
if (NS_WARN_IF(UINT32_MAX - 2 < uintptr_t(aInput.Length()))) {
|
||||
IDB_REPORT_INTERNAL_ERR();
|
||||
return Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
}
|
||||
|
||||
// The 2 is for initial aType and trailing 0. We'll compensate for multi-byte
|
||||
// The +2 is for initial aType and trailing 0. We'll compensate for multi-byte
|
||||
// chars below.
|
||||
uint32_t size = 2;
|
||||
CheckedUint32 size = 2;
|
||||
|
||||
MOZ_ASSERT(size.isValid());
|
||||
|
||||
// We construct a range over the raw pointers here because this loop is
|
||||
// time-critical.
|
||||
|
@ -581,32 +577,32 @@ Result<Ok, nsresult> Key::EncodeAsString(const Span<const T> aInput,
|
|||
const auto inputRange = mozilla::detail::IteratorRange(
|
||||
aInput.Elements(), aInput.Elements() + aInput.Length());
|
||||
|
||||
uint32_t payloadSize = aInput.Length();
|
||||
CheckedUint32 payloadSize = aInput.Length();
|
||||
bool anyMultibyte = false;
|
||||
for (const T val : inputRange) {
|
||||
for (const auto val : inputRange) {
|
||||
if (val > ONE_BYTE_LIMIT) {
|
||||
anyMultibyte = true;
|
||||
payloadSize += char16_t(val) > TWO_BYTE_LIMIT ? 2 : 1;
|
||||
if (payloadSize > KEY_MAXIMUM_BUFFER_LENGTH) {
|
||||
if (!payloadSize.isValid()) {
|
||||
IDB_REPORT_INTERNAL_ERR();
|
||||
return Err(NS_ERROR_DOM_INDEXEDDB_KEY_ERR);
|
||||
return Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size += payloadSize;
|
||||
|
||||
// Now we allocate memory for the new size
|
||||
// Allocate memory for the new size
|
||||
uint32_t oldLen = mBuffer.Length();
|
||||
size += oldLen;
|
||||
|
||||
if (size > KEY_MAXIMUM_BUFFER_LENGTH) {
|
||||
if (!size.isValid()) {
|
||||
IDB_REPORT_INTERNAL_ERR();
|
||||
return Err(NS_ERROR_DOM_INDEXEDDB_KEY_ERR);
|
||||
return Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
}
|
||||
|
||||
char* buffer;
|
||||
if (!mBuffer.GetMutableData(&buffer, size)) {
|
||||
if (!mBuffer.GetMutableData(&buffer, size.value())) {
|
||||
IDB_REPORT_INTERNAL_ERR();
|
||||
return Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
}
|
||||
|
@ -638,7 +634,7 @@ Result<Ok, nsresult> Key::EncodeAsString(const Span<const T> aInput,
|
|||
// the T==uint8_t resp. T==char16_t cases (for the char16_t case, copying
|
||||
// and then adjusting could even be slightly faster, but then we would need
|
||||
// another case distinction here)
|
||||
uint32_t inputLen = std::distance(inputRange.cbegin(), inputRange.cend());
|
||||
const auto inputLen = std::distance(inputRange.cbegin(), inputRange.cend());
|
||||
MOZ_ASSERT(inputLen == payloadSize);
|
||||
std::transform(inputRange.cbegin(), inputRange.cend(), buffer,
|
||||
[](auto value) { return value + ONE_BYTE_ADJUST; });
|
||||
|
|
|
@ -267,62 +267,58 @@ function* testSteps() {
|
|||
event = yield undefined;
|
||||
is(event.target.result, null, "no more results expected");
|
||||
|
||||
// Note that nan is defined below as '0 / 0'.
|
||||
var nan = 0 / 0;
|
||||
var invalidKeys = [
|
||||
"nan",
|
||||
"undefined",
|
||||
"null",
|
||||
"/x/",
|
||||
"{}",
|
||||
"new Date(NaN)",
|
||||
'new Date("foopy")',
|
||||
"[nan]",
|
||||
"[undefined]",
|
||||
"[null]",
|
||||
"[/x/]",
|
||||
"[{}]",
|
||||
"[new Date(NaN)]",
|
||||
"[1, nan]",
|
||||
"[1, undefined]",
|
||||
"[1, null]",
|
||||
"[1, /x/]",
|
||||
"[1, {}]",
|
||||
"[1, [nan]]",
|
||||
"[1, [undefined]]",
|
||||
"[1, [null]]",
|
||||
"[1, [/x/]]",
|
||||
"[1, [{}]]",
|
||||
"new Uint8Array(2147483647)",
|
||||
nan,
|
||||
undefined,
|
||||
null,
|
||||
/x/,
|
||||
{},
|
||||
new Date(NaN),
|
||||
new Date("foopy"),
|
||||
[nan],
|
||||
[undefined],
|
||||
[null],
|
||||
[/x/],
|
||||
[{}],
|
||||
[new Date(NaN)],
|
||||
[1, nan],
|
||||
[1, undefined],
|
||||
[1, null],
|
||||
[1, /x/],
|
||||
[1, {}],
|
||||
[1, [nan]],
|
||||
[1, [undefined]],
|
||||
[1, [null]],
|
||||
[1, [/x/]],
|
||||
[1, [{}]],
|
||||
];
|
||||
|
||||
function checkInvalidKeyException(ex, i, callText) {
|
||||
let suffix = ` during ${callText} with invalid key ${i}: ${invalidKeys[i]}`;
|
||||
let suffix = ` during ${callText} with invalid key ${i}: "${invalidKeys[i]}"`;
|
||||
ok(ex instanceof DOMException, "Threw DOMException" + suffix);
|
||||
is(ex.name, "DataError", "Threw right DOMException" + suffix);
|
||||
is(ex.code, 0, "Threw with right code" + suffix);
|
||||
}
|
||||
|
||||
for (i = 0; i < invalidKeys.length; ++i) {
|
||||
let key = Function(
|
||||
`"use strict"; var nan = 0 / 0; return (${invalidKeys[i]})`
|
||||
)();
|
||||
try {
|
||||
indexedDB.cmp(key, 1);
|
||||
indexedDB.cmp(invalidKeys[i], 1);
|
||||
ok(false, "didn't throw");
|
||||
} catch (ex) {
|
||||
checkInvalidKeyException(ex, i, "cmp(key, 1)");
|
||||
checkInvalidKeyException(ex, i, "cmp(invalidKeys[i], 1)");
|
||||
}
|
||||
try {
|
||||
indexedDB.cmp(1, key);
|
||||
indexedDB.cmp(1, invalidKeys[i]);
|
||||
ok(false, "didn't throw2");
|
||||
} catch (ex) {
|
||||
checkInvalidKeyException(ex, i, "cmp(1, key)");
|
||||
checkInvalidKeyException(ex, i, "cmp(1, invalidKeys[i])");
|
||||
}
|
||||
try {
|
||||
store.put(1, key);
|
||||
store.put(1, invalidKeys[i]);
|
||||
ok(false, "didn't throw3");
|
||||
} catch (ex) {
|
||||
checkInvalidKeyException(ex, i, "store.put(1, key)");
|
||||
checkInvalidKeyException(ex, i, "store.put(1, invalidKeys[i])");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ from __future__ import absolute_import
|
|||
|
||||
from threading import Lock
|
||||
import codecs
|
||||
import locale
|
||||
|
||||
from mozlog.structuredlog import log_levels
|
||||
import six
|
||||
|
@ -79,37 +78,16 @@ class StreamHandler(BaseHandler):
|
|||
import io
|
||||
import mozfile
|
||||
|
||||
source_enc = "utf-8"
|
||||
target_enc = "utf-8"
|
||||
if isinstance(self.stream, io.BytesIO):
|
||||
target_enc = self.stream.encoding
|
||||
if target_enc is None:
|
||||
target_enc = locale.getpreferredencoding()
|
||||
|
||||
if isinstance(self.stream, io.StringIO) and isinstance(
|
||||
formatted, bytes
|
||||
):
|
||||
formatted = formatted.decode(source_enc, "replace")
|
||||
formatted = formatted.decode()
|
||||
elif (
|
||||
isinstance(self.stream, io.BytesIO)
|
||||
or isinstance(self.stream, mozfile.NamedTemporaryFile)
|
||||
) and isinstance(formatted, str):
|
||||
formatted = formatted.encode(target_enc, "replace")
|
||||
elif isinstance(formatted, str):
|
||||
# Suppress eventual surrogates, but keep as string.
|
||||
# TODO: It is yet unclear how we can end up with
|
||||
# surrogates here, see comment on patch on bug 1794401.
|
||||
formatted_bin = formatted.encode(target_enc, "replace")
|
||||
formatted = formatted_bin.decode(target_enc, "ignore")
|
||||
|
||||
# It seems that under Windows we can have cp1252 encoding
|
||||
# for the output stream and that not all unicode chars map
|
||||
# well. We just ignore those errors here (they have no
|
||||
# consequences for the executed tests, anyways).
|
||||
try:
|
||||
self.stream.write(formatted)
|
||||
except (UnicodeEncodeError):
|
||||
return
|
||||
formatted = formatted.encode()
|
||||
self.stream.write(formatted)
|
||||
else:
|
||||
if isinstance(formatted, six.text_type):
|
||||
self.stream.write(formatted.encode("utf-8", "replace"))
|
||||
|
|
|
@ -710,10 +710,6 @@ class XPCShellTestThread(Thread):
|
|||
"""Parses a single line of output, determining its significance and
|
||||
reporting a message.
|
||||
"""
|
||||
if isinstance(line_string, bytes):
|
||||
# Transform binary to string representation
|
||||
line_string = line_string.decode(sys.stdout.encoding, errors="replace")
|
||||
|
||||
if not line_string.strip():
|
||||
return
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче