Backed out changeset 31b5c6b8ef22 (bug 1487542) for apiling. CLOSED TREE
authorDorel Luca <dluca@mozilla.com>
Wed, 21 Nov 2018 22:35:24 +0200
changeset 504047 52072aea049989476355bf06e4a1be4106cc052f
parent 504046 31b5c6b8ef22814d46d15f7efb2b45a16767d74f
child 504048 834b61114235c7a2f2413d135ad11e5b4148c09b
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1487542
milestone65.0a1
backs out31b5c6b8ef22814d46d15f7efb2b45a16767d74f
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 31b5c6b8ef22 (bug 1487542) for apiling. CLOSED TREE
docshell/base/nsIWebNavigation.idl
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationDelegateTest.kt
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java
uriloader/base/nsDocLoader.cpp
--- a/docshell/base/nsIWebNavigation.idl
+++ b/docshell/base/nsIWebNavigation.idl
@@ -210,21 +210,16 @@ interface nsIWebNavigation : nsISupports
 
   /**
    * Allows a top-level data: navigation to occur. E.g. view-image
    * is an explicit user action which should be allowed.
    */
   const unsigned long LOAD_FLAGS_FORCE_ALLOW_DATA_URI = 0x400000;
 
   /**
-   * This load is the result of an HTTP redirect.
-   */
-  const unsigned long LOAD_FLAGS_IS_REDIRECT = 0x800000;
-
-  /**
    * Loads a given URI.  This will give priority to loading the requested URI
    * in the object implementing	this interface.  If it can't be loaded here
    * however, the URI dispatcher will go through its normal process of content
    * loading.
    *
    * @param aURI
    *        The URI string to load.  For HTTP and FTP URLs and possibly others,
    *        characters above U+007F will be converted to UTF-8 and then URL-
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationDelegateTest.kt
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationDelegateTest.kt
@@ -229,18 +229,16 @@ class NavigationDelegateTest : BaseSessi
                 assertThat("URI should not be null", request.uri, notNullValue())
                 assertThat("URL should match", request.uri,
                         equalTo(forEachCall(request.uri, redirectUri)))
                 assertThat("Trigger URL should be null", request.triggerUri,
                            nullValue())
                 assertThat("Target should not be null", request.target, notNullValue())
                 assertThat("Target should match", request.target,
                         equalTo(GeckoSession.NavigationDelegate.TARGET_WINDOW_CURRENT))
-                assertThat("Redirect flag is set", request.isRedirect,
-                        equalTo(forEachCall(false, true)))
                 return null
             }
         })
     }
 
     @Test fun safebrowsingPhishing() {
         val phishingUri = "https://www.itisatrap.org/firefox/its-a-trap.html"
 
@@ -500,17 +498,16 @@ class NavigationDelegateTest : BaseSessi
                 assertThat("Session should not be null", session, notNullValue())
                 assertThat("URI should not be null", request.uri, notNullValue())
                 assertThat("URI should match", request.uri, endsWith(HELLO_HTML_PATH))
                 assertThat("Trigger URL should be null", request.triggerUri,
                            nullValue())
                 assertThat("Target should not be null", request.target, notNullValue())
                 assertThat("Target should match", request.target,
                            equalTo(GeckoSession.NavigationDelegate.TARGET_WINDOW_CURRENT))
-                assertThat("Redirect flag is not set", request.isRedirect, equalTo(false))
                 return null
             }
 
             @AssertCalled(count = 1, order = [2])
             override fun onLocationChange(session: GeckoSession, url: String) {
                 assertThat("Session should not be null", session, notNullValue())
                 assertThat("URL should not be null", url, notNullValue())
                 assertThat("URL should match", url, endsWith(HELLO_HTML_PATH))
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
@@ -406,16 +406,21 @@ public class GeckoSession implements Par
                     case 0: // OPEN_DEFAULTWINDOW
                     case 1: // OPEN_CURRENTWINDOW
                         return NavigationDelegate.TARGET_WINDOW_CURRENT;
                     default: // OPEN_NEWWINDOW, OPEN_NEWTAB, OPEN_SWITCHTAB
                         return NavigationDelegate.TARGET_WINDOW_NEW;
                 }
             }
 
+            // The flags are already matched with nsIDocShell.idl.
+            private int filterFlags(int flags) {
+                return flags & NavigationDelegate.LOAD_REQUEST_IS_USER_TRIGGERED;
+            }
+
             @Override
             public void handleMessage(final NavigationDelegate delegate,
                                       final String event,
                                       final GeckoBundle message,
                                       final EventCallback callback) {
                 if ("GeckoView:LocationChange".equals(event)) {
                     if (message.getBoolean("isTopLevel")) {
                         delegate.onLocationChange(GeckoSession.this,
@@ -2802,34 +2807,40 @@ public class GeckoSession implements Par
         void onCanGoForward(GeckoSession session, boolean canGoForward);
 
         @IntDef({TARGET_WINDOW_NONE, TARGET_WINDOW_CURRENT, TARGET_WINDOW_NEW})
         /* package */ @interface TargetWindow {}
         public static final int TARGET_WINDOW_NONE = 0;
         public static final int TARGET_WINDOW_CURRENT = 1;
         public static final int TARGET_WINDOW_NEW = 2;
 
-        // Match with nsIWebNavigation.idl.
+        @IntDef(flag = true,
+                value = {LOAD_REQUEST_IS_USER_TRIGGERED})
+                /* package */ @interface LoadRequestFlags {}
+
+        // Match with nsIDocShell.idl.
         /**
-         * The load request was triggered by an HTTP redirect.
+         * The load request was triggered by user input.
          */
-        static final int LOAD_REQUEST_IS_REDIRECT = 0x800000;
+        public static final int LOAD_REQUEST_IS_USER_TRIGGERED = 0x1000;
 
         /**
          * Load request details.
          */
         public static class LoadRequest {
             /* package */ LoadRequest(@NonNull final String uri,
                                       @Nullable final String triggerUri,
                                       int geckoTarget,
                                       int flags) {
                 this.uri = uri;
                 this.triggerUri = triggerUri;
                 this.target = convertGeckoTarget(geckoTarget);
-                this.isRedirect = (flags & LOAD_REQUEST_IS_REDIRECT) != 0;
+
+                // Match with nsIDocShell.idl.
+                this.isUserTriggered = (flags & 0x1000) != 0;
             }
 
             // This needs to match nsIBrowserDOMWindow.idl
             private @TargetWindow int convertGeckoTarget(int geckoTarget) {
                 switch (geckoTarget) {
                     case 0: // OPEN_DEFAULTWINDOW
                     case 1: // OPEN_CURRENTWINDOW
                         return TARGET_WINDOW_CURRENT;
@@ -2853,17 +2864,17 @@ public class GeckoSession implements Par
              * The target where the window has requested to open.
              * One of {@link #TARGET_WINDOW_NONE TARGET_WINDOW_*}.
              */
             public final @TargetWindow int target;
 
             /**
              * True if and only if the request was triggered by user interaction.
              */
-            public final boolean isRedirect;
+            public final boolean isUserTriggered;
         }
 
         /**
          * A request to open an URI. This is called before each page load to
          * allow custom behavior implementation.
          * For example, this can be used to override the behavior of
          * TAGET_WINDOW_NEW requests, which defaults to requesting a new
          * GeckoSession via onNewSession.
--- a/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java
+++ b/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java
@@ -670,17 +670,17 @@ public class GeckoViewActivity extends A
         }
 
         @Override
         public GeckoResult<AllowOrDeny> onLoadRequest(final GeckoSession session,
                                                       final LoadRequest request) {
             Log.d(LOGTAG, "onLoadRequest=" + request.uri +
                   " triggerUri=" + request.triggerUri +
                   " where=" + request.target +
-                  " isRedirect=" + request.isRedirect);
+                  " isUserTriggered=" + request.isUserTriggered);
 
             return GeckoResult.fromValue(AllowOrDeny.ALLOW);
         }
 
         @Override
         public GeckoResult<GeckoSession> onNewSession(final GeckoSession session, final String uri) {
             GeckoSession newSession = new GeckoSession(session.getSettings());
 
--- a/uriloader/base/nsDocLoader.cpp
+++ b/uriloader/base/nsDocLoader.cpp
@@ -6,17 +6,16 @@
 #include "nspr.h"
 #include "mozilla/Logging.h"
 #include "mozilla/IntegerPrintfMacros.h"
 
 #include "nsDocLoader.h"
 #include "nsCURILoader.h"
 #include "nsNetUtil.h"
 #include "nsIHttpChannel.h"
-#include "nsIWebNavigation.h"
 #include "nsIWebProgressListener2.h"
 
 #include "nsIServiceManager.h"
 #include "nsString.h"
 
 #include "nsIURL.h"
 #include "nsCOMPtr.h"
 #include "nscore.h"
@@ -1442,18 +1441,17 @@ NS_IMETHODIMP nsDocLoader::AsyncOnChanne
     if (delegate) {
       // No point in getting the URI if we don't have a LoadURIDelegate.
       aNewChannel->GetURI(getter_AddRefs(newURI));
     }
 
     if (newURI) {
       const int where = nsIBrowserDOMWindow::OPEN_CURRENTWINDOW;
       bool loadURIHandled = false;
-      nsresult rv = delegate->LoadURI(newURI, where,
-                                      nsIWebNavigation::LOAD_FLAGS_IS_REDIRECT,
+      nsresult rv = delegate->LoadURI(newURI, where, /* flags */ 0,
                                       /* triggering principal */ nullptr,
                                       &loadURIHandled);
       if (NS_SUCCEEDED(rv) && loadURIHandled) {
         cb->OnRedirectVerifyCallback(NS_OK);
         return NS_OK;
       }
     }
   }