From 652dbf289b1812d315a6eaa4f2b818b0b8adccd2 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Fri, 22 Nov 2013 14:04:17 -0500 Subject: [PATCH] Backed out changeset b421a1fcd9c0 (bug 901456) for landing with the wrong bug number. --- .../test/test_lastModificationFilter.html | 96 +++++++--------------- 1 file changed, 31 insertions(+), 65 deletions(-) diff --git a/dom/devicestorage/test/test_lastModificationFilter.html b/dom/devicestorage/test/test_lastModificationFilter.html index c62580c8ecf6..fb225f1180ff 100644 --- a/dom/devicestorage/test/test_lastModificationFilter.html +++ b/dom/devicestorage/test/test_lastModificationFilter.html @@ -25,14 +25,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=717103 devicestorage_setup(); var oldFiles = ["a.png", "b.png", "c.png"]; -var timeFile = "t.png"; var newFiles = ["d.png", "e.png", "f.png"]; var storage = navigator.getDeviceStorage('pictures'); var prefix = "devicestorage/" + randomFilename(12); +var callback; +var files; var i; var timestamp; -var lastFileAddedTimestamp; function verifyAndDelete(prefix, files, e) { if (e.target.result == null) { @@ -62,56 +62,31 @@ function verifyAndDelete(prefix, files, e) { if (index == -1) return; - files.splice(index, 1); + files.remove(index); // clean up var cleanup = storage.delete(e.target.result.name); cleanup.onsuccess = function(e) {} } -function addFile(filename, callback) { - var addReq = storage.addNamed(createRandomBlob('image/png'), prefix + '/' + filename); - addReq.onsuccess = function(e) { - // After adding the file, we go ahead and grab the timestamp of the file - // that we just added - var getReq = storage.get(prefix + '/' + filename); - getReq.onsuccess = function(e) { - lastFileAddedTimestamp = e.target.result.lastModifiedDate; - callback(); - } - getReq.onerror = function(e) { - ok(false, "getError was called : " + e.target.error.name); - devicestorage_cleanup(); - }; - } - addReq.onerror = function(e) { - ok(false, "addError was called : " + e.target.error.name); - devicestorage_cleanup(); +function addSuccess(e) { + i = i + 1; + if (i == files.length) { + callback(); + return; } + addFile(files[i]); } -function addFileArray(fileArray, callback) { - var i = 0; - function addNextFile() { - i = i + 1; - if (i == fileArray.length) { - callback(); - return; - } - addFile(fileArray[i], addNextFile); - } - addFile(fileArray[0], addNextFile); +function addError(e) { + ok(false, "addError was called : " + e.target.error.name); + devicestorage_cleanup(); } -function delFile(filename, callback) { - var req = storage.delete(prefix + '/' + filename); - req.onsuccess = function(e) { - callback(); - }; - req.onerror = function(e) { - ok(false, "delError was called : " + e.target.error.name); - devicestorage_cleanup(); - }; +function addFile(filename){ + var req = storage.addNamed(createRandomBlob('image/png'), prefix + '/' + files[i]); + req.onsuccess = addSuccess; + req.onerror = addError; } function afterNewFiles() { @@ -128,36 +103,27 @@ function afterNewFiles() { }; } -function waitForTimestampChange() { - // We've added a new file. See if the timestamp differs from - // oldFileAddedTimestamp, and if it's the same wait for a bit - // and try again. - if (lastFileAddedTimestamp.valueOf() === timestamp.valueOf()) { - delFile(timeFile, function() { - setTimeout(function() { - addFile(timeFile, waitForTimestampChange); - }, 1000); - }); - } else { - timestamp = lastFileAddedTimestamp; - // The timestamp has changed. Go ahead and add the rest of the new files - delFile(timeFile, function() { - addFileArray(newFiles, afterNewFiles); - }); - } +function addNewFiles() { + i = 0; + files = newFiles; + callback = afterNewFiles; + addFile(files[0]); +} + +function beforeNewFiles() { + timestamp = new Date(); + setTimeout(addNewFiles, 1000); } function afterOldFiles() { - timestamp = lastFileAddedTimestamp; - setTimeout(function() { - // We've added our old files and waited for a second. - // Add a new file until the timestamp changes - addFile(timeFile, waitForTimestampChange); - }, 1000); + setTimeout(beforeNewFiles, 1000); } function addOldFiles() { - addFileArray(oldFiles, afterOldFiles); + i = 0; + files = oldFiles; + callback = afterOldFiles; + addFile(files[0]); } addOldFiles(); -- 2.11.4.GIT