зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 401edab3831f - Bug 758273.
--HG-- extra : rebase_source : 8ce201cd3fe6a2d6405be2548927f65dab5cbb39
This commit is contained in:
Родитель
9acb961a0b
Коммит
fc28fe58ff
|
@ -16,7 +16,6 @@
|
||||||
#include "nsIPrincipal.h"
|
#include "nsIPrincipal.h"
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
#include "nsJSUtils.h"
|
#include "nsJSUtils.h"
|
||||||
#include "DictionaryHelpers.h"
|
|
||||||
|
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
|
|
||||||
|
@ -308,8 +307,7 @@ public:
|
||||||
nsDOMDeviceStorageCursor(nsIDOMWindow* aWindow,
|
nsDOMDeviceStorageCursor(nsIDOMWindow* aWindow,
|
||||||
nsIURI* aURI,
|
nsIURI* aURI,
|
||||||
DeviceStorageFile* aFile,
|
DeviceStorageFile* aFile,
|
||||||
bool aEditable,
|
bool aEditable);
|
||||||
PRUint64 aSince);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~nsDOMDeviceStorageCursor();
|
~nsDOMDeviceStorageCursor();
|
||||||
|
@ -321,7 +319,6 @@ protected:
|
||||||
nsRefPtr<DeviceStorageFile> mFile;
|
nsRefPtr<DeviceStorageFile> mFile;
|
||||||
nsCOMPtr<nsIURI> mURI;
|
nsCOMPtr<nsIURI> mURI;
|
||||||
bool mEditable;
|
bool mEditable;
|
||||||
PRUint64 mSince;
|
|
||||||
|
|
||||||
// to access mFiles
|
// to access mFiles
|
||||||
friend class InitCursorEvent;
|
friend class InitCursorEvent;
|
||||||
|
@ -511,15 +508,6 @@ public:
|
||||||
nsCOMPtr<nsIFile> f;
|
nsCOMPtr<nsIFile> f;
|
||||||
|
|
||||||
while (NS_SUCCEEDED(files->GetNextFile(getter_AddRefs(f))) && f) {
|
while (NS_SUCCEEDED(files->GetNextFile(getter_AddRefs(f))) && f) {
|
||||||
nsDOMDeviceStorageCursor* cursor = static_cast<nsDOMDeviceStorageCursor*>(mRequest.get());
|
|
||||||
|
|
||||||
PRInt64 msecs;
|
|
||||||
f->GetLastModifiedTime(&msecs);
|
|
||||||
|
|
||||||
if (msecs < (PRInt64) cursor->mSince) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isDir;
|
bool isDir;
|
||||||
f->IsDirectory(&isDir);
|
f->IsDirectory(&isDir);
|
||||||
|
|
||||||
|
@ -546,6 +534,7 @@ public:
|
||||||
collectFiles(dsf);
|
collectFiles(dsf);
|
||||||
}
|
}
|
||||||
else if (isFile) {
|
else if (isFile) {
|
||||||
|
nsDOMDeviceStorageCursor* cursor = static_cast<nsDOMDeviceStorageCursor*>(mRequest.get());
|
||||||
cursor->mFiles.AppendElement(dsf);
|
cursor->mFiles.AppendElement(dsf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -572,14 +561,12 @@ NS_IMPL_RELEASE_INHERITED(nsDOMDeviceStorageCursor, DOMRequest)
|
||||||
nsDOMDeviceStorageCursor::nsDOMDeviceStorageCursor(nsIDOMWindow* aWindow,
|
nsDOMDeviceStorageCursor::nsDOMDeviceStorageCursor(nsIDOMWindow* aWindow,
|
||||||
nsIURI* aURI,
|
nsIURI* aURI,
|
||||||
DeviceStorageFile* aFile,
|
DeviceStorageFile* aFile,
|
||||||
bool aEditable,
|
bool aEditable)
|
||||||
PRUint64 aSince)
|
|
||||||
: DOMRequest(aWindow)
|
: DOMRequest(aWindow)
|
||||||
, mOkToCallContinue(false)
|
, mOkToCallContinue(false)
|
||||||
, mFile(aFile)
|
, mFile(aFile)
|
||||||
, mURI(aURI)
|
, mURI(aURI)
|
||||||
, mEditable(aEditable)
|
, mEditable(aEditable)
|
||||||
, mSince(aSince)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1256,85 +1243,35 @@ nsDOMDeviceStorage::Delete(const JS::Value& aPath, JSContext* aCx, nsIDOMDOMRequ
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDOMDeviceStorage::Enumerate(const JS::Value& aName,
|
nsDOMDeviceStorage::Enumerate(const nsAString & aPath,
|
||||||
const JS::Value& aOptions,
|
nsIDOMDeviceStorageCursor * *_retval NS_OUTPARAM)
|
||||||
JSContext* aCx,
|
|
||||||
PRUint8 aArgc,
|
|
||||||
nsIDOMDeviceStorageCursor** aRetval)
|
|
||||||
{
|
{
|
||||||
return EnumerateInternal(aName, aOptions, aCx, aArgc, false, aRetval);
|
return EnumerateInternal(aPath, _retval, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDOMDeviceStorage::EnumerateEditable(const JS::Value& aName,
|
nsDOMDeviceStorage::EnumerateEditable(const nsAString & aPath,
|
||||||
const JS::Value& aOptions,
|
nsIDOMDeviceStorageCursor * *_retval NS_OUTPARAM)
|
||||||
JSContext* aCx,
|
|
||||||
PRUint8 aArgc,
|
|
||||||
nsIDOMDeviceStorageCursor** aRetval)
|
|
||||||
{
|
{
|
||||||
return EnumerateInternal(aName, aOptions, aCx, aArgc, true, aRetval);
|
return EnumerateInternal(aPath, _retval, true);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static PRTime
|
|
||||||
ExtractDateFromOptions(JSContext* aCx, const JS::Value& aOptions)
|
|
||||||
{
|
|
||||||
PRTime result = 0;
|
|
||||||
DeviceStorageEnumerationParameters params;
|
|
||||||
if (!JSVAL_IS_VOID(aOptions) && !aOptions.isNull()) {
|
|
||||||
nsresult rv = params.Init(aCx, &aOptions);
|
|
||||||
if (NS_SUCCEEDED(rv) && !JSVAL_IS_VOID(params.since) && !params.since.isNull() && params.since.isObject()) {
|
|
||||||
JSObject* obj = JSVAL_TO_OBJECT(params.since);
|
|
||||||
if (JS_ObjectIsDate(aCx, obj) && js_DateIsValid(aCx, obj)) {
|
|
||||||
result = js_DateGetMsecSinceEpoch(aCx, obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsDOMDeviceStorage::EnumerateInternal(const JS::Value& aName,
|
nsDOMDeviceStorage::EnumerateInternal(const nsAString & aPath,
|
||||||
const JS::Value& aOptions,
|
nsIDOMDeviceStorageCursor * *_retval NS_OUTPARAM,
|
||||||
JSContext* aCx,
|
bool aEditable)
|
||||||
PRUint8 aArgc,
|
|
||||||
bool aEditable,
|
|
||||||
nsIDOMDeviceStorageCursor** aRetval)
|
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryReferent(mOwner);
|
nsCOMPtr<nsPIDOMWindow> win = do_QueryReferent(mOwner);
|
||||||
if (!win)
|
if (!win)
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
PRTime since = 0;
|
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mFile, aPath);
|
||||||
nsString path;
|
|
||||||
path.SetIsVoid(true);
|
|
||||||
|
|
||||||
if (aArgc > 0) {
|
nsRefPtr<nsDOMDeviceStorageCursor> cursor = new nsDOMDeviceStorageCursor(win, mURI, dsf, aEditable);
|
||||||
// inspect the first value to see if it is a string
|
NS_ADDREF(*_retval = cursor);
|
||||||
if (JSVAL_IS_STRING(aName)) {
|
|
||||||
JSString* jsstr = JS_ValueToString(aCx, aName);
|
|
||||||
nsDependentJSString jspath;
|
|
||||||
jspath.init(aCx, jsstr);
|
|
||||||
path.Assign(jspath);
|
|
||||||
} else if (!JSVAL_IS_PRIMITIVE(aName)) {
|
|
||||||
// it also might be an options object
|
|
||||||
since = ExtractDateFromOptions(aCx, aName);
|
|
||||||
} else {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aArgc == 2 && (JSVAL_IS_VOID(aOptions) || aOptions.isNull() || !aOptions.isObject())) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
since = ExtractDateFromOptions(aCx, aOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mFile, path);
|
|
||||||
nsRefPtr<nsDOMDeviceStorageCursor> cursor = new nsDOMDeviceStorageCursor(win, mURI, dsf, aEditable, since);
|
|
||||||
nsRefPtr<DeviceStorageCursorRequest> r = new DeviceStorageCursorRequest(cursor);
|
nsRefPtr<DeviceStorageCursorRequest> r = new DeviceStorageCursorRequest(cursor);
|
||||||
|
|
||||||
NS_ADDREF(*aRetval = cursor);
|
|
||||||
|
|
||||||
if (mozilla::Preferences::GetBool("device.storage.prompt.testing", false)) {
|
if (mozilla::Preferences::GetBool("device.storage.prompt.testing", false)) {
|
||||||
r->Allow();
|
r->Allow();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -32,25 +32,14 @@ public:
|
||||||
|
|
||||||
PRInt32 SetRootFileForType(const nsAString& aType, const PRInt32 aIndex);
|
PRInt32 SetRootFileForType(const nsAString& aType, const PRInt32 aIndex);
|
||||||
|
|
||||||
static void CreateDeviceStoragesFor(nsPIDOMWindow* aWin,
|
static void CreateDeviceStoragesFor(nsPIDOMWindow* aWin, const nsAString &aType, nsIVariant** _retval);
|
||||||
const nsAString& aType,
|
|
||||||
nsIVariant** aRetval);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~nsDOMDeviceStorage();
|
~nsDOMDeviceStorage();
|
||||||
|
|
||||||
|
|
||||||
nsresult GetInternal(const JS::Value& aName,
|
nsresult GetInternal(const JS::Value & aName, JSContext* aCx, nsIDOMDOMRequest * *_retval NS_OUTPARAM, bool aEditable);
|
||||||
JSContext* aCx,
|
nsresult EnumerateInternal(const nsAString & aName, nsIDOMDeviceStorageCursor * *_retval NS_OUTPARAM, bool aEditable);
|
||||||
nsIDOMDOMRequest** aRetval,
|
|
||||||
bool aEditable);
|
|
||||||
|
|
||||||
nsresult EnumerateInternal(const JS::Value& aName,
|
|
||||||
const JS::Value& aOptions,
|
|
||||||
JSContext* aCx,
|
|
||||||
PRUint8 aArgc,
|
|
||||||
bool aEditable,
|
|
||||||
nsIDOMDeviceStorageCursor** aRetval);
|
|
||||||
|
|
||||||
PRInt32 mStorageType;
|
PRInt32 mStorageType;
|
||||||
nsCOMPtr<nsIFile> mFile;
|
nsCOMPtr<nsIFile> mFile;
|
||||||
|
|
|
@ -7,12 +7,7 @@ interface nsIDOMBlob;
|
||||||
interface nsIDOMDOMRequest;
|
interface nsIDOMDOMRequest;
|
||||||
interface nsIDOMDeviceStorageCursor;
|
interface nsIDOMDeviceStorageCursor;
|
||||||
|
|
||||||
dictionary DeviceStorageEnumerationParameters
|
[scriptable, uuid(05C0D0C8-D698-4CCD-899C-7198A33BD7EC)]
|
||||||
{
|
|
||||||
jsval since;
|
|
||||||
};
|
|
||||||
|
|
||||||
[scriptable, uuid(6cdf3d8e-4a9f-4582-9d99-769bf9922cfb)]
|
|
||||||
interface nsIDOMDeviceStorage : nsISupports
|
interface nsIDOMDeviceStorage : nsISupports
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -33,9 +28,7 @@ interface nsIDOMDeviceStorage : nsISupports
|
||||||
[implicit_jscontext]
|
[implicit_jscontext]
|
||||||
nsIDOMDOMRequest delete(in jsval aName);
|
nsIDOMDOMRequest delete(in jsval aName);
|
||||||
|
|
||||||
[optional_argc, implicit_jscontext]
|
nsIDOMDeviceStorageCursor enumerate([optional] in DOMString directory);
|
||||||
nsIDOMDeviceStorageCursor enumerate([optional] in jsval aName, /* DeviceStorageEnumerationParameters */ [optional] in jsval options);
|
|
||||||
|
|
||||||
[optional_argc, implicit_jscontext]
|
nsIDOMDeviceStorageCursor enumerateEditable([optional] in DOMString directory);
|
||||||
nsIDOMDeviceStorageCursor enumerateEditable([optional] in jsval aName, /* DeviceStorageEnumerationParameters */ [optional] in jsval options);
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,8 +19,6 @@ _TEST_FILES = \
|
||||||
test_enumerateMultipleContinue.html \
|
test_enumerateMultipleContinue.html \
|
||||||
test_overwrite.html \
|
test_overwrite.html \
|
||||||
test_dotdot.html \
|
test_dotdot.html \
|
||||||
test_enumerateOptions.html \
|
|
||||||
test_lastModificationFilter.html \
|
|
||||||
devicestorage_common.js \
|
devicestorage_common.js \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,6 @@
|
||||||
|
|
||||||
var oldVal = false;
|
var oldVal = false;
|
||||||
|
|
||||||
// Array Remove - By John Resig (MIT Licensed)
|
|
||||||
Array.prototype.remove = function(from, to) {
|
|
||||||
var rest = this.slice((to || from) + 1 || this.length);
|
|
||||||
this.length = from < 0 ? this.length + from : from;
|
|
||||||
return this.push.apply(this, rest);
|
|
||||||
};
|
|
||||||
|
|
||||||
function devicestorage_setup() {
|
function devicestorage_setup() {
|
||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
try {
|
try {
|
||||||
|
@ -53,7 +46,3 @@ function randomFilename(l) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function reportErrorAndQuit(e) {
|
|
||||||
ok(false, "handleError was called : " + e.target.error.name);
|
|
||||||
devicestorage_cleanup();
|
|
||||||
}
|
|
||||||
|
|
|
@ -22,16 +22,27 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=717103
|
||||||
<pre id="test">
|
<pre id="test">
|
||||||
<script class="testbody" type="text/javascript">
|
<script class="testbody" type="text/javascript">
|
||||||
|
|
||||||
|
// Array Remove - By John Resig (MIT Licensed)
|
||||||
|
Array.prototype.remove = function(from, to) {
|
||||||
|
var rest = this.slice((to || from) + 1 || this.length);
|
||||||
|
this.length = from < 0 ? this.length + from : from;
|
||||||
|
return this.push.apply(this, rest);
|
||||||
|
};
|
||||||
|
|
||||||
devicestorage_setup();
|
devicestorage_setup();
|
||||||
|
|
||||||
function enumerateSuccess(e) {
|
function enumerateSuccess(e) {
|
||||||
|
|
||||||
if (e.target.result == null) {
|
if (e.target.result == null) {
|
||||||
ok(files.length == 0, "when the enumeration is done, we shouldn't have any files in this array")
|
ok(files.length == 0, "when the enumeration is done, we shouldn't have any files in this array")
|
||||||
|
dump("We still have length = " + files.length);
|
||||||
devicestorage_cleanup();
|
devicestorage_cleanup();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dump("asdfasdf"+ e.target.result + "\n");
|
||||||
|
dump("asdfasdf"+ e.target.result.name + "\n");
|
||||||
|
|
||||||
var filename = e.target.result.name;
|
var filename = e.target.result.name;
|
||||||
|
|
||||||
var index = files.indexOf(filename);
|
var index = files.indexOf(filename);
|
||||||
|
|
|
@ -1,81 +0,0 @@
|
||||||
<!--
|
|
||||||
Any copyright is dedicated to the Public Domain.
|
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/
|
|
||||||
-->
|
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<!--
|
|
||||||
https://bugzilla.mozilla.org/show_bug.cgi?id=717103
|
|
||||||
-->
|
|
||||||
<head>
|
|
||||||
<title>Test for basic sanity of the device storage API </title>
|
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
||||||
<script type="text/javascript" src="devicestorage_common.js"></script>
|
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
|
|
||||||
<p id="display"></p>
|
|
||||||
<div id="content" style="display: none">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<pre id="test">
|
|
||||||
<script class="testbody" type="text/javascript">
|
|
||||||
|
|
||||||
devicestorage_setup()
|
|
||||||
|
|
||||||
storage = navigator.getDeviceStorage("profile");
|
|
||||||
|
|
||||||
|
|
||||||
throws = false;
|
|
||||||
try {
|
|
||||||
var cursor = storage[0].enumerate();
|
|
||||||
} catch(e) {throws = true}
|
|
||||||
ok(!throws, "enumerate no parameter");
|
|
||||||
|
|
||||||
throws = false;
|
|
||||||
try {
|
|
||||||
var cursor = storage[0].enumerate("string");
|
|
||||||
} catch(e) {throws = true}
|
|
||||||
ok(!throws, "enumerate one string parameter");
|
|
||||||
|
|
||||||
throws = false;
|
|
||||||
try {
|
|
||||||
var cursor = storage[0].enumerate("string", "string2");
|
|
||||||
} catch(e) {throws = true}
|
|
||||||
ok(throws, "enumerate two string parameter");
|
|
||||||
|
|
||||||
throws = false;
|
|
||||||
try {
|
|
||||||
var cursor = storage[0].enumerate("string", {"since": 1});
|
|
||||||
} catch(e) {throws = true}
|
|
||||||
ok(!throws, "enumerate a string and object parameter");
|
|
||||||
|
|
||||||
throws = false;
|
|
||||||
try {
|
|
||||||
var cursor = storage[0].enumerate({"path": "a"});
|
|
||||||
} catch(e) {throws = true}
|
|
||||||
ok(!throws, "enumerate object parameter with path");
|
|
||||||
|
|
||||||
throws = false;
|
|
||||||
try {
|
|
||||||
var cursor = storage[0].enumerate({}, "string");
|
|
||||||
} catch(e) {throws = true}
|
|
||||||
ok(throws, "enumerate object then a string");
|
|
||||||
|
|
||||||
throws = false;
|
|
||||||
try {
|
|
||||||
var cursor = storage[0].enumerate({"path": "a", "since": 0});
|
|
||||||
} catch(e) {throws = true}
|
|
||||||
ok(!throws, "enumerate object parameter with path");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
devicestorage_cleanup()
|
|
||||||
</script>
|
|
||||||
</pre>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
|
@ -1,111 +0,0 @@
|
||||||
<!--
|
|
||||||
Any copyright is dedicated to the Public Domain.
|
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/
|
|
||||||
-->
|
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html> <!--
|
|
||||||
https://bugzilla.mozilla.org/show_bug.cgi?id=717103
|
|
||||||
-->
|
|
||||||
<head>
|
|
||||||
<title>Test for the device storage API </title>
|
|
||||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
||||||
<script type="text/javascript" src="devicestorage_common.js"></script>
|
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
|
|
||||||
<p id="display"></p>
|
|
||||||
<div id="content" style="display: none">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<pre id="test">
|
|
||||||
<script class="testbody" type="text/javascript">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function verifyAndDelete(prefix, files, e) {
|
|
||||||
|
|
||||||
if (e.target.result == null) {
|
|
||||||
ok(files.length == 0, "when the enumeration is done, we shouldn't have any files in this array")
|
|
||||||
dump("We still have length = " + files.length + "\n");
|
|
||||||
dump(files + "\n");
|
|
||||||
devicestorage_cleanup();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var filename = e.target.result.name;
|
|
||||||
|
|
||||||
var index = files.indexOf(filename);
|
|
||||||
ok(index > -1, "filename should be in the enumeration : " + e.target.result.name);
|
|
||||||
if (index == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
files.remove(index);
|
|
||||||
|
|
||||||
// clean up
|
|
||||||
var storage = navigator.getDeviceStorage("profile");
|
|
||||||
var cleanup = storage[0].delete(prefix + "/" + filename);
|
|
||||||
cleanup.onsuccess = function(e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
function addFiles(prefix, files, date, callback) {
|
|
||||||
|
|
||||||
const Cc = SpecialPowers.wrap(Components).classes;
|
|
||||||
const Ci = Components.interfaces;
|
|
||||||
|
|
||||||
var directoryService = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
|
|
||||||
|
|
||||||
for (var i=0; i<files.length; i++) {
|
|
||||||
var f = directoryService.get("ProfD", Components.interfaces.nsIFile);
|
|
||||||
var path = prefix + '/' + files[i];
|
|
||||||
path.split("/").forEach(function(p) {
|
|
||||||
f.appendRelativePath(p);
|
|
||||||
});
|
|
||||||
f.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0644);
|
|
||||||
f.lastModifiedTime = date;
|
|
||||||
}
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
devicestorage_setup();
|
|
||||||
|
|
||||||
var prefix = "devicestorage/" + randomFilename(12)
|
|
||||||
|
|
||||||
var oldFiles = ["a", "b", "c"];
|
|
||||||
var newFiles = ["d", "e", "f"];
|
|
||||||
|
|
||||||
// 157795200 is a long long time ago.
|
|
||||||
addFiles(prefix, oldFiles, 157795200, addNewFiles);
|
|
||||||
|
|
||||||
function enumerateNew() {
|
|
||||||
|
|
||||||
var storage = navigator.getDeviceStorage("profile");
|
|
||||||
ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
|
|
||||||
|
|
||||||
// 836031600 is a long time ago
|
|
||||||
var cursor = storage[0].enumerate(prefix, {"since": new Date(836031600)});
|
|
||||||
cursor.onsuccess = function(e) {
|
|
||||||
verifyAndDelete(prefix, newFiles, e);
|
|
||||||
if (e.target.result) {
|
|
||||||
e.target.continue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cursor.onerror = function (e) {
|
|
||||||
ok(false, "handleError was called : " + e.target.error.name);
|
|
||||||
devicestorage_cleanup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function addNewFiles() {
|
|
||||||
addFiles(prefix, newFiles, Date.now(), enumerateNew);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</pre>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ dictionaries = [
|
||||||
[ 'DeviceLightEventInit', 'nsIDOMDeviceLightEvent.idl' ],
|
[ 'DeviceLightEventInit', 'nsIDOMDeviceLightEvent.idl' ],
|
||||||
[ 'DOMFileMetadataParameters', 'nsIDOMLockedFile.idl' ],
|
[ 'DOMFileMetadataParameters', 'nsIDOMLockedFile.idl' ],
|
||||||
[ 'XMLHttpRequestParameters', 'nsIXMLHttpRequest.idl' ],
|
[ 'XMLHttpRequestParameters', 'nsIXMLHttpRequest.idl' ],
|
||||||
[ 'DeviceStorageEnumerationParameters', 'nsIDOMDeviceStorage.idl' ]
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# include file names
|
# include file names
|
||||||
|
|
Загрузка…
Ссылка в новой задаче