Bug 1441964 - [1.0] Return URI-load delegation success state instead of throwing. r=snorp
authorEugen Sawin <esawin@mozilla.com>
Wed, 28 Feb 2018 00:24:52 +0100
changeset 761271 f248db9bdb5c5fae6bc7f1fcede2eff6dc4808e8
parent 761270 120334ac0e535522a7544773b06345ca94b0c64b
child 761272 2b0380882e88956b620e68c414663b02d08cb9d5
push id100926
push userrwood@mozilla.com
push dateWed, 28 Feb 2018 21:51:29 +0000
reviewerssnorp
bugs1441964
milestone60.0a1
Bug 1441964 - [1.0] Return URI-load delegation success state instead of throwing. r=snorp
docshell/base/nsDocShell.cpp
mobile/android/chrome/geckoview/GeckoViewNavigationContent.js
xpcom/base/nsILoadURIDelegate.idl
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -9643,18 +9643,20 @@ nsDocShell::InternalLoad(nsIURI* aURI,
     const int where = (aWindowTarget.IsEmpty() || targetDocShell)
                       ? nsIBrowserDOMWindow::OPEN_CURRENTWINDOW
                       : nsIBrowserDOMWindow::OPEN_NEWWINDOW;
 
     if (where == nsIBrowserDOMWindow::OPEN_NEWWINDOW && isDocumentAuxSandboxed) {
       return NS_ERROR_DOM_INVALID_ACCESS_ERR;
     }
 
-    if (NS_SUCCEEDED(mLoadURIDelegate->LoadURI(aURI, where, aFlags,
-                                               aTriggeringPrincipal))) {
+    bool loadURIHandled = false;
+    rv = mLoadURIDelegate->LoadURI(aURI, where, aFlags, aTriggeringPrincipal,
+                                   &loadURIHandled);
+    if (NS_SUCCEEDED(rv) && loadURIHandled) {
       // The request has been handled, nothing to do here.
       return NS_OK;
     }
   }
 
   //
   // Resolve the window target before going any further...
   // If the load has been targeted to another DocShell, then transfer the
--- a/mobile/android/chrome/geckoview/GeckoViewNavigationContent.js
+++ b/mobile/android/chrome/geckoview/GeckoViewNavigationContent.js
@@ -48,15 +48,13 @@ class GeckoViewNavigationContent extends
     this.eventDispatcher.sendRequestForResult(message).then(response => {
       handled = response;
     }, () => {
       // There was an error or listener was not registered in GeckoSession, treat as unhandled.
       handled = false;
     });
     Services.tm.spinEventLoopUntil(() => handled !== undefined);
 
-    if (!handled) {
-      throw Cr.NS_ERROR_ABORT;
-    }
+    return handled;
   }
 }
 
 var navigationListener = new GeckoViewNavigationContent("GeckoViewNavigation", this);
--- a/xpcom/base/nsILoadURIDelegate.idl
+++ b/xpcom/base/nsILoadURIDelegate.idl
@@ -22,12 +22,12 @@ interface nsILoadURIDelegate : nsISuppor
   /**
    * Delegates the URI load.
    *
    * @param aURI The URI to load.
    * @param aWhere See possible values described in nsIBrowserDOMWindow.
    * @param aFlags Flags which control the behavior of the load.
    * @param aTriggeringPrincipal The principal that triggered the load of aURI.
   */
-  void
+  boolean
   loadURI(in nsIURI aURI, in short aWhere, in long aFlags,
           in nsIPrincipal aTriggeringPrincipal);
 };