Backout 81a090e983d2, 8236b3579bf3,
authorWes Johnston <wjohnston@mozilla.com>
Tue, 07 Aug 2012 10:08:41 -0700
changeset 104805 621cb0844bf504b93fc90dcd21826f29b9b5cb37
parent 104804 42314e12d3254a6563291810ca18770bdb7ab74c
child 104806 ce9504d8a2a28dd9f8c7db300227a77adae5910b
push idunknown
push userunknown
push dateunknown
milestone17.0a1
backs out81a090e983d214f62f8257f98acf6bac305020b4
Backout 81a090e983d2, 8236b3579bf3,
dom/apps/src/Webapps.js
dom/base/DOMRequest.cpp
dom/base/DOMRequest.h
dom/base/nsIDOMDOMRequest.idl
dom/base/test/test_domrequest.html
dom/devicestorage/DeviceStorageRequestChild.cpp
dom/devicestorage/nsDeviceStorage.cpp
dom/file/ArchiveRequest.cpp
dom/file/FileRequest.cpp
--- a/dom/apps/src/Webapps.js
+++ b/dom/apps/src/Webapps.js
@@ -53,24 +53,16 @@ WebappsRegistry.prototype = {
                       install: 'r',
                       installPackage: 'r',
                       getSelf: 'r',
                       getInstalled: 'r',
                       getNotInstalled: 'r',
                       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
    */
   checkManifest: function(aManifest, aInstallOrigin) {
     if (aManifest.name == undefined)
       return false;
 
     if (aManifest.installs_allowed_from) {
@@ -90,17 +82,17 @@ WebappsRegistry.prototype = {
       return;
     let app = msg.app;
     switch (aMessage.name) {
       case "Webapps:Install:Return:OK":
         Services.DOMRequest.fireSuccess(req, createApplicationObject(this._window, app.origin, app.manifest, app.manifestURL, app.receipts,
                                                                      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) {
           app = msg.apps[0];
           Services.DOMRequest.fireSuccess(req, createApplicationObject(this._window, app.origin, app.manifest, app.manifestURL, app.receipts,
                                                                        app.installOrigin, app.installTime));
         } else {
           Services.DOMRequest.fireSuccess(req, null);
@@ -135,41 +127,41 @@ WebappsRegistry.prototype = {
     xhr.open("GET", aURL, true);
     xhr.channel.loadFlags |= Ci.nsIRequest.VALIDATE_ALWAYS;
 
     xhr.addEventListener("load", (function() {
       if (xhr.status == 200) {
         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 : [];
             cpmm.sendAsyncMessage("Webapps:Install", { app: { installOrigin: installOrigin,
                                                               origin: this._getOrigin(aURL),
                                                               manifestURL: aURL,
                                                               manifest: manifest,
                                                               receipts: receipts,
                                                               categories: categories },
                                                               from: installURL,
                                                               oid: this._id,
                                                               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);
     return request;
   },
 
   getSelf: function() {
     let request = this.createRequest();
--- a/dom/base/DOMRequest.cpp
+++ b/dom/base/DOMRequest.cpp
@@ -107,77 +107,77 @@ DOMRequest::GetError(nsIDOMDOMError** aE
                "Error should be null when pending");
 
   NS_IF_ADDREF(*aError = mError);
 
   return NS_OK;
 }
 
 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!");
   NS_ASSERTION(mResult == JSVAL_VOID, "mResult shouldn't have been set!");
 
   mDone = true;
   if (JSVAL_IS_GCTHING(aResult)) {
     RootResultVal();
   }
   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!");
   NS_ASSERTION(mResult == JSVAL_VOID, "mResult shouldn't have been set!");
 
   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!");
   NS_ASSERTION(mResult == JSVAL_VOID, "mResult shouldn't have been set!");
 
   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;
   }
 
   nsRefPtr<nsDOMEvent> event = new nsDOMEvent(nullptr, nullptr);
   nsresult rv = event->InitEvent(aType, aBubble, aCancelable);
   if (NS_FAILED(rv)) {
     return;
   }
 
   rv = event->SetTrusted(true);
   if (NS_FAILED(rv)) {
     return;
   }
 
-  DispatchEvent(event, aDefaultActionEnabled);
+  bool dummy;
+  DispatchEvent(event, &dummy);
 }
 
 void
 DOMRequest::RootResultVal()
 {
   NS_ASSERTION(!mRooted, "Don't call me if already rooted!");
   NS_HOLD_JS_OBJECTS(this, DOMRequest);
   mRooted = true;
@@ -200,29 +200,25 @@ DOMRequestService::CreateRequest(nsIDOMW
   NS_ENSURE_STATE(aWindow);
   NS_ADDREF(*aRequest = new DOMRequest(aWindow));
   
   return NS_OK;
 }
 
 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;
 }
--- a/dom/base/DOMRequest.h
+++ b/dom/base/DOMRequest.h
@@ -32,33 +32,32 @@ protected:
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMDOMREQUEST
   NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::)
 
   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();
 
   virtual ~DOMRequest()
   {
     if (mRooted) {
       UnrootResultVal();
     }
   }
 
 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();
 
   void Init(nsIDOMWindow* aWindow);
 };
 
 class DOMRequestService MOZ_FINAL : public nsIDOMRequestService
--- a/dom/base/nsIDOMDOMRequest.idl
+++ b/dom/base/nsIDOMDOMRequest.idl
@@ -16,16 +16,16 @@ interface nsIDOMDOMRequest : nsIDOMEvent
 
   readonly attribute jsval result;
   readonly attribute nsIDOMDOMError error;
 
   attribute nsIDOMEventListener onsuccess;
   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);
 };
--- a/dom/base/test/test_domrequest.html
+++ b/dom/base/test/test_domrequest.html
@@ -30,44 +30,34 @@ is(req.result, undefined, "result is und
 is(req.onsuccess, null, "onsuccess is null");
 is(req.onerror, null, "onerror is null");
 
 // fire success
 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");
 is(req.readyState, "done", "correct readyState after success");
 is(req.error, null, "correct error after success");
 is(req.result, "my result", "correct result after success");
 
 // fire error
 req = reqserv.createRequest(window);
 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");
 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>
 </html>
--- a/dom/devicestorage/DeviceStorageRequestChild.cpp
+++ b/dom/devicestorage/DeviceStorageRequestChild.cpp
@@ -31,26 +31,24 @@ DeviceStorageRequestChild::~DeviceStorag
 bool
 DeviceStorageRequestChild::Recv__delete__(const DeviceStorageResponseValue& aValue)
 {
   switch (aValue.type()) {
 
     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;
     }
 
     case DeviceStorageResponseValue::TBlobResponse:
     {
       BlobResponse r = aValue;
 
       // I am going to hell for this.  bent says he'll save me.
@@ -62,18 +60,17 @@ DeviceStorageRequestChild::Recv__delete_
       mimeType.AssignWithConversion(r.contentType());
 
       nsCOMPtr<nsIDOMBlob> blob = new nsDOMMemoryFile(buffer,
                                                       bits.Length(),
                                                       mFile->mPath,
                                                       mimeType);
 
       jsval result = BlobToJsval(mRequest->GetOwner(), blob);
-      bool allowDefault;
-      mRequest->FireSuccess(result, &allowDefault);
+      mRequest->FireSuccess(result);
       break;
     }
 
     case DeviceStorageResponseValue::TEnumerationResponse:
     {
       EnumerationResponse r = aValue;
       nsDOMDeviceStorageCursor* cursor = static_cast<nsDOMDeviceStorageCursor*>(mRequest.get());
 
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -532,18 +532,17 @@ public:
       mError.Append(NS_LITERAL_STRING("null path"));
     }
   }
 
   NS_IMETHOD Run()
   {
     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
-    bool allowDefault;
-    mRequest->FireError(mError, &allowDefault);
+    mRequest->FireError(mError);
     mRequest = nullptr;
     return NS_OK;
   }
 
 private:
   nsRefPtr<DOMRequest> mRequest;
   nsString mError;
 };
@@ -574,18 +573,17 @@ ContinueCursorEvent::Run() {
     nsRefPtr<DeviceStorageFile> file = cursor->mFiles[0];
     cursor->mFiles.RemoveElementAt(0);
 
     // todo, this blob needs to be opened in the parent.  This will be signifincally easier when bent lands
     val = nsIFileToJsval(cursor->GetOwner(), file);
     cursor->mOkToCallContinue = true;
   }
 
-  bool allowDefault;
-  mRequest->FireSuccess(val, &allowDefault);
+  mRequest->FireSuccess(val);
   mRequest = nullptr;
   return NS_OK;
 }
 
 class InitCursorEvent : public nsRunnable
 {
 public:
     InitCursorEvent(DOMRequest* aRequest, DeviceStorageFile* aFile)
@@ -790,18 +788,17 @@ public:
 
     jsval result = JSVAL_NULL;
     if (mFile) {
       result = nsIFileToJsval(mRequest->GetOwner(), mFile);
     } else {
       result = StringToJsval(mRequest->GetOwner(), mPath);
     }
 
-    bool allowDefault;
-    mRequest->FireSuccess(result, &allowDefault);
+    mRequest->FireSuccess(result);
     mRequest = nullptr;
     return NS_OK;
   }
 
 private:
   nsRefPtr<DeviceStorageFile> mFile;
   nsString mPath;
   nsRefPtr<DOMRequest> mRequest;
--- a/dom/file/ArchiveRequest.cpp
+++ b/dom/file/ArchiveRequest.cpp
@@ -83,20 +83,18 @@ ArchiveRequest::GetReader(nsIDOMArchiveR
 
 // Here the request is processed:
 void
 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
 ArchiveRequest::OpGetFilenames()
 {
   mOperation = GetFilenames;
 }
 
@@ -106,19 +104,18 @@ ArchiveRequest::OpGetFile(const nsAStrin
   mOperation = GetFile;
   mFilename = aFilename;
 }
 
 nsresult
 ArchiveRequest::ReaderReady(nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList,
                             nsresult aStatus)
 {
-  bool allowDefault;
   if (aStatus != NS_OK) {
-    FireError(aStatus, &allowDefault);
+    FireError(aStatus);
     return NS_OK;
   }
 
   jsval result;
   nsresult rv;
 
   nsIScriptContext* sc = GetContextForEventHandlers(&rv);
   NS_ENSURE_STATE(sc);
@@ -146,20 +143,20 @@ ArchiveRequest::ReaderReady(nsTArray<nsC
       NS_WARNING("Get*Result failed!");
     }
   } else {
     NS_WARNING("Failed to enter correct compartment!");
     rv = NS_ERROR_FAILURE;
   }
 
   if (NS_SUCCEEDED(rv)) {
-    FireSuccess(result, &allowDefault);
+    FireSuccess(result);
   }
   else {
-    FireError(rv, &allowDefault);
+    FireError(rv);
   }
 
   return NS_OK;
 }
 
 nsresult
 ArchiveRequest::GetFilenamesResult(JSContext* aCx,
                                    jsval* aValue,
--- a/dom/file/FileRequest.cpp
+++ b/dom/file/FileRequest.cpp
@@ -57,19 +57,18 @@ FileRequest::PreHandleEvent(nsEventChain
 nsresult
 FileRequest::NotifyHelperCompleted(FileHelper* aFileHelper)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   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;
   }
 
   // Otherwise we need to get the result from the helper.
   jsval result;
 
   nsIScriptContext* sc = GetContextForEventHandlers(&rv);
   NS_ENSURE_STATE(sc);
@@ -89,20 +88,20 @@ FileRequest::NotifyHelperCompleted(FileH
     }
   }
   else {
     NS_WARNING("Failed to enter correct compartment!");
     rv = NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR;
   }
 
   if (NS_SUCCEEDED(rv)) {
-    FireSuccess(result, &allowDefault);
+    FireSuccess(result);
   }
   else {
-    FireError(rv, &allowDefault);
+    FireError(rv);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 FileRequest::GetLockedFile(nsIDOMLockedFile** aLockedFile)
 {