Bug 1454228 - Ignore onSecurityChange for initial about:blank load in PWAs. r=jchen
authorDylan Roeh <droeh@mozilla.com>
Fri, 27 Apr 2018 12:56:29 -0500
changeset 416136 9ebd471b8e07825cae5aca75a69eb97dd5d079a1
parent 416135 7fe6dcb67de4cbb2a71b9c26e3bda8eb364f2966
child 416137 560f881dffb8c2c35384ca89dc7a25df1ee15a7b
push id33917
push userapavel@mozilla.com
push dateSat, 28 Apr 2018 17:30:55 +0000
treeherdermozilla-central@08f68e2c892c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs1454228
milestone61.0a1
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
Bug 1454228 - Ignore onSecurityChange for initial about:blank load in PWAs. r=jchen
mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java
--- a/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java
@@ -68,16 +68,18 @@ public class WebAppActivity extends AppC
     private boolean mCanGoBack;
 
     private Uri mManifestUrl;
     private Uri mStartUrl;
     private Uri mScope;
 
     private WebAppManifest mManifest;
 
+    private boolean mIsFirstLoad = true;
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0 &&
             savedInstanceState != null) {
             // Even though we're a single task activity, Android's task switcher has the
             // annoying habit of never updating its stored intent after our initial creation,
             // even if we've been subsequently started with a new intent.
 
@@ -107,16 +109,23 @@ public class WebAppActivity extends AppC
 
             @Override
             public void onPageStop(GeckoSession session, boolean success) {
 
             }
 
             @Override
             public void onSecurityChange(GeckoSession session, SecurityInformation security) {
+                // We want to ignore the extraneous first about:blank load
+                if (mIsFirstLoad && security.origin.startsWith("moz-nullprincipal:")) {
+                    mIsFirstLoad = false;
+                    return;
+                }
+                mIsFirstLoad = false;
+
                 int message;
                 if (!security.isSecure) {
                     if (SecurityInformation.CONTENT_LOADED == security.mixedModeActive) {
                         // Active Mixed Content loaded because user has disabled blocking.
                         message = R.string.mixed_content_protection_disabled;
                     } else if (SecurityInformation.CONTENT_LOADED == security.mixedModePassive) {
                         // Passive Mixed Content loaded.
                         if (SecurityInformation.CONTENT_BLOCKED == security.mixedModeActive) {
@@ -130,17 +139,16 @@ public class WebAppActivity extends AppC
                     }
                     fallbackToFennec(getString(message));
                 } else {
                     if (security.isException) {
                         message = R.string.identity_connection_insecure;
                         fallbackToFennec(getString(message));
                     }
                 }
-
             }
         });
 
         mPromptService = new PromptService(this, mGeckoView.getEventDispatcher());
         mDoorHangerPopup = new DoorHangerPopup(this, mGeckoView.getEventDispatcher());
 
         mFormAssistPopup = (FormAssistPopup) findViewById(R.id.pwa_form_assist_popup);
         mFormAssistPopup.create(mGeckoView);