Closed
Bug 1473181
Opened 7 years ago
Closed 7 years ago
GWS/Facebook UA experiment is not sending the custom UA on XMLHttpRequests
Categories
(Web Compatibility :: Interventions, enhancement, P1)
Web Compatibility
Interventions
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: twisniewski, Assigned: twisniewski)
References
()
Details
Attachments
(1 file)
It turns out that UserAgentOverrides.jsm observes http-on-useragent-request, which do not occur on XHRs. This causes breakage in the experiment (as seen in the see also link) where the tier-1 Google "more results" buttons are broken, because they send XHRs which get the stock Fennec UA string instead of the custom UA string the experiment should be sending.
If we instead hook into http-on-modify-request, the overrides will apply correctly to all the relevant requests (it is what webRequest.onBeforeSendHeaders uses).
While we're here I also plan to tweak the way the prefs work so that resetting the preference does not cause the pref to vanish without disabling the add-on.
| Comment hidden (mozreview-request) |
Updated•7 years ago
|
Priority: -- → P1
| Assignee | ||
Updated•7 years ago
|
Updated•7 years ago
|
Updated•7 years ago
|
See Also: → https://webcompat.com/issues/17583
| Assignee | ||
Comment 2•7 years ago
|
||
Mike, do you perhaps have the cycles to give this one a quicker review?
Flags: needinfo?(mconley)
Comment 3•7 years ago
|
||
| mozreview-review | ||
Comment on attachment 8989603 [details]
Bug 1473181 - Observe http modify request rather than useragent request in the GWS/FB addon to support overriding UA string on XHRs as well.
https://reviewboard.mozilla.org/r/254626/#review261856
Thanks!
::: mobile/android/extensions/gws-and-facebook-chrome-spoof/bootstrap.js:36
(Diff revision 1)
> + if (channel) {
> + if (channel.URI.asciiHost.match(TLDsToSpoof)) {
Let's combine these conditions, like:
```js
if (channel &&
channel.URI.asciiHost.match(TLDsToSpoof)) {
// Do work
}
```
::: mobile/android/extensions/gws-and-facebook-chrome-spoof/bootstrap.js:52
(Diff revision 1)
> + } catch (_) {
> + }
> +}
> +
> +function disable() {
> + Services.obs.removeObserver(HTTP_on_modify_request, "http-on-modify-request");
Maybe we should put this in a try/catch too?
::: mobile/android/extensions/gws-and-facebook-chrome-spoof/bootstrap.js:63
(Diff revision 1)
> + enable();
> + } else {
> + disable();
> + }
> + } catch (_) {
> + Services.prefs.getDefaultBranch(EnabledPrefBranch).setBoolPref("enabled", true);
Can you add a comment here about why we're using getDefaultBranch?
::: mobile/android/extensions/gws-and-facebook-chrome-spoof/bootstrap.js:73
(Diff revision 1)
> this.install = () => {
> Services.prefs.setBoolPref(EnabledPref, true);
> };
>
> this.uninstall = () => {
> Services.prefs.clearUserPref(EnabledPref);
We can probably skip this, since we're just deleting the pref now.
Attachment #8989603 -
Flags: review+
Updated•7 years ago
|
Flags: needinfo?(mconley)
| Comment hidden (mozreview-request) |
| Comment hidden (mozreview-request) |
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 7•7 years ago
|
||
Thanks Mike! I had to make one final tweak to pass the right kind of object into add/removeObserver (otherwise it was not actually removing the observer properly when I just passed in the observing function).
I'm carrying over r+, since this was a trivial change as can be seen in the interdiff: https://reviewboard.mozilla.org/r/254626/diff/2-4/
Requesting check-in.
Keywords: checkin-needed
Pushed by nerli@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/06295b3bc400
Observe http modify request rather than useragent request in the GWS/FB addon to support overriding UA string on XHRs as well. r=mconley
Keywords: checkin-needed
Updated•7 years ago
|
Comment 9•7 years ago
|
||
| bugherder | ||
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Updated•7 years ago
|
Updated•5 years ago
|
You need to log in
before you can comment on or make changes to this bug.
Description
•