Backout 81a090e983d2, 8236b3579bf3,

This commit is contained in:
Wes Johnston 2012-08-07 10:08:41 -07:00
Родитель 209e77bb97
Коммит f73e753770
9 изменённых файлов: 41 добавлений и 74 удалений

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

@ -58,14 +58,6 @@ WebappsRegistry.prototype = {
mgmt: 'r'
},
/* Fires errors on the request object. Also fires a notification if preventDefault was
* not called on the event
*/
_fireError: function fireError(aRequest, aError, aTopic) {
if (!Services.DOMRequest.fireError(aRequest, aError))
Services.obs.notifyObservers(this, aTopic, aError);
},
/** from https://developer.mozilla.org/en/OpenWebApps/The_Manifest
* only the name property is mandatory
*/
@ -95,7 +87,7 @@ WebappsRegistry.prototype = {
app.installOrigin, app.installTime));
break;
case "Webapps:Install:Return:KO":
this._fireError(req, msg.error || "DENIED", "webapps-install-error");
Services.DOMRequest.fireError(req, msg.error || "DENIED");
break;
case "Webapps:GetSelf:Return:OK":
if (msg.apps.length) {
@ -140,7 +132,7 @@ WebappsRegistry.prototype = {
try {
let manifest = JSON.parse(xhr.responseText, installOrigin);
if (!this.checkManifest(manifest, installOrigin)) {
this._fireError(request, "INVALID_MANIFEST", "webapps-install-error");
Services.DOMRequest.fireError(request, "INVALID_MANIFEST");
} else {
let receipts = (aParams && aParams.receipts && Array.isArray(aParams.receipts)) ? aParams.receipts : [];
let categories = (aParams && aParams.categories && Array.isArray(aParams.categories)) ? aParams.categories : [];
@ -155,16 +147,16 @@ WebappsRegistry.prototype = {
requestID: requestID });
}
} catch(e) {
this._fireError(request, "MANIFEST_PARSE_ERROR", "webapps-install-error");
Services.DOMRequest.fireError(request, "MANIFEST_PARSE_ERROR");
}
}
else {
this._fireError(request, "MANIFEST_URL_ERROR", "webapps-install-error");
Services.DOMRequest.fireError(request, "MANIFEST_URL_ERROR");
}
}).bind(this), false);
xhr.addEventListener("error", (function() {
this._fireError(request, "NETWORK_ERROR", "webapps-install-error");
Services.DOMRequest.fireError(request, "NETWORK_ERROR");
}).bind(this), false);
xhr.send(null);

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

@ -112,7 +112,7 @@ DOMRequest::GetError(nsIDOMDOMError** aError)
}
void
DOMRequest::FireSuccess(jsval aResult, bool* aDefaultActionEnabled)
DOMRequest::FireSuccess(jsval aResult)
{
NS_ASSERTION(!mDone, "mDone shouldn't have been set to true already!");
NS_ASSERTION(!mError, "mError shouldn't have been set!");
@ -124,11 +124,11 @@ DOMRequest::FireSuccess(jsval aResult, bool* aDefaultActionEnabled)
}
mResult = aResult;
FireEvent(NS_LITERAL_STRING("success"), false, false, aDefaultActionEnabled);
FireEvent(NS_LITERAL_STRING("success"), false, false);
}
void
DOMRequest::FireError(const nsAString& aError, bool* aDefaultActionEnabled)
DOMRequest::FireError(const nsAString& aError)
{
NS_ASSERTION(!mDone, "mDone shouldn't have been set to true already!");
NS_ASSERTION(!mError, "mError shouldn't have been set!");
@ -137,11 +137,11 @@ DOMRequest::FireError(const nsAString& aError, bool* aDefaultActionEnabled)
mDone = true;
mError = DOMError::CreateWithName(aError);
FireEvent(NS_LITERAL_STRING("error"), true, true, aDefaultActionEnabled);
FireEvent(NS_LITERAL_STRING("error"), true, true);
}
void
DOMRequest::FireError(nsresult aError, bool* aDefaultActionEnabled)
DOMRequest::FireError(nsresult aError)
{
NS_ASSERTION(!mDone, "mDone shouldn't have been set to true already!");
NS_ASSERTION(!mError, "mError shouldn't have been set!");
@ -150,12 +150,11 @@ DOMRequest::FireError(nsresult aError, bool* aDefaultActionEnabled)
mDone = true;
mError = DOMError::CreateForNSResult(aError);
FireEvent(NS_LITERAL_STRING("error"), true, true, aDefaultActionEnabled);
FireEvent(NS_LITERAL_STRING("error"), true, true);
}
void
DOMRequest::FireEvent(const nsAString& aType, bool aBubble, bool aCancelable,
bool* aDefaultActionEnabled)
DOMRequest::FireEvent(const nsAString& aType, bool aBubble, bool aCancelable)
{
if (NS_FAILED(CheckInnerWindowCorrectness())) {
return;
@ -172,7 +171,8 @@ DOMRequest::FireEvent(const nsAString& aType, bool aBubble, bool aCancelable,
return;
}
DispatchEvent(event, aDefaultActionEnabled);
bool dummy;
DispatchEvent(event, &dummy);
}
void
@ -205,24 +205,20 @@ DOMRequestService::CreateRequest(nsIDOMWindow* aWindow,
NS_IMETHODIMP
DOMRequestService::FireSuccess(nsIDOMDOMRequest* aRequest,
const jsval& aResult,
bool* aDefaultActionEnabled)
const jsval& aResult)
{
NS_ENSURE_ARG_POINTER(aDefaultActionEnabled);
NS_ENSURE_STATE(aRequest);
static_cast<DOMRequest*>(aRequest)->FireSuccess(aResult, aDefaultActionEnabled);
static_cast<DOMRequest*>(aRequest)->FireSuccess(aResult);
return NS_OK;
}
NS_IMETHODIMP
DOMRequestService::FireError(nsIDOMDOMRequest* aRequest,
const nsAString& aError,
bool* aDefaultActionEnabled)
const nsAString& aError)
{
NS_ENSURE_ARG_POINTER(aDefaultActionEnabled);
NS_ENSURE_STATE(aRequest);
static_cast<DOMRequest*>(aRequest)->FireError(aError, aDefaultActionEnabled);
static_cast<DOMRequest*>(aRequest)->FireError(aError);
return NS_OK;
}

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

@ -37,9 +37,9 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(DOMRequest,
nsDOMEventTargetHelper)
void FireSuccess(jsval aResult, bool* aDefaultActionEnabled);
void FireError(const nsAString& aError, bool* aDefaultActionEnabled);
void FireError(nsresult aError, bool* aDefaultActionEnabled);
void FireSuccess(jsval aResult);
void FireError(const nsAString& aError);
void FireError(nsresult aError);
DOMRequest(nsIDOMWindow* aWindow);
DOMRequest();
@ -52,8 +52,7 @@ public:
}
protected:
void FireEvent(const nsAString& aType, bool aBubble, bool aCancelable,
bool* aDefaultActionEnabled);
void FireEvent(const nsAString& aType, bool aBubble, bool aCancelable);
virtual void RootResultVal();
virtual void UnrootResultVal();

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

@ -21,11 +21,11 @@ interface nsIDOMDOMRequest : nsIDOMEventTarget
attribute nsIDOMEventListener onerror;
};
[scriptable, builtinclass, uuid(46afe27a-d407-4eb8-95c4-aefbd2b63540)]
[scriptable, builtinclass, uuid(eebcdf29-f8fa-4c36-bbc7-2146b1cbaf7b)]
interface nsIDOMRequestService : nsISupports
{
nsIDOMDOMRequest createRequest(in nsIDOMWindow window);
bool fireSuccess(in nsIDOMDOMRequest request, in jsval result);
bool fireError(in nsIDOMDOMRequest request, in DOMString error);
void fireSuccess(in nsIDOMDOMRequest request, in jsval result);
void fireError(in nsIDOMDOMRequest request, in DOMString error);
};

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

@ -35,7 +35,7 @@ var ev = null;
req.onsuccess = function(e) {
ev = e;
}
is(reqserv.fireSuccess(req, "my result"), true, "prevent default not detected");
reqserv.fireSuccess(req, "my result");
ok(ev, "got success event");
is(ev.type, "success", "correct type during success");
is(ev.target, req, "correct target during success");
@ -49,7 +49,7 @@ ev = null;
req.onerror = function(e) {
ev = e;
}
is(reqserv.fireError(req, "OhMyError"), true, "prevent default not detected");
reqserv.fireError(req, "OhMyError");
ok(ev, "got success event");
is(ev.type, "error", "correct type during error");
is(ev.target, req, "correct target during error");
@ -57,16 +57,6 @@ is(req.readyState, "done", "correct readyState after error");
is(req.error.name, "OhMyError", "correct error after error");
is(req.result, undefined, "correct result after error");
// Test calling preventDefault on events
req.onsuccess = function(e) e.preventDefault();
reqserv.fireSuccess(req, "my result");
is(reqserv.fireSuccess(req, "my result"), false, "prevent default detected");
// fire error
req.onerror = function(e) e.preventDefault();
reqserv.fireError(req, "OhMyError");
is(reqserv.fireError(req, "OhMyError"), false, "prevent default detected");
</script>
</pre>
</body>

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

@ -36,16 +36,14 @@ DeviceStorageRequestChild::Recv__delete__(const DeviceStorageResponseValue& aVal
case DeviceStorageResponseValue::TErrorResponse:
{
ErrorResponse r = aValue;
bool allowDefault;
mRequest->FireError(r.error(), &allowDefault);
mRequest->FireError(r.error());
break;
}
case DeviceStorageResponseValue::TSuccessResponse:
{
jsval result = StringToJsval(mRequest->GetOwner(), mFile->mPath);
bool allowDefault;
mRequest->FireSuccess(result, &allowDefault);
mRequest->FireSuccess(result);
break;
}
@ -67,8 +65,7 @@ DeviceStorageRequestChild::Recv__delete__(const DeviceStorageResponseValue& aVal
mimeType);
jsval result = BlobToJsval(mRequest->GetOwner(), blob);
bool allowDefault;
mRequest->FireSuccess(result, &allowDefault);
mRequest->FireSuccess(result);
break;
}

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

@ -537,8 +537,7 @@ public:
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
bool allowDefault;
mRequest->FireError(mError, &allowDefault);
mRequest->FireError(mError);
mRequest = nullptr;
return NS_OK;
}
@ -579,8 +578,7 @@ ContinueCursorEvent::Run() {
cursor->mOkToCallContinue = true;
}
bool allowDefault;
mRequest->FireSuccess(val, &allowDefault);
mRequest->FireSuccess(val);
mRequest = nullptr;
return NS_OK;
}
@ -795,8 +793,7 @@ public:
result = StringToJsval(mRequest->GetOwner(), mPath);
}
bool allowDefault;
mRequest->FireSuccess(result, &allowDefault);
mRequest->FireSuccess(result);
mRequest = nullptr;
return NS_OK;
}

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

@ -88,10 +88,8 @@ ArchiveRequest::Run()
// Register this request to the reader.
// When the reader is ready to return data, a 'Ready()' will be called
nsresult rv = mArchiveReader->RegisterRequest(this);
if (NS_FAILED(rv)) {
bool allowDefault;
FireError(rv, &allowDefault);
}
if (NS_FAILED(rv))
FireError(rv);
}
void
@ -111,9 +109,8 @@ nsresult
ArchiveRequest::ReaderReady(nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList,
nsresult aStatus)
{
bool allowDefault;
if (aStatus != NS_OK) {
FireError(aStatus, &allowDefault);
FireError(aStatus);
return NS_OK;
}
@ -151,10 +148,10 @@ ArchiveRequest::ReaderReady(nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList,
}
if (NS_SUCCEEDED(rv)) {
FireSuccess(result, &allowDefault);
FireSuccess(result);
}
else {
FireError(rv, &allowDefault);
FireError(rv);
}
return NS_OK;

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

@ -62,9 +62,8 @@ FileRequest::NotifyHelperCompleted(FileHelper* aFileHelper)
nsresult rv = aFileHelper->mResultCode;
// If the request failed then fire error event and return.
bool allowDefault;
if (NS_FAILED(rv)) {
FireError(rv, &allowDefault);
FireError(rv);
return NS_OK;
}
@ -94,10 +93,10 @@ FileRequest::NotifyHelperCompleted(FileHelper* aFileHelper)
}
if (NS_SUCCEEDED(rv)) {
FireSuccess(result, &allowDefault);
FireSuccess(result);
}
else {
FireError(rv, &allowDefault);
FireError(rv);
}
return NS_OK;