Bug 1505821 - DeserializeFromString should append an empty string for a trailing comma r=asuth

KeyPath [..., ''] will be serialized to have a trailing comma, when deserializing it, we should
append back the empty string. Otherwise we will get inconsistent result with the KeyPath::Parse() method, causing assertions failure.

Differential Revision: https://phabricator.services.mozilla.com/D24724

--HG--
extra : moz-landing-system : lando
This commit is contained in:
violet 2019-04-17 12:52:46 +00:00
Родитель 401be41334
Коммит 0a2e5d2dc2
4 изменённых файлов: 26 добавлений и 1 удалений

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

@ -466,6 +466,13 @@ KeyPath KeyPath::DeserializeFromString(const nsAString& aString) {
keyPath.mStrings.AppendElement(tokenizer.nextToken());
}
if (tokenizer.separatorAfterCurrentToken()) {
// There is a trailing comma, indicating the original KeyPath has
// a trailing empty string, i.e. [..., '']. We should append this
// empty string.
keyPath.mStrings.AppendElement(nsString{});
}
return keyPath;
}

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

@ -0,0 +1,16 @@
<script>
const dbRequest = window.indexedDB.open('bug1505821_1_hello');
dbRequest.onupgradeneeded = function (event) {
const store = event.target.result.createObjectStore('IDBStore_1', {autoIncrement: true});
store.createIndex('I', [''], {unique: true});
store.createIndex('J', ['a', ''], {unique: true});
store.createIndex('M', ['', 'a'], {unique: true});
store.createIndex('K', ['', 'a', ''], {unique: true});
store.createIndex('L', ['', '', ''], {unique: true});
}
const dbRequest2 = window.indexedDB.open('bug1505821_1_hello');
dbRequest.onsuccess = function (event) {
window.indexedDB.deleteDatabase("bug1507229_1_hello");
}
</script>

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

@ -1,5 +1,6 @@
<script>
window.indexedDB.open("hello").onsuccess = function(event) {
window.indexedDB.open("bug1507229_1_hello").onsuccess = function(event) {
event.target.result.createMutableFile("");
window.indexedDB.deleteDatabase("bug1507229_1_hello");
}
</script>

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

@ -1,2 +1,3 @@
load 726376-1.html
load 1505821-1.html
load 1507229-1.html