Backed out 302400cbd111 (bug 754350) and 9aa942155c05 (bug 791816) for Windows mochitest-2 orange.

This commit is contained in:
Ryan VanderMeulen 2012-10-13 13:20:55 -04:00
parent f0d30acf35
commit f6d225c895
7 changed files with 75 additions and 47 deletions

View File

@ -248,14 +248,6 @@ DeviceStorageRequestParent::WriteFileEvent::CancelableRun()
return NS_OK;
}
bool check = false;
mFile->mFile->Exists(&check);
if (check) {
nsCOMPtr<PostErrorEvent> event = new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_EXISTS);
NS_DispatchToMainThread(event);
return NS_OK;
}
nsresult rv = mFile->Write(mInputStream);
if (NS_FAILED(rv)) {

View File

@ -851,20 +851,44 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
class PostErrorEvent : public nsRunnable
{
public:
PostErrorEvent(nsRefPtr<DOMRequest>& aRequest, const char* aMessage)
PostErrorEvent(nsRefPtr<DOMRequest>& aRequest, const char* aMessage, DeviceStorageFile* aFile)
{
mRequest.swap(aRequest);
CopyASCIItoUTF16(aMessage, mError);
BuildErrorString(aMessage, aFile);
}
PostErrorEvent(DOMRequest* aRequest, const char* aMessage)
PostErrorEvent(DOMRequest* aRequest, const char* aMessage, DeviceStorageFile* aFile)
: mRequest(aRequest)
{
CopyASCIItoUTF16(aMessage, mError);
BuildErrorString(aMessage, aFile);
}
~PostErrorEvent() {}
void BuildErrorString(const char* aMessage, DeviceStorageFile* aFile)
{
nsAutoString fullPath;
if (aFile && aFile->mFile) {
aFile->mFile->GetPath(fullPath);
}
else {
fullPath.Assign(NS_LITERAL_STRING("null file"));
}
mError = NS_ConvertASCIItoUTF16(aMessage);
mError.Append(NS_LITERAL_STRING(" file path = "));
mError.Append(fullPath.get());
mError.Append(NS_LITERAL_STRING(" path = "));
if (aFile) {
mError.Append(aFile->mPath);
}
else {
mError.Append(NS_LITERAL_STRING("null path"));
}
}
NS_IMETHOD Run()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -982,7 +1006,9 @@ public:
bool check;
mFile->mFile->IsDirectory(&check);
if (!check) {
nsCOMPtr<PostErrorEvent> event = new PostErrorEvent(mRequest, POST_ERROR_EVENT_FILE_NOT_ENUMERABLE);
nsCOMPtr<PostErrorEvent> event = new PostErrorEvent(mRequest,
POST_ERROR_EVENT_FILE_NOT_ENUMERABLE,
mFile);
NS_DispatchToMainThread(event);
return NS_OK;
}
@ -1067,7 +1093,9 @@ nsDOMDeviceStorageCursor::GetElement(nsIDOMElement * *aRequestingElement)
NS_IMETHODIMP
nsDOMDeviceStorageCursor::Cancel()
{
nsCOMPtr<PostErrorEvent> event = new PostErrorEvent(this, POST_ERROR_EVENT_PERMISSION_DENIED);
nsCOMPtr<PostErrorEvent> event = new PostErrorEvent(this,
POST_ERROR_EVENT_PERMISSION_DENIED,
mFile);
NS_DispatchToMainThread(event);
return NS_OK;
}
@ -1076,7 +1104,9 @@ NS_IMETHODIMP
nsDOMDeviceStorageCursor::Allow()
{
if (!mFile->IsSafePath()) {
nsCOMPtr<nsIRunnable> r = new PostErrorEvent(this, POST_ERROR_EVENT_PERMISSION_DENIED);
nsCOMPtr<nsIRunnable> r = new PostErrorEvent(this,
POST_ERROR_EVENT_ILLEGAL_FILE_NAME,
mFile);
NS_DispatchToMainThread(r);
return NS_OK;
}
@ -1255,20 +1285,14 @@ public:
nsCOMPtr<nsIInputStream> stream;
mBlob->GetInternalStream(getter_AddRefs(stream));
bool check = false;
mFile->mFile->Exists(&check);
if (check) {
nsCOMPtr<PostErrorEvent> event = new PostErrorEvent(mRequest, POST_ERROR_EVENT_FILE_EXISTS);
NS_DispatchToMainThread(event);
return NS_OK;
}
nsresult rv = mFile->Write(stream);
if (NS_FAILED(rv)) {
mFile->mFile->Remove(false);
nsCOMPtr<PostErrorEvent> event = new PostErrorEvent(mRequest, POST_ERROR_EVENT_UNKNOWN);
nsCOMPtr<PostErrorEvent> event = new PostErrorEvent(mRequest,
POST_ERROR_EVENT_UNKNOWN,
mFile);
NS_DispatchToMainThread(event);
return NS_OK;
}
@ -1305,7 +1329,7 @@ public:
bool check = false;
mFile->mFile->Exists(&check);
if (!check) {
r = new PostErrorEvent(mRequest, POST_ERROR_EVENT_FILE_DOES_NOT_EXIST);
r = new PostErrorEvent(mRequest, POST_ERROR_EVENT_FILE_DOES_NOT_EXIST, mFile);
}
}
@ -1342,7 +1366,7 @@ public:
bool check = false;
mFile->mFile->Exists(&check);
if (check) {
r = new PostErrorEvent(mRequest, POST_ERROR_EVENT_FILE_DOES_NOT_EXIST);
r = new PostErrorEvent(mRequest, POST_ERROR_EVENT_FILE_DOES_NOT_EXIST, mFile);
}
else {
r = new PostResultEvent(mRequest, mFile->mPath);
@ -1503,7 +1527,9 @@ public:
NS_IMETHOD Cancel()
{
nsCOMPtr<PostErrorEvent> event = new PostErrorEvent(mRequest, POST_ERROR_EVENT_PERMISSION_DENIED);
nsCOMPtr<PostErrorEvent> event = new PostErrorEvent(mRequest,
POST_ERROR_EVENT_PERMISSION_DENIED,
mFile);
NS_DispatchToMainThread(event);
return NS_OK;
}
@ -1813,10 +1839,10 @@ nsDOMDeviceStorage::AddNamed(nsIDOMBlob *aBlob,
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, mRootDirectory, aPath);
if (!typeChecker->Check(mStorageType, dsf->mFile) ||
!typeChecker->Check(mStorageType, aBlob)) {
r = new PostErrorEvent(request, POST_ERROR_EVENT_ILLEGAL_TYPE);
r = new PostErrorEvent(request, POST_ERROR_EVENT_ILLEGAL_TYPE, dsf);
}
else if (!dsf->IsSafePath()) {
r = new PostErrorEvent(request, POST_ERROR_EVENT_PERMISSION_DENIED);
r = new PostErrorEvent(request, POST_ERROR_EVENT_ILLEGAL_FILE_NAME, dsf);
}
else {
r = new DeviceStorageRequest(DeviceStorageRequest::DEVICE_STORAGE_REQUEST_WRITE,
@ -1862,7 +1888,10 @@ nsDOMDeviceStorage::GetInternal(const JS::Value & aPath,
JSString* jsstr = JS_ValueToString(aCx, aPath);
nsDependentJSString path;
if (!path.init(aCx, jsstr)) {
r = new PostErrorEvent(request, POST_ERROR_EVENT_UNKNOWN);
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, mRootDirectory);
r = new PostErrorEvent(request,
POST_ERROR_EVENT_NON_STRING_TYPE_UNSUPPORTED,
dsf);
NS_DispatchToMainThread(r);
return NS_OK;
}
@ -1870,7 +1899,7 @@ nsDOMDeviceStorage::GetInternal(const JS::Value & aPath,
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, mRootDirectory, path);
dsf->SetEditable(aEditable);
if (!dsf->IsSafePath()) {
r = new PostErrorEvent(request, POST_ERROR_EVENT_PERMISSION_DENIED);
r = new PostErrorEvent(request, POST_ERROR_EVENT_ILLEGAL_FILE_NAME, dsf);
} else {
r = new DeviceStorageRequest(DeviceStorageRequest::DEVICE_STORAGE_REQUEST_READ,
win, mPrincipal, dsf, request);
@ -1895,7 +1924,8 @@ nsDOMDeviceStorage::Delete(const JS::Value & aPath, JSContext* aCx, nsIDOMDOMReq
JSString* jsstr = JS_ValueToString(aCx, aPath);
nsDependentJSString path;
if (!path.init(aCx, jsstr)) {
r = new PostErrorEvent(request, POST_ERROR_EVENT_UNKNOWN);
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, mRootDirectory);
r = new PostErrorEvent(request, POST_ERROR_EVENT_NON_STRING_TYPE_UNSUPPORTED, dsf);
NS_DispatchToMainThread(r);
return NS_OK;
}
@ -1903,7 +1933,7 @@ nsDOMDeviceStorage::Delete(const JS::Value & aPath, JSContext* aCx, nsIDOMDOMReq
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, mRootDirectory, path);
if (!dsf->IsSafePath()) {
r = new PostErrorEvent(request, POST_ERROR_EVENT_PERMISSION_DENIED);
r = new PostErrorEvent(request, POST_ERROR_EVENT_ILLEGAL_FILE_NAME, dsf);
}
else {
r = new DeviceStorageRequest(DeviceStorageRequest::DEVICE_STORAGE_REQUEST_DELETE,

View File

@ -32,12 +32,14 @@ class nsPIDOMWindow;
#include "DeviceStorageRequestChild.h"
#define POST_ERROR_EVENT_FILE_EXISTS "NoModificationAllowedError"
#define POST_ERROR_EVENT_FILE_DOES_NOT_EXIST "NotFoundError"
#define POST_ERROR_EVENT_FILE_NOT_ENUMERABLE "TypeMismatchError"
#define POST_ERROR_EVENT_PERMISSION_DENIED "SecurityError"
#define POST_ERROR_EVENT_ILLEGAL_TYPE "TypeMismatchError"
#define POST_ERROR_EVENT_FILE_DOES_NOT_EXIST "File location doesn't exists"
#define POST_ERROR_EVENT_FILE_NOT_ENUMERABLE "File location is not enumerable"
#define POST_ERROR_EVENT_PERMISSION_DENIED "Permission Denied"
#define POST_ERROR_EVENT_ILLEGAL_FILE_NAME "Illegal file name"
#define POST_ERROR_EVENT_ILLEGAL_TYPE "Illegal content type"
#define POST_ERROR_EVENT_UNKNOWN "Unknown"
#define POST_ERROR_EVENT_NON_STRING_TYPE_UNSUPPORTED "Non-string type unsupported"
#define POST_ERROR_EVENT_NOT_IMPLEMENTED "Not implemented"
using namespace mozilla;
using namespace mozilla::dom;

View File

@ -43,8 +43,6 @@ var tests = [
function fail(e) {
ok(false, "addSuccess was called");
ok(e.target.error.name == "TypeMismatchError", "Error must be TypeMismatchError");
devicestorage_cleanup();
}

View File

@ -13,7 +13,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=717103
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<body onunload="unload()">
<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">
@ -22,6 +22,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=717103
<pre id="test">
<script class="testbody" type="text/javascript">
function unload() {
delete gDataBlob;
gDataBlob = null;
delete gFileReader;
gFileReader = null;
}
devicestorage_setup();
var gFileName = "devicestorage/hi.png";

View File

@ -45,11 +45,9 @@ function fail(e) {
function next(e) {
if (e != undefined) {
ok(true, "addError was called");
ok(e.target.error.name == "SecurityError", "Error must be SecurityError");
}
if (e != undefined)
ok(true, "addError was called");
var f = tests.pop();
if (f == undefined) {

View File

@ -44,7 +44,6 @@ function addOverwritingSuccess(e) {
function addOverwritingError(e) {
ok(true, "Adding to the same location should fail");
ok(e.target.error.name == "NoModificationAllowedError", "Error must be NoModificationAllowedError");
var storage = navigator.getDeviceStorage("pictures");
request = storage.delete(filename)