Bug 1401208 - Change default web app scope to the start_url r=esawin draft
authorJames Willcox <snorp@snorp.net>
Tue, 19 Sep 2017 09:45:04 -0500
changeset 667011 59c26ca04c9d4d13fcc25669fc1f303db2c98fca
parent 667010 5d0acf8261bd8e6595a36148f56b4ec8c4237cf9
child 732272 616fc84aa577c7b341e7364925e23fb48e0a547f
push id80587
push userbmo:snorp@snorp.net
push dateTue, 19 Sep 2017 14:49:37 +0000
reviewersesawin
bugs1401208
milestone57.0a1
Bug 1401208 - Change default web app scope to the start_url r=esawin MozReview-Commit-ID: Jvbru5oRYDH
mobile/android/base/java/org/mozilla/gecko/webapps/WebAppManifest.java
--- a/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppManifest.java
+++ b/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppManifest.java
@@ -100,18 +100,18 @@ public class WebAppManifest {
     public String getOrientation() {
         return mOrientation;
     }
 
     private void readManifest(final JSONObject manifest, final JSONObject manifestField) {
         mThemeColor = readThemeColor(manifestField);
         mName = readName(manifestField);
         mIcon = readIcon(manifest);
+        mStartUri = readStartUrl(manifestField);
         mScope = readScope(manifestField);
-        mStartUri = readStartUrl(manifestField);
 
         mDisplayMode = manifestField.optString("display", null);
         mOrientation = manifestField.optString("orientation", null);
     }
 
     private Integer readThemeColor(final JSONObject manifest) {
         final String colorStr = manifest.optString("theme_color", null);
         if (colorStr != null) {
@@ -182,24 +182,25 @@ public class WebAppManifest {
         for (int i = 0; i < (segments.size() - 1); i++) {
             builder.appendPath(segments.get(i));
         }
 
         return builder.build();
     }
 
     private Uri readScope(final JSONObject manifest) {
+        final Uri defaultScope = stripLastPathSegment(mStartUri);
         final String scopeStr = manifest.optString("scope", null);
         if (scopeStr == null) {
-            return null;
+            return defaultScope;
         }
 
         Uri scope = Uri.parse(scopeStr);
         if (scope == null) {
-            return null;
+            return defaultScope;
         }
 
         if (scope.isRelative()) {
             scope = buildRelativeUrl(stripLastPathSegment(mManifestUri), scope);
         }
 
         return scope;
     }