Bug 1441982 - Only allow an unopened GeckoSession as a response to onNewSession() r=jchen
authorJames Willcox <snorp@snorp.net>
Tue, 27 Feb 2018 18:11:23 -0500
changeset 461858 cf7689be97bcac8c139615250dcb59f0ea676275
parent 461857 5c570aa49dfb8b5021f6b0ae50f50050d5f9bada
child 461859 b71f6a4e18cb33cc6490963b75ff515533d67cd9
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs1441982
milestone60.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 1441982 - Only allow an unopened GeckoSession as a response to onNewSession() r=jchen This is a little clearer than the current semantics and explicitly allows reusing an existing GeckoSession instance (as long as it's not yet open). MozReview-Commit-ID: 8e8gvOEjYze
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TestRunnerActivity.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TestRunnerActivity.java
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TestRunnerActivity.java
@@ -88,17 +88,16 @@ public class TestRunnerActivity extends 
 
             // We can't use e10s because we get deadlocked when quickly creating and
             // destroying sessions. Bug 1348361.
             settings.setBoolean(GeckoSessionSettings.USE_MULTIPROCESS, false);
         }
 
         final GeckoSession session = new GeckoSession(settings);
         session.setNavigationDelegate(mNavigationDelegate);
-        session.openWindow(this);
         return session;
     }
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         Intent intent = getIntent();
@@ -106,16 +105,17 @@ public class TestRunnerActivity extends 
 
         final String intentArgs = intent.getStringExtra("args");
         final String args = intentArgs != null ? "-purgecaches " + intentArgs : "-purgecaches";
         GeckoSession.preload(this, args, false /* no multiprocess, see below */);
 
         // We can't use e10s because we get deadlocked when quickly creating and
         // destroying sessions. Bug 1348361.
         mSession = createSession();
+        mSession.openWindow(this);
 
         // If we were passed a URI in the Intent, open it
         final Uri uri = intent.getData();
         if (uri != null) {
             mSession.loadUri(uri);
         }
 
         mView = new GeckoView(this);
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
@@ -146,21 +146,27 @@ public class GeckoSession extends LayerS
                         delegate.onLoadUri(GeckoSession.this, uri, where);
                     callback.sendSuccess(result);
                 } else if ("GeckoView:OnNewSession".equals(event)) {
                     final String uri = message.getString("uri");
                     delegate.onNewSession(GeckoSession.this, uri,
                         new Response<GeckoSession>() {
                             @Override
                             public void respond(GeckoSession session) {
-                                if (session != null && session.isOpen() && session.isReady()) {
-                                    throw new IllegalArgumentException("Must use a new GeckoSession instance");
+                                if (session == null) {
+                                    callback.sendSuccess(null);
+                                    return;
                                 }
 
-                                callback.sendSuccess(session != null ? session.getId() : null);
+                                if (session.isOpen()) {
+                                    throw new IllegalArgumentException("Must use an unopened GeckoSession instance");
+                                }
+
+                                session.openWindow(null);
+                                callback.sendSuccess(session.getId());
                             }
                         });
                 }
             }
         };
 
     private final GeckoSessionHandler<ProgressDelegate> mProgressHandler =
         new GeckoSessionHandler<ProgressDelegate>(