Closed Bug 1162099 Opened 10 years ago Closed 10 years ago

Use the dynamic UA override mechanism in Fennec

Categories

(Firefox for Android Graveyard :: General, defect)

defect
Not set
normal

Tracking

(p11+, firefox41 fixed, fennec+)

RESOLVED FIXED
Firefox 41
Tracking Status
p11 + ---
firefox41 --- fixed
fennec + ---

People

(Reporter: miketaylr, Assigned: miketaylr)

References

(Blocks 1 open bug)

Details

Attachments

(3 files, 9 obsolete files)

1.45 KB, patch
miketaylr
: review+
Details | Diff | Splinter Review
1.68 KB, patch
miketaylr
: review+
Details | Diff | Splinter Review
2.12 KB, patch
nalexander
: review+
Details | Diff | Splinter Review
The infrastructure for this was handled in Bug 897221. This bug would mean Fennec would be able to actually use it which would require: 1) Shipping a ua-updates.json. 2) Settings prefs to enable it and point to the updateable list. 2) Making sure the in-tree file is synced to the same place B2G's is: "https://dynamicua.cdn.mozilla.net/0/%APP_ID%" (once this is done we could move the youtube override from mobile.js to ua-updates.json as well). I'm happy to write the patches for this, with some feedback from the Fennec team.
I should note that it's possible to restrict this to distributions as well, rather than shipping to everyone. But that may lead to situations where people on different Fennec builds/distributions get different experiences, which seems bad.
tracking-fennec: --- → ?
tracking-fennec: ? → +
tracking-p11: --- → +
Assignee: nobody → miket
Blocks: 1163759
If you want to test that this works manually, you can flip use these pref values in mobile.js: pref("general.useragent.updates.enabled", true); pref("general.useragent.updates.url", "https://miketaylr.com/bzla/ua-update.json"); You should then be able to navigate to echo.opera.com and see something like "IT WORKS!!" for a User-Agent header.
Depends on: 1078267
I should note that I cribbed the Makefile jazz from how B2G does this: <https://dxr.mozilla.org/mozilla-central/source/b2g/app/Makefile.in#8> I about as inexperienced as they get with the build system, so there may be nicer ways to go about this.
Comment on attachment 8604292 [details] [diff] [review] Part-2-Bug-1162099-Add-Makefile.in-to-mobile-android-app-fo.patch Nick might have ideas for moving this into moz.build
Attachment #8604292 - Flags: review?(nalexander)
Comment on attachment 8604290 [details] [diff] [review] Part-1-Bug-1162099-Create-ua-override.json.in-and-move-Yout.patch >diff --git a/mobile/android/app/ua-update.json.in b/mobile/android/app/ua-update.json.in >+ "youtube.com": "Android; Tablet;#Android; Mobile;" >+} >\ No newline at end of file Add a newline
Attachment #8604290 - Flags: review?(mark.finkle) → review+
Attachment #8604293 - Flags: review?(mark.finkle) → review+
Comment on attachment 8604294 [details] [diff] [review] Part-4-Bug-1162099-Set-the-prefs-to-use-the-dynamic-UA-over.patch >+// See ua-update.json.in for the packaged UA override list >+// XXX See Bug 1163759 before setting this to true Drop the XXX
Attachment #8604294 - Flags: review?(mark.finkle) → review+
Thanks for the reviews Mark. (In reply to Mark Finkle (:mfinkle) from comment #8) > Comment on attachment 8604292 [details] [diff] [review] > Part-2-Bug-1162099-Add-Makefile.in-to-mobile-android-app-fo.patch > > Nick might have ideas for moving this into moz.build Cool. Originally I was using DIST_FILES += ['ua-update.json.in'] in /m/a/app's moz.build, but I wasn't sure if it was possible to strip comments from the file with sed after that point (without a Makefile). Like I said, sketchy grasp of the build system.
Carrying forward r+.
Attachment #8604290 - Attachment is obsolete: true
Carrying forward r+.
Attachment #8604294 - Attachment is obsolete: true
Comment on attachment 8604292 [details] [diff] [review] Part-2-Bug-1162099-Add-Makefile.in-to-mobile-android-app-fo.patch Review of attachment 8604292 [details] [diff] [review]: ----------------------------------------------------------------- We really don't want to add more invocations of sed to the build system. There are two things we can do here: use DIST_FILES (in moz.build) and the preprocessor's built-in "slashslash" directive, which appears to be intended for this usage; or use the new-ish moz.build GENERATED_FILES option. I'd prefer the former. So we'd have: .json.in: #filter slashslash // Comments. { "foo": "bar", // Comment. // Full line comment. } in moz.build: DIST_FILES += ['.json.in'] (I see an example in https://dxr.mozilla.org/mozilla-central/source/dom/indexedDB/test/extensions of a preprocessed DIST_FILES entry.) We should do this both here and in b2g/app. I am happy to do this and get build peer review, or to make this a separate ticket.
Attachment #8604292 - Flags: review?(nalexander) → review-
See Also: → 1164580
gps, we've tested that the "slashslash" preprocessor directive does what it's supposed to here (which is to remove the comments so the JSON isn't invalid). Is there any reason to not use it? I see there isn't any current usage in the tree.
Attachment #8605319 - Attachment is obsolete: true
(updated to include mfinkle's r+ in the commit message)
Attachment #8604292 - Attachment is obsolete: true
Attachment #8604293 - Attachment is obsolete: true
(updated commit message w/ r=mfinkle)
Attachment #8605320 - Attachment is obsolete: true
Once the updater mechanism does its thing and hits the server, this works as expected. For the life of me I can't figure out why I get the following message in the console on startup though (before anything is fetched from the network). I double checked with the original patchsets and it showed up there too...I think I missed it by not clearing data once an updated was saved to my profile. E/GeckoConsole(29088): [JavaScript Error: "A promise chain failed to handle a rejection. Did you forget to '.catch', or did you forget to 'return'? E/GeckoConsole(29088): See https://developer.mozilla.org/Mozilla/JavaScript_code_modules/Promise.jsm/Promise E/GeckoConsole(29088): E/GeckoConsole(29088): Date: Wed May 13 2015 21:30:23 GMT-0500 (CDT) E/GeckoConsole(29088): Full Message: Unix error 2 during operation open on file /data/data/org.mozilla.fennec_mtaylor/ua-update.json (No such file or directory) E/GeckoConsole(29088): Full Stack: JS frame :: resource://gre/modules/Promise.jsm -> resource://gre/modules/Promise-backend.js :: PendingErrors.register :: line 162 E/GeckoConsole(29088): JS frame :: resource://gre/modules/Promise.jsm -> resource://gre/modules/Promise-backend.js :: this.PromiseWalker.completePromise :: line 675 E/GeckoConsole(29088): JS frame :: resource://gre/modules/Promise.jsm -> resource://gre/modules/Promise-backend.js :: Handler.prototype.process :: line 903 E/GeckoConsole(29088): JS frame :: resource://gre/modules/Promise.jsm -> resource://gre/modules/Promise-backend.js :: this.PromiseWalker.walkerLoop :: line 746 E/GeckoConsole(29088): JS frame :: resource://gre/modules/Promise.jsm -> resource://gre/modules/ Nick, does dist/bin/ua-update.json not correspond to /data/data/org.mozilla.fennec_mtaylor/ua-update.json?
Acutally, maybe it's better to ni? jchen since he wrote the original code.
Comment on attachment 8605617 [details] [diff] [review] 1162099-1-Create-ua-override.json.patch Review of attachment 8605617 [details] [diff] [review]: ----------------------------------------------------------------- ::: mobile/android/app/ua-update.json.in @@ +1,2 @@ > +#filter slashslash > +// Comments must be on their own lines and must start with "//" This is no longer true. Everything after // is a comment. If we were to ever want // in a User-Agent string, that would be a problem.
Attachment #8605617 - Flags: review?(nalexander) → review+
Attachment #8605619 - Flags: review?(nalexander) → review+
> Nick, does dist/bin/ua-update.json not correspond to > /data/data/org.mozilla.fennec_mtaylor/ua-update.json? Add ua-update.json to the list at https://dxr.mozilla.org/mozilla-central/source/toolkit/mozapps/installer/upload-files.mk#305. Then run |mach package| and verify that it is in the APK: nalexander@chocho ~/M/gecko> unzip -l objdir-droid/dist/fennec-*apk | grep ua-update.json 62 05-13-15 20:29 ua-update.json I would much prefer such files make it into assets/, but one thing at a time. See Bug 1160563.
Flags: needinfo?(nchen)
(In reply to Nick Alexander :nalexander from comment #21) > ::: mobile/android/app/ua-update.json.in > @@ +1,2 @@ > > +#filter slashslash > > +// Comments must be on their own lines and must start with "//" > > This is no longer true. Everything after // is a comment. If we were to > ever want // in a User-Agent string, that would be a problem. Roger that. (In reply to Nick Alexander :nalexander from comment #22) > > Nick, does dist/bin/ua-update.json not correspond to > > /data/data/org.mozilla.fennec_mtaylor/ua-update.json? > > Add ua-update.json to the list at > https://dxr.mozilla.org/mozilla-central/source/toolkit/mozapps/installer/ > upload-files.mk#305. Cool, thanks again. ^_^
Updated the comment and commit message to reflect r+.
Attachment #8605617 - Attachment is obsolete: true
Seems like it makes sense to squash these commits that add ua-update.json(.in) to package.manifest, upload-files.mk and moz.build. And one last r? nalexander to rubber stamp adding the file to upload-files.mk.
Attachment #8605618 - Attachment is obsolete: true
Attachment #8605619 - Attachment is obsolete: true
Comment on attachment 8605646 [details] [diff] [review] 1162099-1-Create-ua-override.json.patch Oops, forgot to re-request feedback from gps on using the slashslash filter.
Attachment #8605648 - Flags: review?(nalexander) → review+
Try run looks good, but I'll wait for gps' feedback before requesting check-in. https://treeherder.mozilla.org/#/jobs?repo=try&revision=c07b2ed6d234&filter-tier=1
Comment on attachment 8605646 [details] [diff] [review] 1162099-1-Create-ua-override.json.patch Review of attachment 8605646 [details] [diff] [review]: ----------------------------------------------------------------- I'm not a huge fan of using the preprocessor period. But JSON doesn't give you much choice. It's better to have comments than no comments. So this is acceptable. Alternatively, you could write a Python script that defines a data structure and prints JSON. But that's probably a bit more scaffolding than you are willing to create. If only JSON supported in-line comments.
Attachment #8605646 - Flags: feedback?(gps) → feedback+
Thanks! Given the time-sensitive nature of this request, I think we'll skip the python -> JSON routine. But maybe that could be an option for the future.
Keywords: checkin-needed
Depends on: 1179300
See Also: → 1172015
See Also: → 1178760
Blocks: 1301587
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: